Skip to content

Commit

Permalink
Fuzzy matching should only select whole words as candidates.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Staubo committed Aug 26, 2011
1 parent eb026fd commit 8684a7b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion alternative_autocomplete.py
Expand Up @@ -65,7 +65,7 @@ def find_candidates(self, prefix, position, text):
candidates.sort(lambda a, b: cmp(a.distance, b.distance))
candidates = [candidate.text for candidate in candidates]
else:
word_regex = re.compile(re.escape(prefix[0:1]) + r'[\w\d]+', re.M | re.U | re.I)
word_regex = re.compile(r'\b' + re.escape(prefix[0:1]) + r'[\w\d]+', re.M | re.U | re.I)
words = word_regex.findall(text)
candidates = [word for word in words if word != prefix and fuzzy_match(prefix, word)]
if candidates:
Expand Down

0 comments on commit 8684a7b

Please sign in to comment.