Class SimilarNamedWays

  • All Implemented Interfaces:
    OsmPrimitiveVisitor

    public class SimilarNamedWays
    extends Test
    Checks for similar named ways, symptom of a possible typo. It uses the Levenshtein distance to check for similarity
    • Method Detail

      • startTest

        public void startTest​(ProgressMonitor monitor)
        Description copied from class: Test
        Start the test using a given progress monitor
        Overrides:
        startTest in class Test
        Parameters:
        monitor - the progress monitor
      • endTest

        public void endTest()
        Description copied from class: Test
        Notification of the end of the test. The tester may perform additional actions and destroy the used structures.

        If you override this method, don't forget to cleanup progressMonitor (most overrides call super.endTest() to do this).

        Overrides:
        endTest in class Test
      • addRegExprRule

        public void addRegExprRule​(java.lang.String regExpr,
                                   java.lang.String replacement)
        Add a regular expression rule.
        Parameters:
        regExpr - the regular expression to search for
        replacement - a string to replace with, which should match the expression.
      • addSynonyms

        public void addSynonyms​(java.lang.String... words)
        Add a rule with synonym words.
        Parameters:
        words - words which are synonyms
      • similaryName

        public boolean similaryName​(java.lang.String name,
                                    java.lang.String name2)
        Check if two names are similar, but not identical. First both names will be "normalized". Afterwards the Levenshtein distance will be calculated.
        Examples for normalization rules:
        replaceAll("\\d+", "0")
        would cause similaryName("track 1", "track 2") = false, but similaryName("Track 1", "track 2") = true
        Parameters:
        name - first name to compare
        name2 - second name to compare
        Returns:
        true if the normalized names are different but only a "little bit"