NLTK中的字母标记法

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

使用NLTK字母组合标记,我正在训练Brown Corpus中的句子>

我尝试使用不同的categories,但得到的值大致相同。对于每个0.9328,例如categoriesfictionromance,该值约为humor ...>

from nltk.corpus import brown


# Fiction    
brown_tagged_sents = brown.tagged_sents(categories='fiction')
brown_sents = brown.sents(categories='fiction')
unigram_tagger = nltk.UnigramTagger(brown_tagged_sents)
unigram_tagger.evaluate(brown_tagged_sents)
>>> 0.9415956079897209

# Romance
brown_tagged_sents = brown.tagged_sents(categories='romance')
brown_sents = brown.sents(categories='romance')
unigram_tagger = nltk.UnigramTagger(brown_tagged_sents)
unigram_tagger.evaluate(brown_tagged_sents)
>>> 0.9348490474422324

为什么会这样?是因为它们来自同一corpus吗?还是他们的part-of-speech标记相同?

[使用NLTK Unigram Tagger,我正在用Brown Corpus训练句子,尝试不同的类别,我得到的价值大致相同。对于每个类别,例如小说,...

nlp nltk stanford-nlp allennlp
1个回答
0
投票

[您似乎正在训练,然后根据相同的训练数据评估训练后的UnigramTagger。看看nltk.tag的文档,尤其是有关评估的part

通过您的代码,您将获得很高的分数,这很明显,因为您的训练数据和评估/测试数据是相同的。如果要更改测试数据与培训数据不同的位置,则会得到不同的结果。我的示例如下:

© www.soinside.com 2019 - 2024. All rights reserved.