Skip to content

Commit

Permalink
added sorting of synonyms
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroMTQ committed Mar 2, 2022
1 parent 551dd08 commit 32e8a3b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions unifunc/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,8 @@ def add_alternative_tokens(self,vector1):
#remove parentheses
if w.startswith('[') and w.endswith(']'): res[w].add(w.strip('[]'))
if w.startswith('(') and w.endswith(')'): res[w].add(w.strip('()'))
for w in res:
res[w]=sorted(res[w])
return res

def find_matching_tokens(self,synset1,synset2):
Expand All @@ -1371,9 +1373,12 @@ def find_matching_tokens(self,synset1,synset2):
matches_found[w2]=w1
else:
synsw2 = synset2[w2]
syns_intersect=synsw1.intersection(synsw2)
temp_synsw1=set(synsw1)
temp_synsw2=set(synsw2)
syns_intersect=temp_synsw1.intersection(temp_synsw2)
syns_intersect=sorted(syns_intersect)
if syns_intersect:
best_syn=syns_intersect.pop()
best_syn=syns_intersect[0]
matches_found[w1]=best_syn
matches_found[w2]=best_syn
return matches_found
Expand Down

0 comments on commit 32e8a3b

Please sign in to comment.