Class SimilarNamedWays
java.lang.Object
org.openstreetmap.josm.data.validation.Test
org.openstreetmap.josm.data.validation.tests.SimilarNamedWays
- All Implemented Interfaces:
OsmPrimitiveVisitor
Checks for similar named ways, symptom of a possible typo. It uses the
Levenshtein distance to check for similarity
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA normalization that is applied to names before testing themstatic classA rule to replace by regular expression, so that all strings matching the regular expression are handled as if they wereSimilarNamedWays.RegExprRule.replacementstatic classA rule that registers synonyms to a given wordNested classes/interfaces inherited from class org.openstreetmap.josm.data.validation.Test
Test.TagTest -
Field Summary
FieldsModifier and TypeFieldDescriptionAll ways, grouped by cellsThe already detected errorsprivate final List<SimilarNamedWays.NormalizeRule>protected static final intFields 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRegExprRule(String regExpr, String replacement) Add a regular expression rule.voidaddSynonyms(String... words) Add a rule with synonym words.voidendTest()Notification of the end of the test.booleansimilaryName(String name, String name2) Check if two names are similar, but not identical.voidstartTest(ProgressMonitor monitor) Start the test using a given progress monitorvoidVisiting 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 Details
-
SIMILAR_NAMED
- See Also:
-
cellWays
All ways, grouped by cells -
errorWays
The already detected errors -
rules
-
-
Constructor Details
-
SimilarNamedWays
public SimilarNamedWays()Constructor
-
-
Method Details
-
startTest
Description copied from class:TestStart the test using a given progress monitor -
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
Description copied from interface:OsmPrimitiveVisitorVisiting call for lines.- Specified by:
visitin interfaceOsmPrimitiveVisitor- Overrides:
visitin classTest- Parameters:
w- The way to inspect.
-
addRegExprRule
Add a regular expression rule.- Parameters:
regExpr- the regular expression to search forreplacement- a string to replace with, which should match the expression.
-
addSynonyms
Add a rule with synonym words.- Parameters:
words- words which are synonyms
-
similaryName
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"
-