Skip to content
Snippets Groups Projects
Commit 1eab7dcd authored by Dennis Baurichter's avatar Dennis Baurichter
Browse files

Ignore order of words in search queries

Partially fixes #77
parent 9b2b91ab
No related branches found
No related tags found
No related merge requests found
......@@ -53,7 +53,7 @@ class SimpleSearcher(ISearcher):
# Comparison is done by splitting both the search query and comparison strings
# into individual words (by splitting at spaces).
# A given string matches the search query iff each word of the query is present
# in the list of words of the compared string, and occurs in the same order.
# in the list of words of the compared string.
# An individual word of the query string matches an individual word of a
# comparison string iff it is a substring (case insensitive).
# Example:
......@@ -62,13 +62,7 @@ class SimpleSearcher(ISearcher):
# vvvv vvvv
# strings: correct battery horse staple
# (match)
#
# query string: horse battery
# vvvvv xxxxxxx
# string: correct battery horse staple
# (mismatch)
# ```
# Note that there may be any number of words bet
#
class SESearcher(ISearcher):
......@@ -89,13 +83,17 @@ class SESearcher(ISearcher):
# \returns True iff v matches our query string according to the algorithm
# specified in our class description.
def match(s,v):
i=0
n=len(s._q)
if i>=n: return False
parts=v.lower().split(" ")
for q in s._q:
found=False
for part in parts:
if part.find(q) > -1:
found=True
break
for x in v.split(" "):
if x.lower().find(s._q[i])>-1:
i=i+1
if i>=n: return True
if not found:
return False
return True
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment