@Test public void testExtract() { logger.info("extract"); Configuration configuration = getConfiguration(); String text = Datasets.exampleHtmlCode(); CETR.Parameters parameters = new CETR.Parameters(); parameters.setNumberOfClusters(2); parameters.setAlphaWindowSizeFor2DModel(3); parameters.setSmoothingAverageRadius(2); CETR instance = new CETR(configuration); String expResult = "This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission."; String result = instance.extract(text, parameters); assertEquals(expResult, result); }
public String extract(String html, CETR.Parameters parameters) { html = clearText(html); List<String> rows = extractRows(html); List<Integer> selectedRowIds = selectRows(rows, parameters); StringBuilder sb = new StringBuilder(html.length()); for(Integer rowId : selectedRowIds) { String row = rows.get(rowId); row = StringCleaner.removeExtraSpaces(HTMLParser.extractText(row)); if(row.isEmpty()) { continue; } sb.append(row).append(" "); } return sb.toString().trim(); }
CETR { public String extract(String html, CETR.Parameters parameters) { html = clearText(html); List<String> rows = extractRows(html); List<Integer> selectedRowIds = selectRows(rows, parameters); StringBuilder sb = new StringBuilder(html.length()); for(Integer rowId : selectedRowIds) { String row = rows.get(rowId); row = StringCleaner.removeExtraSpaces(HTMLParser.extractText(row)); if(row.isEmpty()) { continue; } sb.append(row).append(" "); } return sb.toString().trim(); } }
CETR { public String extract(String html, CETR.Parameters parameters) { html = clearText(html); List<String> rows = extractRows(html); List<Integer> selectedRowIds = selectRows(rows, parameters); StringBuilder sb = new StringBuilder(html.length()); for(Integer rowId : selectedRowIds) { String row = rows.get(rowId); row = StringCleaner.removeExtraSpaces(HTMLParser.extractText(row)); if(row.isEmpty()) { continue; } sb.append(row).append(" "); } return sb.toString().trim(); } CETR(Configuration configuration); }
CETR { public String extract(String html, CETR.Parameters parameters) { html = clearText(html); List<String> rows = extractRows(html); List<Integer> selectedRowIds = selectRows(rows, parameters); StringBuilder sb = new StringBuilder(html.length()); for(Integer rowId : selectedRowIds) { String row = rows.get(rowId); row = StringCleaner.removeExtraSpaces(HTMLParser.extractText(row)); if(row.isEmpty()) { continue; } sb.append(row).append(" "); } return sb.toString().trim(); } CETR(Configuration configuration); String extract(String html, CETR.Parameters parameters); }
CETR { public String extract(String html, CETR.Parameters parameters) { html = clearText(html); List<String> rows = extractRows(html); List<Integer> selectedRowIds = selectRows(rows, parameters); StringBuilder sb = new StringBuilder(html.length()); for(Integer rowId : selectedRowIds) { String row = rows.get(rowId); row = StringCleaner.removeExtraSpaces(HTMLParser.extractText(row)); if(row.isEmpty()) { continue; } sb.append(row).append(" "); } return sb.toString().trim(); } CETR(Configuration configuration); String extract(String html, CETR.Parameters parameters);  }