Permalink
Browse files

Added substring matching

  • Loading branch information...
1 parent 2908333 commit 22d1a4687f8267a1e61fe1132b3774baf48e526a @ari0 ari0 committed Jan 1, 2011
Showing with 8 additions and 3 deletions.
  1. +8 −3 RapMatcher.py
View
11 RapMatcher.py
@@ -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
@@ -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())

0 comments on commit 22d1a46

Please sign in to comment.