Changeset 14897 in josm
- Timestamp:
- 2019-03-18T09:10:55+01:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/validator/ignoretags.cfg
r14881 r14897 2 2 ; This is used for checks "key/tag not in presets" 3 3 ; K: the given tag will not produce a "tag not in presets" error, but it is 4 ; used as dictionary entry for spell checking the given key. 5 ; E: ignore tags with this key 6 ; S: ignore tag if key starts with this string 7 ; F: ignore tag if key ends with this string 4 ; used as dictionary entry for spell checking the given key and also 5 ; for the key/value combination. 6 ; E: ignore tags with this key and add the key to the spell check dictionary. 7 ; S: ignore tag if key starts with this string. 8 ; F: ignore tag if key ends with this string. 8 9 ; 9 10 ; -
trunk/data/validator/words.cfg
r14490 r14897 8 8 # There must not be any white space before or after words, unless they are to be included in 9 9 # the bad spelling. 10 # There is no need to add bad spelling with different upper/lower case. 10 # There is no need to add bad spelling with different upper/lower case for keys 11 # which appear in the presets or the ignoreTags.cfg (prefixes E: and K:) 11 12 # There is no need to add bad spelling with leading or trailing blanks. 12 13 … … 40 41 -maenity 41 42 -emenity 43 +barrier 44 -barier 42 45 +bicycle 43 46 -bycycle … … 50 53 +commercial 51 54 -comercial 52 +created_by53 -cretaed_by54 -crated_by55 -creared_by56 -creayed_by57 -{created_by58 -creeated_by59 -created_bu60 55 +denomination 61 56 -denonimation … … 161 156 -oeway 162 157 -eway 163 +osmarender:nameDirection164 -name_direction165 -osmarender:name_direction166 158 +railway 167 159 -raillway … … 178 170 -waterwy 179 171 -wateway 180 +unknown181 -unknwon182 172 # 183 173 # Not sorted. … … 208 198 -bulding 209 199 -buildinq 210 +city211 -citya212 200 +complete 213 201 -complite … … 221 209 -desription 222 210 -decription 223 +feature224 -featuer225 211 +freight 226 212 -frieght 227 213 +full_name:fa 228 214 -full_name:Fa 229 +highway_border230 -highway_boarder231 -highway_boreder232 215 +int_name 233 216 -iint_name … … 290 273 +old_name 291 274 -oldname 292 +osmarender:renderName293 -osmarender:rendername294 -soamrender:renderName295 +osmarender:renderRef296 -osmrender:renderRef297 275 +postal_code 298 276 -posatl_code … … 324 302 -tracltype 325 303 -trackype 326 +tramline327 -tram_line328 304 +tunnel 329 305 -tunne -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r14869 r14897 297 297 case "E:": 298 298 ignoreDataEquals.add(line); 299 addToKeyDictionary(line); 299 300 break; 300 301 case "F:": … … 305 306 ignoreDataTag.add(tag); 306 307 oftenUsedTags.put(tag.getKey(), tag.getValue()); 308 addToKeyDictionary(tag.getKey()); 307 309 break; 308 310 default: … … 314 316 Logging.error("Invalid line in {0} : {1}", source, e.getMessage()); 315 317 Logging.trace(e); 318 } 319 } 320 321 private static void addToKeyDictionary(String key) { 322 if (key != null) { 323 String hk = harmonizeKey(key); 324 if (!key.equals(hk)) { 325 harmonizedKeys.put(hk, key); 326 } 316 327 } 317 328 } … … 356 367 private static void addPresetValue(KeyedItem ky) { 357 368 if (ky.key != null && ky.getValues() != null) { 358 String hk = harmonizeKey(ky.key); 359 if (!ky.key.equals(hk)) { 360 harmonizedKeys.put(hk, ky.key); 361 } 369 addToKeyDictionary(ky.key); 362 370 } 363 371 } … … 602 610 private void spellCheckKey(MultiMap<OsmPrimitive, String> withErrors, OsmPrimitive p, String key) { 603 611 String prettifiedKey = harmonizeKey(key); 604 String fixedKey = isKeyInPresets(prettifiedKey) ? prettifiedKey : harmonizedKeys.get(prettifiedKey); 612 String fixedKey; 613 if (ignoreDataEquals.contains(prettifiedKey)) { 614 fixedKey = prettifiedKey; 615 } else { 616 fixedKey = isKeyInPresets(prettifiedKey) ? prettifiedKey : harmonizedKeys.get(prettifiedKey); 617 } 618 if (fixedKey == null) { 619 for (Tag a : ignoreDataTag) { 620 if (a.getKey().equals(prettifiedKey)) { 621 fixedKey = prettifiedKey; 622 break; 623 } 624 } 625 } 626 605 627 if (fixedKey != null && !"".equals(fixedKey) && !fixedKey.equals(key)) { 628 final String proposedKey = fixedKey; 606 629 // misspelled preset key 607 630 final TestError.Builder error = TestError.builder(this, Severity.WARNING, MISSPELLED_KEY) 608 .message(tr("Misspelled property key"), marktr("Key ''{0}'' looks like ''{1}''."), key, fixedKey)631 .message(tr("Misspelled property key"), marktr("Key ''{0}'' looks like ''{1}''."), key, proposedKey) 609 632 .primitives(p); 610 633 if (p.hasKey(fixedKey)) { 611 634 errors.add(error.build()); 612 635 } else { 613 errors.add(error.fix(() -> new ChangePropertyKeyCommand(p, key, fixedKey)).build());636 errors.add(error.fix(() -> new ChangePropertyKeyCommand(p, key, proposedKey)).build()); 614 637 } 615 638 withErrors.put(p, "WPK"); -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java
r14732 r14897 84 84 85 85 /** 86 * Check for misspelled key where the suggested alternative is given with prefix E: in ignoreTags.cfg. 87 * The error should be fixable. 88 * @throws IOException if any I/O error occurs 89 */ 90 @Test 91 public void testUpperCaseIgnoredKey() throws IOException { 92 // ticket 17468 93 final List<TestError> errors = test(OsmUtils.createPrimitive("node wheelchair:Description=bla")); 94 assertEquals(1, errors.size()); 95 assertEquals("Misspelled property key", errors.get(0).getMessage()); 96 assertEquals("Key 'wheelchair:Description' looks like 'wheelchair:description'.", errors.get(0).getDescription()); 97 assertEquals(Severity.WARNING, errors.get(0).getSeverity()); 98 assertTrue(errors.get(0).isFixable()); 99 } 100 101 /** 102 * Check for misspelled key where the suggested alternative is given with prefix K: in ignoreTags.cfg. 103 * The error should be fixable. 104 * @throws IOException if any I/O error occurs 105 */ 106 @Test 107 public void testUpperCaseInKeyIgnoredTag() throws IOException { 108 // ticket 17468 109 final List<TestError> errors = test(OsmUtils.createPrimitive("node land_Area=administrative")); 110 assertEquals(1, errors.size()); 111 assertEquals("Misspelled property key", errors.get(0).getMessage()); 112 assertEquals("Key 'land_Area' looks like 'land_area'.", errors.get(0).getDescription()); 113 assertEquals(Severity.WARNING, errors.get(0).getSeverity()); 114 assertTrue(errors.get(0).isFixable()); 115 } 116 117 /** 86 118 * Check for unknown key. 87 119 * @throws IOException if any I/O error occurs
Note:
See TracChangeset
for help on using the changeset viewer.