mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 02:58:13 +00:00
restrict depth of word set calculation
This commit is contained in:
18
lib/lib.php
18
lib/lib.php
@@ -165,18 +165,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getWordSets($aWords)
|
function getWordSets($aWords, $iDepth)
|
||||||
{
|
{
|
||||||
$aResult = array(array(join(' ',$aWords)));
|
$aResult = array(array(join(' ',$aWords)));
|
||||||
$sFirstToken = '';
|
$sFirstToken = '';
|
||||||
while(sizeof($aWords) > 1)
|
if ($iDepth < 8) {
|
||||||
{
|
while(sizeof($aWords) > 1)
|
||||||
$sWord = array_shift($aWords);
|
|
||||||
$sFirstToken .= ($sFirstToken?' ':'').$sWord;
|
|
||||||
$aRest = getWordSets($aWords);
|
|
||||||
foreach($aRest as $aSet)
|
|
||||||
{
|
{
|
||||||
$aResult[] = array_merge(array($sFirstToken),$aSet);
|
$sWord = array_shift($aWords);
|
||||||
|
$sFirstToken .= ($sFirstToken?' ':'').$sWord;
|
||||||
|
$aRest = getWordSets($aWords, $iDepth+1);
|
||||||
|
foreach($aRest as $aSet)
|
||||||
|
{
|
||||||
|
$aResult[] = array_merge(array($sFirstToken),$aSet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $aResult;
|
return $aResult;
|
||||||
|
|||||||
@@ -390,7 +390,7 @@
|
|||||||
{
|
{
|
||||||
$aPhrases[$iPhrase] = $aPhrase;
|
$aPhrases[$iPhrase] = $aPhrase;
|
||||||
$aPhrases[$iPhrase]['words'] = explode(' ',$aPhrases[$iPhrase]['string']);
|
$aPhrases[$iPhrase]['words'] = explode(' ',$aPhrases[$iPhrase]['string']);
|
||||||
$aPhrases[$iPhrase]['wordsets'] = getWordSets($aPhrases[$iPhrase]['words']);
|
$aPhrases[$iPhrase]['wordsets'] = getWordSets($aPhrases[$iPhrase]['words'], 0);
|
||||||
$aTokens = array_merge($aTokens, getTokensFromSets($aPhrases[$iPhrase]['wordsets']));
|
$aTokens = array_merge($aTokens, getTokensFromSets($aPhrases[$iPhrase]['wordsets']));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user