Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fsmi-klausurarchiv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fsarbeit.imt
fsmi-klausurarchiv
Commits
1eab7dcd
There was an error fetching the commit references. Please try again later.
Commit
1eab7dcd
authored
Sep 8, 2019
by
Dennis Baurichter
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/python/klausurarchiv/search/util.py
+13
-15
13 additions, 15 deletions
src/python/klausurarchiv/search/util.py
with
13 additions
and
15 deletions
src/python/klausurarchiv/search/util.py
+
13
−
15
View file @
1eab7dcd
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment