Skip to content

Commit

Permalink
Added substring matching
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdabaa committed Jan 1, 2011
1 parent 2908333 commit 22d1a46
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions RapMatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ def __equality_match(self, word1, word2):
"""
Tests whether or not word1 is equal to word2
"""
return (word1 == word2)

return word1 == word2

def __substring_match(self, word1, word2):
return (((len(word1) > 3) and (word1 in word2)) or
((len(word2) > 3) and (word2 in word1)))

def __levenshtein_match(self, word1, word2):
"""
Tests whether word1 and word2 both have length >= 5
Expand Down Expand Up @@ -66,7 +70,8 @@ def match(self, query):
for interest in self.interests:
for word in interest.get_words():
word = word.upper()
if ((self.__equality_match(query, word)) or
if ((self.__equality_match(query, word)) or
(self.__substring_match(query, word)) or
(self.__levenshtein_match(query, word)) or
(self.__wordnet_match(query, word))):
self.matches.add(interest.get_name())
Expand Down

0 comments on commit 22d1a46

Please sign in to comment.