take frequency scores from token description

No need to hand them in separately.
This commit is contained in:
Sarah Hoffmann
2017-10-12 22:59:07 +02:00
parent 023f94b066
commit 77abe882ab
2 changed files with 6 additions and 9 deletions

View File

@@ -669,7 +669,7 @@ class Geocode
return $aSearchResults; return $aSearchResults;
} }
public function getGroupedSearches($aSearches, $aPhrases, $aValidTokens, $aWordFrequencyScores, $bIsStructured, $sNormQuery) public function getGroupedSearches($aSearches, $aPhrases, $aValidTokens, $bIsStructured, $sNormQuery)
{ {
/* /*
Calculate all searches using aValidTokens i.e. Calculate all searches using aValidTokens i.e.
@@ -745,7 +745,6 @@ class Geocode
$aSearchTerm, $aSearchTerm,
$bIsStructured, $bIsStructured,
$iPhrase, $iPhrase,
$aWordFrequencyScores,
isset($aValidTokens[' '.$sToken]) ? $aValidTokens[' '.$sToken] : array() isset($aValidTokens[' '.$sToken]) ? $aValidTokens[' '.$sToken] : array()
); );
@@ -1037,7 +1036,7 @@ class Geocode
// Any words that have failed completely? // Any words that have failed completely?
// TODO: suggestions // TODO: suggestions
$aGroupedSearches = $this->getGroupedSearches($aSearches, $aPhrases, $aValidTokens, $aWordFrequencyScores, $bStructuredPhrases, $sNormQuery); $aGroupedSearches = $this->getGroupedSearches($aSearches, $aPhrases, $aValidTokens, $bStructuredPhrases, $sNormQuery);
if ($this->bReverseInPlan) { if ($this->bReverseInPlan) {
// Reverse phrase array and also reverse the order of the wordsets in // Reverse phrase array and also reverse the order of the wordsets in
@@ -1048,7 +1047,7 @@ class Geocode
if (sizeof($aPhrases) > 1) { if (sizeof($aPhrases) > 1) {
$aPhrases[sizeof($aPhrases)-1]->invertWordSets(); $aPhrases[sizeof($aPhrases)-1]->invertWordSets();
} }
$aReverseGroupedSearches = $this->getGroupedSearches($aSearches, $aPhrases, $aValidTokens, $aWordFrequencyScores, false, $sNormQuery); $aReverseGroupedSearches = $this->getGroupedSearches($aSearches, $aPhrases, $aValidTokens, false, $sNormQuery);
foreach ($aGroupedSearches as $aSearches) { foreach ($aGroupedSearches as $aSearches) {
foreach ($aSearches as $aSearch) { foreach ($aSearches as $aSearch) {

View File

@@ -333,14 +333,12 @@ class SearchDescription
* @param mixed[] $aSearchTerm Description of the token. * @param mixed[] $aSearchTerm Description of the token.
* @param bool $bStructuredPhrases True if the search is structured. * @param bool $bStructuredPhrases True if the search is structured.
* @param integer $iPhrase Number of the phrase the token is in. * @param integer $iPhrase Number of the phrase the token is in.
* @param mixed[] $aWordFrequencyScores Number of times tokens appears
* overall in a planet database.
* @param array[] $aFullTokens List of full term tokens with the * @param array[] $aFullTokens List of full term tokens with the
* same name. * same name.
* *
* @return SearchDescription[] List of derived search descriptions. * @return SearchDescription[] List of derived search descriptions.
*/ */
public function extendWithPartialTerm($aSearchTerm, $bStructuredPhrases, $iPhrase, &$aWordFrequencyScores, $aFullTokens) public function extendWithPartialTerm($aSearchTerm, $bStructuredPhrases, $iPhrase, $aFullTokens)
{ {
// Only allow name terms. // Only allow name terms.
if (!(isset($aSearchTerm['word_id']) && $aSearchTerm['word_id'])) { if (!(isset($aSearchTerm['word_id']) && $aSearchTerm['word_id'])) {
@@ -354,7 +352,7 @@ class SearchDescription
&& sizeof($this->aName) && sizeof($this->aName)
&& strpos($aSearchTerm['word_token'], ' ') === false && strpos($aSearchTerm['word_token'], ' ') === false
) { ) {
if ($aWordFrequencyScores[$iWordID] < CONST_Max_Word_Frequency) { if ($aSearchTerm['search_name_count'] + 1 < CONST_Max_Word_Frequency) {
$oSearch = clone $this; $oSearch = clone $this;
$oSearch->iSearchRank++; $oSearch->iSearchRank++;
$oSearch->aAddress[$iWordID] = $iWordID; $oSearch->aAddress[$iWordID] = $iWordID;
@@ -397,7 +395,7 @@ class SearchDescription
if (preg_match('#^[0-9]+$#', $aSearchTerm['word_token'])) { if (preg_match('#^[0-9]+$#', $aSearchTerm['word_token'])) {
$oSearch->iSearchRank += 2; $oSearch->iSearchRank += 2;
} }
if ($aWordFrequencyScores[$iWordID] < CONST_Max_Word_Frequency) { if ($aSearchTerm['search_name_count'] + 1 < CONST_Max_Word_Frequency) {
$oSearch->aName[$iWordID] = $iWordID; $oSearch->aName[$iWordID] = $iWordID;
} else { } else {
$oSearch->aNameNonSearch[$iWordID] = $iWordID; $oSearch->aNameNonSearch[$iWordID] = $iWordID;