mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 18:37:58 +00:00
Black/whitelisting for special phrases
Allows to restrict the special phrases imported from the wiki. Blacklist allows to exclude certain class/type combinations. Whitelist allows to define an allowed subset of types for a class. Adjust to your liking in settings/phrase_settings.php before running the specialphrases script.
This commit is contained in:
51
settings/phrase_settings.php
Normal file
51
settings/phrase_settings.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
# These settings control the import of special phrases from the wiki.
|
||||
|
||||
# Languages to download the special phrases for.
|
||||
$aLanguageIn = array(
|
||||
'af',
|
||||
'ar',
|
||||
'br',
|
||||
'ca',
|
||||
'cs',
|
||||
'de',
|
||||
'en',
|
||||
'es',
|
||||
'et',
|
||||
'eu',
|
||||
'fa',
|
||||
'fi',
|
||||
'fr',
|
||||
'gl',
|
||||
'hr',
|
||||
'hu',
|
||||
'ia',
|
||||
'is',
|
||||
'it',
|
||||
'ja',
|
||||
'mk',
|
||||
'nl',
|
||||
'no',
|
||||
'pl',
|
||||
'ps',
|
||||
'pt',
|
||||
'ru',
|
||||
'sk',
|
||||
'sv',
|
||||
'uk',
|
||||
'vi',
|
||||
);
|
||||
|
||||
# class/type combinations to exclude
|
||||
$aTagsBlacklist = array(
|
||||
'boundary' => array('administrative'),
|
||||
'place' => array('house', 'houses'),
|
||||
);
|
||||
# If a class is in the white list then all types will
|
||||
# be ignored except the ones given in the list.
|
||||
# Also use this list to exclude an entire class from
|
||||
# special phrases.
|
||||
$aTagsWhitelist = array(
|
||||
'highway' => array('bus_stop', 'rest_area', 'raceway'),
|
||||
'building' => array(),
|
||||
);
|
||||
@@ -15,39 +15,6 @@
|
||||
);
|
||||
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
|
||||
|
||||
$aLanguageIn = array(
|
||||
'af',
|
||||
'ar',
|
||||
'br',
|
||||
'ca',
|
||||
'cs',
|
||||
'de',
|
||||
'en',
|
||||
'es',
|
||||
'et',
|
||||
'eu',
|
||||
'fa',
|
||||
'fi',
|
||||
'fr',
|
||||
'gl',
|
||||
'hr',
|
||||
'hu',
|
||||
'ia',
|
||||
'is',
|
||||
'it',
|
||||
'ja',
|
||||
'mk',
|
||||
'nl',
|
||||
'no',
|
||||
'pl',
|
||||
'ps',
|
||||
'pt',
|
||||
'ru',
|
||||
'sk',
|
||||
'sv',
|
||||
'uk',
|
||||
'vi',
|
||||
);
|
||||
|
||||
if ($aCMDResult['countries']) {
|
||||
echo "select getorcreate_country(make_standard_name('uk'), 'gb');\n";
|
||||
@@ -63,6 +30,7 @@
|
||||
|
||||
if ($aCMDResult['wiki-import'])
|
||||
{
|
||||
include(CONST_BasePath.'/settings/phrase_settings.php');
|
||||
$aPairs = array();
|
||||
|
||||
foreach($aLanguageIn as $sLanguage)
|
||||
@@ -84,7 +52,17 @@
|
||||
preg_match('/^\\w+$/', $sType) < 1) {
|
||||
trigger_error("Bad class/type for language $sLanguage: $sClass=$sType");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
# blacklisting: disallow certain class/type combinations
|
||||
if (isset($aTagsBlacklist[$sClass]) && in_array($sType, $aTagsBlacklist[$sClass])) {
|
||||
# fwrite(STDERR, "Blacklisted: ".$sClass."/".$sType."\n");
|
||||
continue;
|
||||
}
|
||||
# whitelisting: if class is in whitelist, allow only tags in the list
|
||||
if (isset($aTagsWhitelist[$sClass]) && !in_array($sType, $aTagsWhitelist[$sClass])) {
|
||||
# fwrite(STDERR, "Non-Whitelisted: ".$sClass."/".$sType."\n");
|
||||
continue;
|
||||
}
|
||||
$aPairs[$sClass.'|'.$sType] = array($sClass, $sType);
|
||||
|
||||
switch(trim($aMatch[4]))
|
||||
|
||||
Reference in New Issue
Block a user