Last active
January 20, 2019 06:27
-
-
Save alexgolec/8b2d5db8ade800dc7ba28e70e6b34a1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def synonym_queries(synonym_words, queries): | |
''' | |
synonym_words: iterable of pairs of strings representing synonymous words | |
queries: iterable of pairs of strings representing queries to be tested for | |
synonymous-ness | |
''' | |
output = [] | |
for q1, q2 in queries: | |
q1, q2 = q1.split(), q2.split() | |
if len(q1) != len(q2): | |
output.append(False) | |
continue | |
result = True | |
for i in range(len(q1)): | |
w1, w2 = q1[i], q2[i] | |
if w1 == w2: | |
continue | |
elif words_are_synonyms(w1, w2): | |
continue | |
result = False | |
break | |
output.append(result) | |
return output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment