Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/SimilarNamedWays.java
r11747 r12283 7 7 8 8 import java.awt.geom.Point2D; 9 import java.text.Normalizer; 9 10 import java.util.ArrayList; 10 11 import java.util.Arrays; … … 34 35 35 36 protected static final int SIMILAR_NAMED = 701; 37 38 private static final Pattern REMOVE_DIACRITICS = Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); 36 39 37 40 /** All ways, grouped by cells */ … … 202 205 boolean similar = distance > 0 && distance <= 2; 203 206 207 // check if only the case differs, so we don't consider large distance as different strings 208 if (distance > 2 && name.length() == name2.length()) { 209 similar = deAccent(name).equalsIgnoreCase(deAccent(name2)); 210 } 211 204 212 // try all rules 205 213 for (NormalizeRule rule : rules) { … … 216 224 } 217 225 226 /** 227 * Removes diacritics (accents) from string. 228 * @param str string 229 * @return {@code str} without any diacritic (accent) 230 * @since 12283 231 */ 232 public static String deAccent(String str) { 233 // https://stackoverflow.com/a/1215117/2257172 234 return REMOVE_DIACRITICS.matcher(Normalizer.normalize(str, Normalizer.Form.NFD)).replaceAll(""); 235 } 236 218 237 @FunctionalInterface 219 238 public interface NormalizeRule { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/SimilarNamedWaysTest.java
r11403 r12283 88 88 } 89 89 90 /** 91 * Test similar names. 92 */ 90 93 @Test 91 94 public void testSimilarNames() { … … 118 121 checkSimilarity("first and second 2 changes", "First Street", "Soconds Street", true); 119 122 checkSimilarity("first and second 3 changes", "First Street", "Soconds Stret", false); 123 124 // case only, see #14858 125 checkSimilarity("case only", "Rua São João", "Rua Sao Joao", true); 126 checkSimilarity("case only", "Rua São João", "Rua SAO JOAO", true); 127 checkSimilarity("case only", "Rua Sao Joao", "Rua SAO JOAO", true); 128 checkSimilarity("case only", "Rue éèçàïù", "Rue EeCAIU", true); 120 129 } 121 130 }
Note:
See TracChangeset
for help on using the changeset viewer.