]> git.openstreetmap.org Git - nominatim.git/commitdiff
restrict depth of word set calculation
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 19 Apr 2013 22:18:08 +0000 (00:18 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 19 Apr 2013 22:18:08 +0000 (00:18 +0200)
lib/lib.php
website/search.php

index 998e0429740107343ad939e625bdf44fe3701bfe..96d2c048fcae7d2b91ca2224a9b55805dcd335e8 100644 (file)
        }
 
 
        }
 
 
-       function getWordSets($aWords)
+       function getWordSets($aWords, $iDepth)
        {
                $aResult = array(array(join(' ',$aWords)));
                $sFirstToken = '';
        {
                $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;
                        }
                }
                return $aResult;
index cc8fe02ae3c3c853d98bca2df11f67c130716673..387a79de87b3bc5522c4b0ac516b9d4d97d1529a 100755 (executable)
                                {
                                        $aPhrases[$iPhrase] = $aPhrase;
                                        $aPhrases[$iPhrase]['words'] = explode(' ',$aPhrases[$iPhrase]['string']);
                                {
                                        $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
                                        $aTokens = array_merge($aTokens, getTokensFromSets($aPhrases[$iPhrase]['wordsets']));
                                }
                                else