我要求 Wordnet(在 python 脚本中)列出所有现有的荷兰语动词,但我的输出是空的。有什么想法吗?

问题描述 投票:0回答:0

我想提取荷兰语中的所有动词,为此我使用了 Wordnet。 我写了下面的代码,但结果仍然没有输出,因为 dutch_verbs 列表是空的! 知道为什么它会是空的,代码应该是正确的!?

非常感谢! 马克

这是我在 Google Colab 中得到的输出:

列出所有荷兰语动词; [nltk_data] 正在将 wordnet 包下载到 /root/nltk_data...; [nltk_data] 包 wordnet 已经是最新的!; [nltk_data] 正在将 omw 包下载到 /root/nltk_data...; [nltk_data] 包 omw 已经是最新的了!;

我期待一个动词列表(不定式),根据以下代码按字母顺序升序排列:

python代码

`    import nltk
`    nltk.download('wordnet')
`    from nltk.corpus import wordnet as wn

`    print('Listing all verbs in Dutch')

`    #Download the Dutch WordNet corpus
`    nltk.download('omw')

`    #Get all synsets for verbs (pos='v') in Dutch
`    dutch_verb_synsets = wn.all_synsets(pos='v', lang='nld')

`    #Extract infinitive verb forms from synsets
`    dutch_verbs = [lemma.name() for synset in dutch_verb_synsets for lemma in synset.lemmas(lang='nld')]

`    #Remove duplicates and sort the verbs
`    unique_dutch_verbs = sorted(set(dutch_verbs))

`    #Print the list of verbs in Dutch
`    for verb in unique_dutch_verbs:
`        print(verb)

python nlp wordnet
© www.soinside.com 2019 - 2024. All rights reserved.