]> git.openstreetmap.org Git - nominatim.git/commitdiff
sanity check of house number format
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 1 May 2014 07:18:10 +0000 (09:18 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 1 May 2014 07:18:10 +0000 (09:18 +0200)
Add a penalty for house number search terms when they contain
too many non-numeric characters in an attempt to filter tokens
that ended up as house numbers in the word table as a result
of mapping errors.

lib/Geocode.php

index 92e1a0b327d2b295bc6210427bc28af3eaa12d0e..847439c76e5d3712ed3d4068b78ca2d3c319c20d 100644 (file)
                                                                                                if ($aSearch['sHouseNumber'] === '')
                                                                                                {
                                                                                                        $aSearch['sHouseNumber'] = $sToken;
+                                                    // sanity check: if the housenumber is not mainly made
+                                                    // up of numbers, add a penalty
+                                                    if (preg_match_all("/[^0-9]/", $sToken, $aMatches) > 2) $aSearch['iSearchRank']++;
                                                                                                        if ($aSearch['iSearchRank'] < $this->iMaxRank) $aNewWordsetSearches[] = $aSearch;
                                                                                                        /*
                                                                                                        // Fall back to not searching for this item (better than nothing)