nltk semantic word substitution
<p>I'm trying to find different ways of writing "events in [city]" which are semantically similar. I am trying to do this by finding words that are semantically similar to "events" so I can substitute them in. </p>

<p>To find these words I'm using nltk's wordnet corpus, but I'm getting some pretty strange results. For example, using the hyponyms of 'event.n.01', I'm getting "Miracles in Ottawa". </p>

<p>co-hyponyms and hypernyms seem just as bad or worse. I wonder if anyone understands the structure better and can offer a potential solution?</p>

<p>Here's some sample code:</p>

<pre><code>!/usr/bin/python3

import nltk

lemma = 'event.n.01'
synset = nltk.corpus.wordnet.synset(lemma)

print("%s: %s" % (synset.name(), synset.definition()))

print("\nFinding hyponyms...")
print([s.split('.')[0] for w in synset.hyponyms() for s in w.lemma_names()])

print("\nFinding hypernym paths...")
print([s.split('.')[0] for hyprs in synset.hypernym_paths() for hypr in hyprs for s in hypr.lemma_names()])

print("\nFinding co-hyponyms...")
for hypers in synset.hypernym_paths():
        for hyper in hypers:
                print(hyper.name())
                for hypos in hyper.hyponyms():
                        print("\t%s" % (', '.join(hypos.lemma_names())))

print(synset.similar())
</code></pre>

<p>You can take a deep learning approach. Train a word2vec model and get the most similar vectors to the "event" vector.</p>

<p>You can test a model here <a href="http://turbomaze.github.io/word2vecjson/" rel="nofollow" title="Word2Vec">Word2Vec Demo</a></p>

python nlp nltk