@Test public void testUnifyTerminators() { logger.info("unifyTerminators"); String text = " This is amazing!!! ! How is this possible?!?!?!?!!!???! "; String expResult = "This is amazing. How is this possible."; String result = StringCleaner.unifyTerminators(text); assertEquals(expResult, result); }
public static String unifyTerminators(String text) { text = text.replaceAll("[\",:;()\\-]+", " "); text = text.replaceAll("[\\.!?]", "."); text = text.replaceAll("\\.[\\. ]+", "."); text = text.replaceAll("\\s*\\.\\s*", ". "); return text.trim(); }
StringCleaner { public static String unifyTerminators(String text) { text = text.replaceAll("[\",:;()\\-]+", " "); text = text.replaceAll("[\\.!?]", "."); text = text.replaceAll("\\.[\\. ]+", "."); text = text.replaceAll("\\s*\\.\\s*", ". "); return text.trim(); } }
StringCleaner { public static String unifyTerminators(String text) { text = text.replaceAll("[\",:;()\\-]+", " "); text = text.replaceAll("[\\.!?]", "."); text = text.replaceAll("\\.[\\. ]+", "."); text = text.replaceAll("\\s*\\.\\s*", ". "); return text.trim(); }  }
StringCleaner { public static String unifyTerminators(String text) { text = text.replaceAll("[\",:;()\\-]+", " "); text = text.replaceAll("[\\.!?]", "."); text = text.replaceAll("\\.[\\. ]+", "."); text = text.replaceAll("\\s*\\.\\s*", ". "); return text.trim(); }  static String tokenizeURLs(String text); static String tokenizeSmileys(String text); static String removeExtraSpaces(String text); static String removeSymbols(String text); static String unifyTerminators(String text); static String removeAccents(String text); static String clear(String text); }
StringCleaner { public static String unifyTerminators(String text) { text = text.replaceAll("[\",:;()\\-]+", " "); text = text.replaceAll("[\\.!?]", "."); text = text.replaceAll("\\.[\\. ]+", "."); text = text.replaceAll("\\s*\\.\\s*", ". "); return text.trim(); }  static String tokenizeURLs(String text); static String tokenizeSmileys(String text); static String removeExtraSpaces(String text); static String removeSymbols(String text); static String unifyTerminators(String text); static String removeAccents(String text); static String clear(String text);  }