Created
May 7, 2019 13:06
-
-
Save adsieg/d3e04773bf2092fe28c831a892402dc1 to your computer and use it in GitHub Desktop.
knowledge_based_measure
This file contains hidden or 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
from nltk.corpus import wordnet as wn | |
from nltk.corpus import wordnet_ic | |
dog=wn.synsets('dog', pos=wn.NOUN)[0] #get the first noun synonym of the word "dog" | |
cat=wn.synsets('cat', pos=wn.NOUN)[0] | |
rose=wn.synsets('rose', pos=wn.NOUN)[0] | |
flower=wn.synsets('flower', pos=wn.NOUN)[0] | |
brown_ic = wordnet_ic.ic('ic-brown.dat') #load the brown corpus to compute the IC | |
rose.res_similarity(flower, brown_ic) | |
rose.res_similarity(dog, brown_ic) | |
cat.res_similarity(dog, brown_ic) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment