You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NLTK WordNet 3.0同义词集上位词列表不完整问题咨询

Why NLTK WordNet 3.0 and Web WordNet Show Different Hypernyms for "bank" (casino funds)

First, let’s clear up the core discrepancy: it’s not that NLTK is missing hypernyms—it’s a difference in how results are presented.

When you run bank6ss.hypernyms() in NLTK, you get [Synset('funds.n.01')]—this is the single, correct direct hypernym synset. The WordNet web version displays multiple terms (funds, finances, monetary resource, etc.) because those are all lemma names belonging to the same funds.n.01 synset. A WordNet synset groups synonymous words together, so the web interface lists all those synonyms as "hypernyms" for readability, but they’re all part of the same underlying synset.

How to Get the Full List of Hypernym Terms in NLTK

To replicate the web version’s output, you just need to extract all lemma names from the hypernym synset. Here’s how to adjust your code:

from nltk.corpus import wordnet as wn

# Get the casino funds synset for "bank"
bank6ss = wn.synsets("bank")[5]

# Fetch the hypernym synset(s)
hypernym_synsets = bank6ss.hypernyms()

# Extract all lemma names from each hypernym synset
full_hypernym_terms = []
for synset in hypernym_synsets:
    full_hypernym_terms.extend([lemma.name() for lemma in synset.lemmas()])

print(full_hypernym_terms)
# Output: ['funds', 'finances', 'monetary_resource', 'monetary_fund']

This will give you all the synonymous terms the web version lists as direct hypernyms.

Why instance_hypernyms() Doesn’t Help

instance_hypernyms() is designed for synsets representing specific instances (like a particular person or landmark), not general categories like funds. Since the casino "bank" synset refers to a general type of fund, this method won’t return relevant results here.

Note on WordNet Versions

Your NLTK uses WordNet 3.0, an older release (current WordNet is 3.1). However, this specific synset structure hasn’t changed between versions—even if you upgrade, you’ll still get funds.n.01 as the hypernym, and extracting its lemmas will yield the same list of terms.

内容的提问来源于stack exchange,提问作者freieschaf

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:34:37