Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select the closest pair of synsets for two words #140

Merged
merged 1 commit into from
Mar 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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