5.3 更多的词汇关系

上位词和下位词被称为词汇关系,因为它们是同义集之间的关系。这个关系定位上下为“是一个”层次。WordNet 网络另一个重要的漫游方式是从元素到它们的部件(部分)或到它们被包含其中的东西(整体)。例如,一棵树的部分是它的树干,树冠等;这些都是part_meronyms()。一棵树的 实质 是包括心材和边材组成的,即substance_meronyms()。树木的集合形成了一个森林,即member_holonyms()

  1. >>> wn.synset('tree.n.01').part_meronyms()
  2. [Synset('burl.n.02'), Synset('crown.n.07'), Synset('limb.n.02'),
  3. Synset('stump.n.01'), Synset('trunk.n.01')]
  4. >>> wn.synset('tree.n.01').substance_meronyms()
  5. [Synset('heartwood.n.01'), Synset('sapwood.n.01')]
  6. >>> wn.synset('tree.n.01').member_holonyms()
  7. [Synset('forest.n.01')]

来看看可以获得多么复杂的东西,考虑具有几个密切相关意思的词 mint。我们可以看到mint.n.04mint.n.02的一部分,是组成mint.n.05的材质。

  1. >>> for synset in wn.synsets('mint', wn.NOUN):
  2. ... print(synset.name() + ':', synset.definition())
  3. ...
  4. batch.n.02: (often followed by `of') a large number or amount or extent
  5. mint.n.02: any north temperate plant of the genus Mentha with aromatic leaves and
  6. small mauve flowers
  7. mint.n.03: any member of the mint family of plants
  8. mint.n.04: the leaves of a mint plant used fresh or candied
  9. mint.n.05: a candy that is flavored with a mint oil
  10. mint.n.06: a plant where money is coined by authority of the government
  11. >>> wn.synset('mint.n.04').part_holonyms()
  12. [Synset('mint.n.02')]
  13. >>> wn.synset('mint.n.04').substance_holonyms()
  14. [Synset('mint.n.05')]

动词之间也有关系。例如,走路的动作包括抬脚的动作,所以走路蕴涵着抬脚。一些动词有多个蕴涵:

  1. >>> wn.synset('walk.v.01').entailments()
  2. [Synset('step.v.01')]
  3. >>> wn.synset('eat.v.01').entailments()
  4. [Synset('chew.v.01'), Synset('swallow.v.01')]
  5. >>> wn.synset('tease.v.03').entailments()
  6. [Synset('arouse.v.07'), Synset('disappoint.v.01')]

词条之间的一些词汇关系,如反义词:

  1. >>> wn.lemma('supply.n.02.supply').antonyms()
  2. [Lemma('demand.n.02.demand')]
  3. >>> wn.lemma('rush.v.01.rush').antonyms()
  4. [Lemma('linger.v.04.linger')]
  5. >>> wn.lemma('horizontal.a.01.horizontal').antonyms()
  6. [Lemma('inclined.a.02.inclined'), Lemma('vertical.a.01.vertical')]
  7. >>> wn.lemma('staccato.r.01.staccato').antonyms()
  8. [Lemma('legato.r.01.legato')]

你可以使用dir()查看词汇关系和同义词集上定义的其它方法,例如dir(wn.synset('harmony.n.02'))