Skip to content

Commit

Permalink
Merge pull request #140 from gunthercox/issue_65
Browse files Browse the repository at this point in the history
Select the closest pair of synsets for two words
  • Loading branch information
gunthercox committed Mar 27, 2016
2 parents 12e3c85 + a95d71a commit df1beda
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions chatterbot/adapters/logic/closest_meaning.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,17 @@ def get_similarity(self, string1, string2):

if synset1 and synset2:

# Compare the first synset in each list of synsets
similarity = synset1[0].path_similarity(synset2[0])
max_similarity = 0

if similarity:
total_similarity = total_similarity + similarity
# Get the highest similarity for each combination of synsets
for synset in itertools.product(*[synset1, synset2]):
similarity = synset[0].path_similarity(synset[1])

if similarity and (similarity > max_similarity):
max_similarity = similarity

# Add the most similar path value to the total
total_similarity += max_similarity

return total_similarity

Expand Down

0 comments on commit df1beda

Please sign in to comment.