有什么方法可以获得与单个单词相关的下位词的完整列表?
relative = wordnet.synsets("relative", pos='n')[0]
hyponyms = ([lemma.name() for synset in relative.hyponyms() for lemma in synset.lemmas()])
这给了我很多下位词,但是Wordnet在线搜索的完整下载列表中的很多都不在我的列表中。
答案 0 :(得分:2)
使用Synset.closure()
功能:
from nltk.corpus import wordnet as wn
relative = wn.synsets('relative', 'n')[0]
hypos = lambda s:s.hyponyms()
print(list(relative.closure(hypos)))
[OUT]:
[Synset(' agnate.n.01'),Synset(' ancestor.n.01'),Synset(' blood_relation.n.01' ),Synset(' cousin.n.01'),Synset(' descendant.n.01'),Synset(' enate.n.01'), Synset(' in-law.n.01'),Synset(' kin.n.01'),Synset(' kinsman.n.01'), Synset(' kinswoman.n.01'),Synset(' kissing_cousin.n.01'),Synset(' next_of_kin.n.01'),Synset( ' offspring.n.01'),Synset(' second_cousin.n.01'),Synset(' sibling.n.01'),Synset(&# 39; spouse.n.01'),Synset(' ancestress.n.01'),Synset(' forebear.n.01'),Synset(' foreset.n.01'),Synset(' foremother.n.01'),Synset(' progenitor.n.01'),Synset('孩子。 n.04'),Synset(' scion.n.01'),Synset(' brother-in-law.n.01'),Synset('媳妇.n.01'),Synset('岳父.n.01'),Synset('婆婆.n.01&# 39;),Synset('嫂子.n.01'),Synset(' son-in-law.n.01'),S ynset(' affine.n.01'),Synset(' male_sibling.n.01'),Synset(' nephew.n.01'),Synset( ' uncle.n.01'),Synset(' aunt.n.01'),Synset(' female_sibling.n.01'),Synset(&# 39; niece.n.01'),Synset(' baby.n.02'),Synset(' bastard.n.02'),Synset(' child.n.02'),Synset(' firstborn.n.01'),Synset(' grandchild.n.01'),Synset('继承人。 n.03'),Synset(' half_blood.n.01'),Synset(' quadruplet.n.02'),Synset(' quintuplet.n。 02'),Synset(' triplet.n.02'),Synset(' twin.n.01'),Synset(' bigamist.n.01&# 39;),Synset(' consort.n.01'),Synset(' helpmate.n.01'),Synset(' husband.n.01' ),Synset(' monogamist.n.01'),Synset(' newlywed.n.01'),Synset(' polygamist.n.01'), Synset(' wife.n.01'),Synset(' grandparent.n.01'),Synset(' great_grandparent.n.01'),Synset( ' patriarch.n.03'),Synset(' genitor.n.01'),Synset(& #39; brother.n.01'),Synset(' great-nephew.n.01'),Synset(' great-uncle.n.01'),Synset (' great-aunt.n.01'),Synset(' maiden_aunt.n.01'),Synset(' sister.n.01'),Synset (' great-niece.n.01'),Synset(' army_brat.n.01'),Synset(' baby.n.01'),Synset (' female_offspring.n.01'),Synset(' male_offspring.n.01'),Synset(' stepchild.n.01'),Synset(& #39; granddaughter.n.01'),Synset(' grandson.n.01'),Synset(' great_grandchild.n.01'),Synset(') ; fraternal_twin.n.01'),Synset(' identical_twin.n.01'),Synset(' prince_consort.n.01'),Synset(' benedick .n.01'),Synset(' cuckold.n.01'),Synset(' family_man.n.01'),Synset(' house_husband.n .01'),Synset(' uxoricide.n.01'),Synset(' bride.n.01'),Synset(' groom.n.03& #39;),Synset(' polyandrist.n.01'),Synset(' polygynist.n.01'),Synset(' battle-ax.n.02& #39;),Synset(' crown _prin cess.n.01'),Synset(' first_lady.n.02'),Synset(' golf_widow.n.01'),Synset(' honest_woman。 n.01'),Synset(' housewife.n.01'),Synset(' marchioness.n.01'),Synset(' matron.n。 01'),Synset(' mayoress.n.01'),Synset(' missus.n.01'),Synset(' old_lady.n.01&# 39;),Synset(' sheika.n.01'),Synset(' signora.n.01'),Synset(' trophy_wife.n.01' ),Synset(' uxor.n.01'),Synset(' vicereine.n.01'),Synset(' viscountess.n.01'), Synset(' grandfather.n.01'),Synset(' grandma.n.01'),Synset(' great_grandfather.n.01'),Synset( ' great_grandmother.n.01'),Synset(' antediluvian.n.01'),Synset(' jacob.n.02'),Synset(&# 39; simeon.n.01'),Synset(' parent.n.01'),Synset(' big_brother.n.02'),Synset(' little_brother.n.01'),Synset(' stepbrother.n.01'),Synset(' big_sister.n.01'),Synset(' half_sister。 n.01'),Synset(' littl e_sister.n.01'),Synset(' blue_baby.n.01'),Synset(' cherub.n.01'),Synset('弃儿。 n.01'),Synset(' godchild.n.01'),Synset(' neonate.n.01'),Synset(' nursling.n。 01'),Synset(' papoose.n.01'),Synset(' test-tube_baby.n.01'),Synset(' war_baby.n。 01'),Synset(' daughter.n.01'),Synset(' son.n.01'),Synset(' stepdaughter.n.01&# 39;),Synset(' stepson.n.01'),Synset(' great_granddaughter.n.01'),Synset(' great_grandson.n.01' ),Synset(' siamese_twin.n.01'),Synset(' wittol.n.01'),Synset(' war_bride.n.01'), Synset(' nan.n.01'),Synset(' adoptive_parent.n.01'),Synset(' empty_nester.n.01'),Synset( ' father.n.01'),Synset(' filicide.n.01'),Synset(' mother.n.01'),Synset(&# 39; stepparent.n.01'),Synset(' goddaughter.n.01'),Synset(' godson.n.01'),Synset(' liveborn_infant.n.01'),Synset('低生育-weight_baby.n.01'),Synset(' postmature_infant.n.01'),Synset(' premature_baby.n.01'),Synset(' small -for-gestational-age_infant.n.01'),Synset(' stillborn_infant.n.01'),Synset(' term_infant.n.01'),Synset(& #39; mother' s_daughter.n.01'),Synset(' junior.n.04'),Synset(' mother' s_boy.n.01' ;),Synset(' dad.n.01'),Synset(' old_man.n.03'),Synset(' pater.n.01') ,Synset(' ma.n.01'),Synset(' mater.n.01'),Synset(' primipara.n.01'),Synset (' puerpera.n.01'),Synset(' quadripara.n.01'),Synset(' quintipara.n.01'),Synset(& #39; supermom.n.01'),Synset(' surrogate_mother.n.01'),Synset(' stepfather.n.01'),Synset(') ; stepmother.n.01&#39)]