Opened 10 years ago
Closed 10 years ago
#11498 closed enhancement (fixed)
[Patch] Warn about obvious misspelled tag values
Reported by: | mdk | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 15.05 |
Component: | Core validator | Version: | latest |
Keywords: | Cc: |
Description
As I outlined in #11433 there would be a nice validator enhancement to detect common typos in tag values compared with the values from the presets:
- using of upper case characters
- using of ' ' or '-' instead of '_'
- trailing or leading special chars like ' ', ';', '_'
This extension is very restrictive. Only in case of a validation result "Preset do not contain property value" there would be an additional check for a similar value in the preset. Only if the original value was not found in preset, but the "prettified" value exists, a warning "Misspelled property value" will be shown instead (with fix).
Attachments (2)
Change History (13)
by , 10 years ago
Attachment: | patch.diff added |
---|
comment:1 by , 10 years ago
Component: | Core → Core validator |
---|
comment:2 by , 10 years ago
Milestone: | → 15.05 |
---|
follow-up: 5 comment:3 by , 10 years ago
comment:5 by , 10 years ago
Replying to mdk:
Nice that you will fit the patch into the may release.
Thanks for this nice patch :)
I saw a little flaw in my patch: in prettifyValue() i do the character replacement twice.
Thanks, I have fixed it in the commit.
In the first try I used commens.lang.StringUtils, but I saw that this package is not used in JOSM, so I extend Utils.strip(). I hope this is the correct way.
Yes, perfect.
Is it correct, that I need to implement the check twice if I want to provide a fix? First in
check()
, where I add a message toerrors
. This would be also a nice place to create the fixCommand
. But instead I had to ensure thatisFixable()
returns true on thisTestError
andfixError()
must return the the fixCommand
. For this I have to implement the check a second time to find out when to create the fix command (there are several reasons for isFixable()=true) and especially the details for the fix command.
Correct but not optimal, see below.
Wouldn't it be better to create the fix command in
check()
and add it to theTestError
?isFixable(TestError)
just have to look ifTestError
contains a fix command. And getting the correct fix command would also be extreamly simple!
Definitively :) That's why the FixableTestError
is here, I have used it in the commit.
comment:6 by , 10 years ago
Thank you very much.
Knowing the object model would derfinitly save time :)
With the FixableTestError
I think I will extend the test - for the first try the missing test was too complex.
So I'll be back ;-)
comment:7 by , 10 years ago
Also outlined in #11433:
Additionally we could also have a test where we remove the '_' from the preset value. If we find a match in this case like "steakhouse" would match "steak_house" without '_', we can warn and offer a fix to replace cuisine=steakhouse with cuisine=steak_house.
I have implemented this extension too.
comment:8 by , 10 years ago
And the next step could be external configured pais with value typos to be added to the HashMap.
To increase performance these HashMaps could be cached insted of created for each check.
And we could do similar checks for keys.
comment:9 by , 10 years ago
Please correct file core/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
line 425 ({2}}):
String i = marktr("Value ''{0}'' for key ''{1}'' looks like ''{2}}.");
comment:10 by , 10 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Nice that you will fit the patch into the may release.
I saw a little flaw in my patch: in prettifyValue() i do the character replacement twice.
In the first try I used commens.lang.StringUtils, but I saw that this package is not used in JOSM, so I extend Utils.strip(). I hope this is the correct way.
Is it correct, that I need to implement the check twice if I want to provide a fix? First in
check()
, where I add a message toerrors
. This would be also a nice place to create the fixCommand
. But instead I had to ensure thatisFixable()
returns true on thisTestError
andfixError()
must return the the fixCommand
. For this I have to implement the check a second time to find out when to create the fix command (there are several reasons for isFixable()=true) and especially the details for the fix command.Wouldn't it be better to create the fix command in
check()
and add it to theTestError
?isFixable(TestError)
just have to look ifTestError
contains a fix command. And getting the correct fix command would also be extreamly simple!