37 lines
1.7 KiB
Python
37 lines
1.7 KiB
Python
from nltk.corpus import wordnet as wn
|
|
|
|
# syns = wn.synsets("program")
|
|
# print(syns[0].name())
|
|
|
|
# grief = wn.synsets('grief')
|
|
# love = wn.synsets('love')
|
|
|
|
# # print(grief.path_similarity(love))
|
|
# # print(grief)
|
|
# print(grief[0].definition())
|
|
# print(love[0].definition())
|
|
|
|
|
|
w1 = wn.synset('grief.n.01')
|
|
w2 = wn.synset('love.n.01')
|
|
|
|
# print(w1.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0])
|
|
# print(w2.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0])
|
|
|
|
# print(w1.hypernyms()[0],w2.hypernyms()[0])
|
|
# print(w1.hypernyms()[0].hypernyms()[0],w2.hypernyms()[0].hypernyms()[0])
|
|
# print(w1.hypernyms()[0].hypernyms()[0].hypernyms()[0],w2.hypernyms()[0].hypernyms()[0].hypernyms()[0])
|
|
# print(w1.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0],w2.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0])
|
|
# print(w1.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0],w2.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0])
|
|
# print(w1.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0],w2.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0])
|
|
# print(w1.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0],w2.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0])
|
|
|
|
# print(wn.synsets('abstraction.n.06')[0])
|
|
|
|
abstractNouns = set([i for i in wn.synset('abstraction.n.06').closure(lambda s:s.hyponyms())])
|
|
print(len(abstractNouns))
|
|
|
|
abst = wn.synset('abstraction.n.06').hyponyms()
|
|
print(len(abst))
|
|
for n in abst:
|
|
print(n) |