Ignore:
Timestamp:
2018-05-26T00:47:08+02:00 (19 months ago)
Author:
Don-vip
Message:

fix #13889 - Make preset searchs ignore accents

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/SimilarNamedWays.java

    r13390 r13836  
    77
    88import java.awt.geom.Point2D;
    9 import java.text.Normalizer;
    109import java.util.ArrayList;
    1110import java.util.Arrays;
     
    2524import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    2625import org.openstreetmap.josm.tools.MultiMap;
     26import org.openstreetmap.josm.tools.Utils;
    2727
    2828/**
     
    3535
    3636    protected static final int SIMILAR_NAMED = 701;
    37 
    38     private static final Pattern REMOVE_DIACRITICS = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
    3937
    4038    /** All ways, grouped by cells */
     
    207205        // check if only the case differs, so we don't consider large distance as different strings
    208206        if (distance > 2 && name.length() == name2.length()) {
    209             similar = deAccent(name).equalsIgnoreCase(deAccent(name2));
     207            similar = Utils.deAccent(name).equalsIgnoreCase(Utils.deAccent(name2));
    210208        }
    211209
     
    225223
    226224    /**
    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 
    237     /**
    238225     * A normalization that is applied to names before testing them
    239226     */
Note: See TracChangeset for help on using the changeset viewer.