Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for sentence in tokenized:
- pos_sentences = st.tag(sentence)
- #print pos_sentences
- tmp = []
- # mapping nltk pos tags to wordnet pos tags
- for tok, pos in pos_sentences:
- lower_pos = pos[0].lower()
- if lower_pos in ['a', 'n', 'v', 'r', 's']:
- res = wordnet.synsets(tok, lower_pos)
- if len(res) > 0:
- a = res[0]
- else:
- a = "[{0}, {1}]".format(tok, pos)
- tmp.append(a)
- #print a
- wordnet_sense.append(tmp)
- print wordnet_sense
- >>> [['[angry, JJ]'], [Synset('anger.n.01')], [Synset('happiness.n.01')], ['[sad, JJ]']]
- for i in wordnet_sense:
- for v in i:
- wna = WNAffect('wordnet-1.6/', 'wn-domains-3.2/')
- emo = wna.get_emotion(v[0], v[1])
- print emo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement