@Test public void testNormalize() throws Exception { assertNull(comp.normalize(null)); assertNull(comp.normalize(" ")); assertNull(comp.normalize(".")); assertNull(comp.normalize(" (-) ")); assertEquals("doring", comp.normalize("Döring")); assertEquals("desireno", comp.normalize("Désírèñø")); assertEquals("p m e l de la chapelle", comp.normalize("p m é l de la chapelle")); assertEquals("a j white", comp.normalize("A.J. White")); assertEquals("j a white", comp.normalize("J A WHITE")); assertEquals("a j white", comp.normalize("A-J-White")); assertEquals("a j white", comp.normalize("(A.J. White)")); assertEquals("a j white,herbert,p j harvey", comp.normalize("A. J. White, Herbert & P. J. Harvey")); assertEquals("a j white,herbert,p j harvey", comp.normalize("A.J. White, Herbert et P.J. Harvey")); assertEquals("a j white,herbert,p j harvey", comp.normalize("A.J. White, Herbert and P.J. Harvey")); assertEquals("colla", comp.normalize("Bertero ex Colla")); assertEquals("schult", comp.normalize("Sieber ex Schult.")); assertEquals("nevski", comp.normalize("Desv. ex Nevski")); assertEquals("w q yin", comp.normalize("K. M. Feng ex W. Q. Yin")); assertEquals("g kirchn", comp.normalize("G.Kirchn. in Petzold & G.Kirchn.")); assertEquals("torr,a gray", comp.normalize("Torr. & A.Gray")); assertEquals("c chr", comp.normalize("C. Chr.")); assertEquals("h christ", comp.normalize("H. Christ")); assertEquals("l", comp.normalize("L.")); assertEquals("rchb", comp.normalize("Rchb.")); assertEquals("rchb", comp.normalize("Abasicarpon Andrz. ex Rchb.")); assertEquals("muller", comp.normalize("Müller")); assertEquals("muller", comp.normalize("Mueller")); assertEquals("moller", comp.normalize("Moeller")); assertEquals("l filius", comp.normalize("L. f.")); assertEquals("l filius", comp.normalize("L.fil.")); assertEquals("don filius", comp.normalize("Don f.")); assertEquals("don filius", comp.normalize("Don fil.")); assertEquals("don filius", comp.normalize("Don fil")); assertEquals("f merck", comp.normalize("f. Merck")); assertEquals("f merck", comp.normalize("f Merck")); assertEquals("la don filius,dc", comp.normalize("la Don f. et DC")); assertEquals("la don,f rich,dc", comp.normalize("la Don, f. Rich. et DC")); assertEquals("la don,rich filius,dc", comp.normalize("la Don, Rich. f. et DC")); assertEquals("l filius", comp.normalize("L.f.")); assertEquals("l filius", comp.normalize("L. f.")); assertEquals("l filius", comp.normalize("L f")); assertEquals("lf", comp.normalize("Lf")); }
@VisibleForTesting protected static String normalize(String x) { if (StringUtils.isBlank(x)) { return null; } x = IN.matcher(x).replaceFirst(""); x = SANCT.matcher(x).replaceFirst(""); x = EX.matcher(x).replaceFirst(""); x = FIL.matcher(x).replaceAll("$1 filius"); x = AND.matcher(x).replaceAll(", "); x = TRANSLITERATIONS.matcher(x).replaceAll("$1"); x = org.gbif.utils.text.StringUtils.foldToAscii(x); x = PUNCTUATION.matcher(x).replaceAll(" "); x = COMMA.matcher(x).replaceAll(","); x = StringUtils.normalizeSpace(x); if (StringUtils.isBlank(x)) { return null; } return x.toLowerCase(); }
AuthorComparator { @VisibleForTesting protected static String normalize(String x) { if (StringUtils.isBlank(x)) { return null; } x = IN.matcher(x).replaceFirst(""); x = SANCT.matcher(x).replaceFirst(""); x = EX.matcher(x).replaceFirst(""); x = FIL.matcher(x).replaceAll("$1 filius"); x = AND.matcher(x).replaceAll(", "); x = TRANSLITERATIONS.matcher(x).replaceAll("$1"); x = org.gbif.utils.text.StringUtils.foldToAscii(x); x = PUNCTUATION.matcher(x).replaceAll(" "); x = COMMA.matcher(x).replaceAll(","); x = StringUtils.normalizeSpace(x); if (StringUtils.isBlank(x)) { return null; } return x.toLowerCase(); } }
AuthorComparator { @VisibleForTesting protected static String normalize(String x) { if (StringUtils.isBlank(x)) { return null; } x = IN.matcher(x).replaceFirst(""); x = SANCT.matcher(x).replaceFirst(""); x = EX.matcher(x).replaceFirst(""); x = FIL.matcher(x).replaceAll("$1 filius"); x = AND.matcher(x).replaceAll(", "); x = TRANSLITERATIONS.matcher(x).replaceAll("$1"); x = org.gbif.utils.text.StringUtils.foldToAscii(x); x = PUNCTUATION.matcher(x).replaceAll(" "); x = COMMA.matcher(x).replaceAll(","); x = StringUtils.normalizeSpace(x); if (StringUtils.isBlank(x)) { return null; } return x.toLowerCase(); } private  AuthorComparator(Map<String, String> authors); }
AuthorComparator { @VisibleForTesting protected static String normalize(String x) { if (StringUtils.isBlank(x)) { return null; } x = IN.matcher(x).replaceFirst(""); x = SANCT.matcher(x).replaceFirst(""); x = EX.matcher(x).replaceFirst(""); x = FIL.matcher(x).replaceAll("$1 filius"); x = AND.matcher(x).replaceAll(", "); x = TRANSLITERATIONS.matcher(x).replaceAll("$1"); x = org.gbif.utils.text.StringUtils.foldToAscii(x); x = PUNCTUATION.matcher(x).replaceAll(" "); x = COMMA.matcher(x).replaceAll(","); x = StringUtils.normalizeSpace(x); if (StringUtils.isBlank(x)) { return null; } return x.toLowerCase(); } private  AuthorComparator(Map<String, String> authors); static AuthorComparator createWithoutAuthormap(); static AuthorComparator createWithAuthormap(); static AuthorComparator createWithAuthormap(Map<String, String> authorMap); Equality compare(@Nullable String authors1, @Nullable String year1, @Nullable String authors2, @Nullable String year2); Equality compare(ParsedName n1, ParsedName n2); boolean compareStrict(String author1, @Nullable String year1, String author2, @Nullable String year2); }
AuthorComparator { @VisibleForTesting protected static String normalize(String x) { if (StringUtils.isBlank(x)) { return null; } x = IN.matcher(x).replaceFirst(""); x = SANCT.matcher(x).replaceFirst(""); x = EX.matcher(x).replaceFirst(""); x = FIL.matcher(x).replaceAll("$1 filius"); x = AND.matcher(x).replaceAll(", "); x = TRANSLITERATIONS.matcher(x).replaceAll("$1"); x = org.gbif.utils.text.StringUtils.foldToAscii(x); x = PUNCTUATION.matcher(x).replaceAll(" "); x = COMMA.matcher(x).replaceAll(","); x = StringUtils.normalizeSpace(x); if (StringUtils.isBlank(x)) { return null; } return x.toLowerCase(); } private  AuthorComparator(Map<String, String> authors); static AuthorComparator createWithoutAuthormap(); static AuthorComparator createWithAuthormap(); static AuthorComparator createWithAuthormap(Map<String, String> authorMap); Equality compare(@Nullable String authors1, @Nullable String year1, @Nullable String authors2, @Nullable String year2); Equality compare(ParsedName n1, ParsedName n2); boolean compareStrict(String author1, @Nullable String year1, String author2, @Nullable String year2);  }