简体   繁体   English

使用python获取不同语言的单词列表

[英]Get list of words in different languages using python

I'm trying to get a list of all words in a language in the same way NLTK is providing for english. 我正在尝试以NLTK为英语提供的相同方式来获取语言中所有单词的列表。 See example for english: 参见英语示例:

I already tried to use pyenchant to achieve a similar result but the documentation not being updated I have some troubles downloading an italian dictionary (MacOS). 我已经尝试使用pyenchant达到类似的结果,但是文档没有更新,因此下载意大利语词典(MacOS)时遇到了一些麻烦。

from nltk.corpus import words
print(words.words())

Is it possible to get a similar list in french, german and italian? 是否有可能以法语,德语和意大利语获得类似的列表?

You can combine googletrans and nltk as the following: 您可以将googletrans和nltk结合如下:

from nltk.corpus import words
from googletrans import Translator

french = []
translator = Translator()

for in_english in words.words():
    in_french = translator.translate(in_english, dest='fr')
    french.append(in_french.text)
    print in_french.text

print french 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM