mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 18:37:58 +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)));
|
||||
$sFirstToken = '';
|
||||
while(sizeof($aWords) > 1)
|
||||
{
|
||||
$sWord = array_shift($aWords);
|
||||
$sFirstToken .= ($sFirstToken?' ':'').$sWord;
|
||||
$aRest = getWordSets($aWords);
|
||||
foreach($aRest as $aSet)
|
||||
if ($iDepth < 8) {
|
||||
while(sizeof($aWords) > 1)
|
||||
{
|
||||
$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;
|
||||
|
||||
@@ -390,7 +390,7 @@
|
||||
{
|
||||
$aPhrases[$iPhrase] = $aPhrase;
|
||||
$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']));
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user