Class SimilarNamedWays
- java.lang.Object
-
- org.openstreetmap.josm.data.validation.Test
-
- org.openstreetmap.josm.data.validation.tests.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSimilarNamedWays.NormalizeRuleA normalization that is applied to names before testing themstatic classSimilarNamedWays.RegExprRuleA rule to replace by regular expression, so that all strings matching the regular expression are handled as if they wereSimilarNamedWays.RegExprRule.replacementstatic classSimilarNamedWays.SynonymRuleA rule that registers synonyms to a given word-
Nested classes/interfaces inherited from class org.openstreetmap.josm.data.validation.Test
Test.TagTest
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.awt.geom.Point2D,java.util.List<Way>>cellWaysAll ways, grouped by cellsprivate MultiMap<Way,Way>errorWaysThe already detected errorsprivate java.util.List<SimilarNamedWays.NormalizeRule>rulesprotected static intSIMILAR_NAMED-
Fields inherited from class org.openstreetmap.josm.data.validation.Test
checkBeforeUpload, checkEnabled, description, enabled, errors, IN_DOWNLOADED_AREA, IN_DOWNLOADED_AREA_STRICT, isBeforeUpload, name, partialSelection, progressMonitor, stopwatch, testBeforeUpload
-
-
Constructor Summary
Constructors Constructor Description SimilarNamedWays()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRegExprRule(java.lang.String regExpr, java.lang.String replacement)Add a regular expression rule.voidaddSynonyms(java.lang.String... words)Add a rule with synonym words.voidendTest()Notification of the end of the test.booleansimilaryName(java.lang.String name, java.lang.String name2)Check if two names are similar, but not identical.voidstartTest(ProgressMonitor monitor)Start the test using a given progress monitorvoidvisit(Way w)Visiting call for lines.-
Methods inherited from class org.openstreetmap.josm.data.validation.Test
addGui, clear, deletePrimitivesIfNeeded, fixError, getErrors, getName, getSource, initialize, isBuilding, isCanceled, isFixable, isPrimitiveUsable, isResidentialArea, ok, removeIrrelevantErrors, setBeforeUpload, setPartialSelection, setShowElements, testBeforeUpload, visit, visit, visit
-
-
-
-
Field Detail
-
SIMILAR_NAMED
protected static final int SIMILAR_NAMED
- See Also:
- Constant Field Values
-
cellWays
private java.util.Map<java.awt.geom.Point2D,java.util.List<Way>> cellWays
All ways, grouped by cells
-
rules
private final java.util.List<SimilarNamedWays.NormalizeRule> rules
-
-
Constructor Detail
-
SimilarNamedWays
public SimilarNamedWays()
Constructor
-
-
Method Detail
-
startTest
public void startTest(ProgressMonitor monitor)
Description copied from class:TestStart the test using a given progress monitor
-
endTest
public void endTest()
Description copied from class:TestNotification 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 callsuper.endTest()to do this).
-
visit
public void visit(Way w)
Description copied from interface:OsmPrimitiveVisitorVisiting call for lines.- Specified by:
visitin interfaceOsmPrimitiveVisitor- Overrides:
visitin classTest- Parameters:
w- The way to inspect.
-
addRegExprRule
public void addRegExprRule(java.lang.String regExpr, java.lang.String replacement)
Add a regular expression rule.- Parameters:
regExpr- the regular expression to search forreplacement- 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 comparename2- second name to compare- Returns:
- true if the normalized names are different but only a "little bit"
-
-