public int nrOfTables(){ int result = 0; for( Section s: sections ) result+= s.nrOfTables(); return result; }
public Table getTable(int i){ int nr = 0; int offset = 0; for( Section s: sections ){ nr = s.nrOfTables(); if( nr+offset > i )return s.getTable(i-offset); offset += nr; } return null; }
/** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { // load a sample document (the contents are equal to "DarmstadtWikipediaArticle.txt") String documentText = TestFile.getFileText(); //get a ParsedPage object MediaWikiParserFactory pf = new MediaWikiParserFactory(); MediaWikiParser parser = pf.createParser(); ParsedPage pp = parser.parse(documentText); //get the sections for(Section section : pp.getSections()) { System.out.println("section : " + section.getTitle()); System.out.println(" nr of paragraphs : " + section.nrOfParagraphs()); System.out.println(" nr of tables : " + section.nrOfTables()); System.out.println(" nr of nested lists : " + section.nrOfNestedLists()); System.out.println(" nr of definition lists: " + section.nrOfDefinitionLists()); } } }