Skip to content

Instantly share code, notes, and snippets.

@alexgolec
Created January 18, 2019 16:41
Show Gist options
  • Save alexgolec/6c3479980ff0d6194b7334ed1a65c706 to your computer and use it in GitHub Desktop.
Save alexgolec/6c3479980ff0d6194b7334ed1a65c706 to your computer and use it in GitHub Desktop.
synonyms = defaultdict(set)
for w1, w2 in synonym_words:
for w in synonyms[w1]:
synonyms[w].add(w2)
synonyms[w1].add(w2)
for w in synonyms[w2]:
synonyms[w].add(w1)
synonyms[w2].add(w1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment