Files
MoFin/venv/lib/python3.12/site-packages/nltk/test/wordnet_lch.doctest
T
知微 fa45d8aa5f fix: 小果地址统一node122(兼容LAN+EasyTier)
- health_checklist.json: 192.168.1.122→node122
- ocr_client.py: docstring IP→node122
- docs/market-data-requirements.md: IP→node122
- 所有API调用通过ProxyHandler({})绕过系统代理
  Privoxy对node122:18003返回500,直连正常
2026-06-30 02:56:35 +08:00

54 lines
2.3 KiB
Plaintext

.. Copyright (C) 2001-2026 NLTK Project
.. For license information, see LICENSE.TXT
===============================
WordNet Lowest Common Hypernyms
===============================
Wordnet's lowest_common_hypernyms() method is based used to locate the
lowest single hypernym that is shared by two given words:
>>> from nltk.corpus import wordnet as wn
>>> wn.synset('kin.n.01').lowest_common_hypernyms(wn.synset('mother.n.01'))
[Synset('relative.n.01')]
>>> wn.synset('policeman.n.01').lowest_common_hypernyms(wn.synset('chef.n.01'))
[Synset('person.n.01')]
This method generally returns a single result, but in some cases, more than one
valid LCH is possible:
>>> wn.synset('body.n.09').lowest_common_hypernyms(wn.synset('sidereal_day.n.01'))
[Synset('attribute.n.02'), Synset('measure.n.02')]
In some cases, lowest_common_hypernyms() can return one of the synsets which was
passed to it as an argument:
>>> wn.synset('woman.n.01').lowest_common_hypernyms(wn.synset('girlfriend.n.02'))
[Synset('woman.n.01')]
In NLTK 3.0a2 the behavior of lowest_common_hypernyms() was changed to give more
accurate results in a small set of cases, generally when dealing with nouns describing
social roles or jobs. To emulate the pre v3.0a2 behavior, you can set the use_min_depth=True
flag:
>>> wn.synset('policeman.n.01').lowest_common_hypernyms(wn.synset('chef.n.01'))
[Synset('person.n.01')]
>>> wn.synset('policeman.n.01').lowest_common_hypernyms(wn.synset('chef.n.01'), use_min_depth=True)
[Synset('organism.n.01')]
In some cases use_min_depth=True may return more or fewer results than the default
behavior:
>>> wn.synset('woman.n.01').lowest_common_hypernyms(wn.synset('girlfriend.n.02'))
[Synset('woman.n.01')]
>>> wn.synset('woman.n.01').lowest_common_hypernyms(wn.synset('girlfriend.n.02'), use_min_depth=True)
[Synset('organism.n.01'), Synset('woman.n.01')]
In the general case, however, they tend to return the same results:
>>> wn.synset('body.n.09').lowest_common_hypernyms(wn.synset('sidereal_day.n.01'))
[Synset('attribute.n.02'), Synset('measure.n.02')]
>>> wn.synset('body.n.09').lowest_common_hypernyms(wn.synset('sidereal_day.n.01'), use_min_depth=True)
[Synset('attribute.n.02'), Synset('measure.n.02')]