From b4c87a09a194a7d966724ce48ba2d8ef0d044ca0 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sat, 20 Apr 2013 00:18:08 +0200 Subject: [PATCH] restrict depth of word set calculation --- lib/lib.php | 18 ++++++++++-------- website/search.php | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/lib.php b/lib/lib.php index 998e0429..96d2c048 100644 --- a/lib/lib.php +++ b/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; diff --git a/website/search.php b/website/search.php index cc8fe02a..387a79de 100755 --- a/website/search.php +++ b/website/search.php @@ -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 -- 2.45.2