gpt4 book ai didi

python - 名称实体识别NLTK回顾

转载 作者:行者123 更新时间:2023-11-30 09:11:25 25 4
gpt4 key购买 nike

我正在尝试创建一个实体识别(NER)应用程序,其中我尝试采用词性标记(PoS)方法。我正在尝试利用 Python 的 NLTK 库,并将其用作 hmm_tagger=nltk.HiddenMarkovModelTagger.train(train_set)。在训练集中,我尝试以布朗语料库的 tagged_sents() 格式提供数据。PoS标签如下

brown_a = nltk.corpus.brown.tagged_sents()[:2]
>>> brown_a
[[(u'The', u'AT'), (u'Fulton', u'NP-TL'), (u'County', u'NN-TL'), (u'Grand', u'JJ-TL'), (u'Jury', u'NN-TL'), (u'said', u'VBD'), (u'Friday', u'NR'), (u'an', u'AT'), (u'investigation', u'NN'), (u'of', u'IN'), (u"Atlanta's", u'NP$'), (u'recent', u'JJ'), (u'primary', u'NN'), (u'election', u'NN'), (u'produced', u'VBD'), (u'``', u'``'), (u'no', u'AT'), (u'evidence', u'NN'), (u"''", u"''"), (u'that', u'CS'), (u'any', u'DTI'), (u'irregularities', u'NNS'), (u'took', u'VBD'), (u'place', u'NN'), (u'.', u'.')], [(u'The', u'AT'), (u'jury', u'NN'), (u'further', u'RBR'), (u'said', u'VBD'), (u'in', u'IN'), (u'term-end', u'NN'), (u'presentments', u'NNS'), (u'that', u'CS'), (u'the', u'AT'), (u'City', u'NN-TL'), (u'Executive', u'JJ-TL'), (u'Committee', u'NN-TL'), (u',', u','), (u'which', u'WDT'), (u'had', u'HVD'), (u'over-all', u'JJ'), (u'charge', u'NN'), (u'of', u'IN'), (u'the', u'AT'), (u'election', u'NN'), (u',', u','), (u'``', u'``'), (u'deserves', u'VBZ'), (u'the', u'AT'), (u'praise', u'NN'), (u'and', u'CC'), (u'thanks', u'NNS'), (u'of', u'IN'), (u'the', u'AT'), (u'City', u'NN-TL'), (u'of', u'IN-TL'), (u'Atlanta', u'NP-TL'), (u"''", u"''"), (u'for', u'IN'), (u'the', u'AT'), (u'manner', u'NN'), (u'in', u'IN'), (u'which', u'WDT'), (u'the', u'AT'), (u'election', u'NN'), (u'was', u'BEDZ'), (u'conducted', u'VBN'), (u'.', u'.')]]

{这里我们可能会增加 Brown_a 的大小。它仅作为示例给出。}

我现在正在尝试构建一个 NER,我将上面的数据更改为,

[[(u'The', u'NameP'), (u'Fulton', u'Name'), (u'County', u'NameC'), (u'Grand', u'NameCC'), (u'Jury', u'NameCCC'), (u'said', u'VBD'), (u'Friday', u'NR'), (u'an', u'AT'), (u'investigation', u'NA'), (u'of', u'NA'), (u"Atlanta's", u'Name'), (u'recent', u'NA'), (u'primary', u'NA'), (u'election', u'NA'), (u'produced', u'NA'), (u'``', u'NA'), (u'no', u'NA'), (u'evidence', u'NA'), (u"''", u"NA"), (u'that', u'NA'), ...]

在这里,我保留数据格式,但将标记集更改为我的定义,即 NA 表示不可用(任何不是 NE 的内容), NameP 为前一个名称, 名字对名字,等等。

我现在正在将这些新数据作为训练集和训练。

我的方法很好还是我需要做一些重大改变?

请提出建议。

最佳答案

为什么不使用现成的NER系统,例如CRF-NERMallet ?您这样做是出于学术目的还是有需要解决的业务问题?如果是后者,请尝试使用已经构建的东西来获得初步结果,如果它们不符合您的期望,那么才考虑您的实现。

关于python - 名称实体识别NLTK回顾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35831630/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com