Skip to content

Commit

Permalink
add specialized normQuery function for the case: phrase in completion…
Browse files Browse the repository at this point in the history
…. related to #82
  • Loading branch information
chrisreu committed Jun 25, 2014
1 parent 311ac20 commit b7d3510
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion hunt-searchengine/src/Hunt/Query/Processor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ evalScoredWords (QBoost w q)
= boost w <$> evalScoredWords' q

evalScoredWords q@QPhrase{} -- QPhrase is transformed into QFullWord or QSeq Phrase
= normQuery q >>= evalScoredWords
= normPhraseQuery q >>= evalScoredWords

evalScoredWords q@QBinary{} -- QBin is transformed into QSeq
= normQuery q >>= evalScoredWords
Expand Down Expand Up @@ -465,6 +465,20 @@ normQuery q@(QBinary op _q1 _q2)
normQuery q
= return q


normPhraseQuery :: Query -> Processor Query
normPhraseQuery (QPhrase op w)
= return . QSeq Phrase $ normPhrase (T.words w) []
where
normPhrase (x:[]) r = r ++ [QWord op x]
normPhrase (x:xs) r = normPhrase xs $
r ++ [QFullWord op x]
normPhrase [] r = r
normPhraseQuery q
= return q



collectAssoc :: BinOp -> Query -> [Query] -> [Query]
collectAssoc op (QBinary op' q1 q2)
| op == op'
Expand Down

0 comments on commit b7d3510

Please sign in to comment.