我想提取荷兰语中的所有动词,为此我使用了 Wordnet。 我写了下面的代码,但结果仍然没有输出,因为 dutch_verbs 列表是空的! 知道为什么它会是空的,代码应该是正确的!?
非常感谢! 马克
列出所有荷兰语动词; [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)