【发布时间】:2016-01-26 15:07:49
【问题描述】:
我想在 python 中使用StanfordNER 来检测命名实体。我应该如何清理句子?
例如,考虑
qry="In the UK, the class is relatively crowded with Zacc competing with Abc's Popol (market leader) and Xyz's Abcvd."
如果我愿意
st = StanfordNERTagger('english.all.3class.distsim.crf.ser.gz')
print st.tag(qry.split())
我明白了
[
(u'In', u'O'), (u'the', u'O'), (u'UK,', u'O'), (u'the', u'O'),
(u'class', u'O'), (u'is', u'O'), (u'relatively', u'O'), (u'crowded', u'O'),
(u'with', u'O'), (u'Zacc', u'PERSON'), (u'competing', u'O'), (u'with', u'O'),
(u"Abc's", u'O'), (u'Popol', u'O'), (u'(market', u'O'), (u'leader)', u'O'),
(u'and', u'O'), (u"Xyz's", u'O'), (u'Abcvd.', u'O')
]
`
所以只检测到 1 个命名实体。但是,如果我通过用空格替换所有特殊字符来进行一些清理
qry="In the UK the class is relatively crowded with Zacc competing with Abc s Popol market leader and Xyz s Abcvd"
我明白了
[
(u'In', u'O'), (u'the', u'O'), (u'UK', u'LOCATION'), (u'the', u'O'),
(u'class', u'O'), (u'is', u'O'), (u'relatively', u'O'), (u'crowded', u'O'),
(u'with', u'O'), (u'Zacc', u'PERSON'), (u'competing', u'O'), (u'with', u'O'),
(u'Abc', u'ORGANIZATION'), (u's', u'O'), (u'Popol', u'PERSON'), (u'market', u'O'),
(u'leader', u'O'), (u'and', u'O'), (u'Xyz', u'ORGANIZATION'), (u's', u'O'), (u'Abcvd', u'PERSON')]
`
很明显,这样比较合适。有没有关于如何清理StanfordNER 的句子的一般规则?最初我认为根本不需要清理!
【问题讨论】:
标签: python nlp nltk stanford-nlp named-entity-recognition