@Test public void shouldGetTheFirstHtmlWithContent() { String html = "<html xmlns=\"http: "<head>\n" + "<meta name=\"X-Parsed-By\" content=\"org.apache.tika.parser.DefaultParser\" />\n" + "<meta name=\"X-Parsed-By\" content=\"org.apache.tika.parser.ocr.TesseractOCRParser\" />\n" + "<meta name=\"Content-Type\" content=\"image/tiff\" />\n" + "<title></title>\n" + "</head>\n" + "<body><div>Replace this ﬁle with prentcsmacro . sty for your meeting,\n" + "or with entcsinacro.st for your meeting. Both can be\n" + "found at the LN l‘CS l\\= acro Home Page.\n" + "\n" + "An Example Paper\n" + "\n" + "My Name 1'2\n" + "\n" + "My Department\n" + "My Um‘ver.s‘-ity\n" + "My City, My Country\n" + "\n" + "My Co—author 3\n" + "\n" + "My Co-author's Department\n" + "M y C 0- auth or \"5 Umvve rs-2' ty\n" + "My Co—a.uthor'.s‘ City, My Co—aut/z0r's Country\n" + "\n" + "Abstract\n" + "\n" + "This is a short example to show the basics of using the TSNTCS style macro ﬁles.\n" + "Ample examples of how ﬁles should look may be found among the published volumes\n" + "of the series at the ENTCS Home Page http: "\n" + "Key words: Please list keywords from your paper here, separated\n" + "by commas.\n" + "\n" + "1 Introduction\n" + "\n" + "This short note provides a guide to using the ENTCS macro package for\n" + "preparing papers for publication in your conference Proceedings. The Pro-\n" + "ceedings may be printed and hard copies distributed to participants at the\n" + "meeting; this is an option to Conference Organizers may choose to exercise.\n" + "The Proceedings also will be par of a volume in the series Electronic Notes\n" + "272. Theoretical Computer .S'cz'en.ce (ILNTCS), which is published under the aus-\n" + "pices of Elsevier Science B. V., the publishers of ’1'heoretz'cal Computer Science.\n" + "It’s home page is http: "The l£l\\'TCS macro package consists of two ﬁles:\n" + "\n" + "entcs.c1s, the basic style ﬁle, and\n" + "\n" + "</div>\n" + "</body></html><html xmlns=\"http: "<head>\n" + "<meta name=\"Compression\" content=\"Uncompressed\" />\n" + "<meta name=\"tiff:ImageLength\" content=\"3508\" />\n" + "<meta name=\"Samples Per Pixel\" content=\"4 samples/pixel\" />\n" + "<meta name=\"tiff:ImageWidth\" content=\"2480\" />\n" + "<meta name=\"tiff:YResolution\" content=\"300.0\" />\n" + "<meta name=\"Bits Per Sample\" content=\"8 8 8 8 bits/component/pixel\" />\n" + "<meta name=\"Y Resolution\" content=\"300 dots per (no unit)\" />\n" + "<title></title>\n" + "</head>\n" + "<body /></html>"; String firstHtmlWithContent = StringTools.getFirstHtmlWithContent(html); assertThat(firstHtmlWithContent.contains("short note provides"), equalTo(true)); assertThat(firstHtmlWithContent.contains("Y Resolution"), equalTo(false)); }
public static String getFirstHtmlWithContent(String html) { String[] split = html.split("<html"); for (String htmlPart : split) { if (noContentInHtml(htmlPart)) { continue; } return String.format("%s%s", "<html", htmlPart); } return ""; }
StringTools { public static String getFirstHtmlWithContent(String html) { String[] split = html.split("<html"); for (String htmlPart : split) { if (noContentInHtml(htmlPart)) { continue; } return String.format("%s%s", "<html", htmlPart); } return ""; } }
StringTools { public static String getFirstHtmlWithContent(String html) { String[] split = html.split("<html"); for (String htmlPart : split) { if (noContentInHtml(htmlPart)) { continue; } return String.format("%s%s", "<html", htmlPart); } return ""; }  }
StringTools { public static String getFirstHtmlWithContent(String html) { String[] split = html.split("<html"); for (String htmlPart : split) { if (noContentInHtml(htmlPart)) { continue; } return String.format("%s%s", "<html", htmlPart); } return ""; }  static int getLevenshteinDistance(String str1, String str2); static Set<String> getApproximatelyMatchingStringList(String sourceString, String search); boolean isNotTooShort(String string); static Set<String> getApproximatelyMatchingStringList(String sourceString, String search, int maxDistance); static String getCompletingString(String string, int begin, int end); static List<MatchingWindow> getMatchingWindowsAboveThreshold(String text, String search, double threshold); static Set<String> splitIntoWordsWithLengthHigherThan(String string, int minLength); static Set<String> splitIntoWordsWithLengthHigherThan(String string, int minLength, String... ignoreWords); static boolean noContentInHtml(String text); static List<String> getRegexMatchesWithMinLength(String text, String regex, int minLength); static String getRandomForeName(); static String getRandomSurname(); static String getFirstHtmlWithContent(String html); static String getMetaDataFromHTML(String html); static String addMetaDataToHtml(String htmlText, String metaData); }
StringTools { public static String getFirstHtmlWithContent(String html) { String[] split = html.split("<html"); for (String htmlPart : split) { if (noContentInHtml(htmlPart)) { continue; } return String.format("%s%s", "<html", htmlPart); } return ""; }  static int getLevenshteinDistance(String str1, String str2); static Set<String> getApproximatelyMatchingStringList(String sourceString, String search); boolean isNotTooShort(String string); static Set<String> getApproximatelyMatchingStringList(String sourceString, String search, int maxDistance); static String getCompletingString(String string, int begin, int end); static List<MatchingWindow> getMatchingWindowsAboveThreshold(String text, String search, double threshold); static Set<String> splitIntoWordsWithLengthHigherThan(String string, int minLength); static Set<String> splitIntoWordsWithLengthHigherThan(String string, int minLength, String... ignoreWords); static boolean noContentInHtml(String text); static List<String> getRegexMatchesWithMinLength(String text, String regex, int minLength); static String getRandomForeName(); static String getRandomSurname(); static String getFirstHtmlWithContent(String html); static String getMetaDataFromHTML(String html); static String addMetaDataToHtml(String htmlText, String metaData);  }