python - 如何在 NLTK 中将荷兰语文本与西类牙语部分分开?

标签 python tags nltk text-mining

NLTK包含荷兰语标记语料库,我如何从中打印最常见的标记?

为此,我需要知道荷兰语标签包含在 conll2002 语料库中。

conll2002 语料库还包含西类牙语文本,因此我只需阅读荷兰语部分。

<小时/>

代码:

conll_tagged = nltk.corpus.conll2002.tagged_words()

tag_fd = nltk.FreqDist(conll_tagged 中(单词,标签)的标签)

tag_fd.most_common()

[(u'NC', 89469), (u'N', 77188), (u'SP', 61145), (u'V', 40744), (u'Punc', 39354), ( u'DA', 35574), (u'Prep', 32114), (u'AQ', 31249), (u'Art', 28875), (u'Pron', 22037), (u'Adv', 21987), (u'Fc', 20719), (u'Adj', 20553), (u'VMI', 19650), (u'Conj', 14281), (u'Num', 11226), (u'Num', 11226) 'Fp', 10266), (u'Z', 9291), (u'CC', 8543), (u'DI', 7630), (u'Fe', 7544), (u'RG', 7396 ), (u'PR', 7128), (u'VMN', 6435), (u'CS', 6408), (u'VMP', 3547), (u'P0', 3509), (u'第3314章 3314、3307、2817、2437、2345、2238 ,(u'DD',2224),(u'DN',1875),(u'NP',1846),(u'VMS',1624),(u'RN',1546),(u'PP' ', 1302), (u'AO', 1281), (u'PI', 864), (u'VMM', 854), (u'PN', 820), (u'Misc', 616), (u'VMG', 528), (u'Fd', 365), (u'VSN', 291), (u'VSP', 258), (u'PD', 231), (u'Int' , 231), (u'Fx', 211), (u'VSS', 176), (u'Fz', 157), (u'VAN', 146), (u'I', 136), ( u'VAS', 129), (u'PT', 95), (u'Fh', 72), (u'Y', 34), (u'VSG', 26), (u'Fs', 25), (u'Fit', 18), (u'Fia', 18), (u'VAP', 18), (u'DT', 17), (u'Fat', 5), (u 'Ft', 4), (u'PX', 4), (u'Faa', 4), (u'VSM', 3), (u'DE', 2), (u'VAM', 1 )]

最佳答案

其正确的conll2002还包含西类牙语和荷兰语。

print nltk.corpus.conll2002.fileids()
Output:
['esp.testa', 'esp.testb', 'esp.train', 'ned.testa', 'ned.testb', 'ned.train']

我们只对荷兰语感兴趣,具体方法如下。

from nltk.corpus import conll2002
for doc in conll2002.tagged_sents('ned.testa')[:]: #you need change the file name according to your requirement
     conll_tagged += doc
tag_fd = nltk.FreqDist(tag for (word,tag) in conll_tagged)
tag_fd.items()

输出是:

[(u'N', 38789),
 (u'V', 21032),
 (u'Prep', 16540),
 (u'Punc', 16472),
 (u'Art', 14816),
 (u'Adv', 10824),
 (u'Adj', 10296),
 (u'Pron', 10232),
 (u'Conj', 7184),
 (u'Num', 4268),
 (u'Misc', 244),
 (u'Int', 52)]

关于python - 如何在 NLTK 中将荷兰语文本与西类牙语部分分开?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35340049/

相关文章:

c# - 在 Visual Studio XML 文档中同时使用 <value> 和 <summary> 标签的目的

html - 使用 xsl :element tag for html transformation

python - NLTK FreqDest 对象比较

python - "TclError: no display name and no $DISPLAY environment variable"nltk错误

python - 如何让 Python 在现有的 NetBeans 中运行?

python(boto3)程序删除aws中的旧快照

python - 在面向对象的 Python 中使用 ctypes 从 DLL 文件运行函数时出现问题

docker - 如何在 docker-compose 中使用多个图像标签

Python 将输出转换为句子

python - proto3 Python 中未显示 False Boolean