自然语言处理之:命名实体识别-3
使用机器学习工具包进行命名实体识别
使用词性标注进行命名实体识别:
如果使用了词性标注,那么使用词性信息可以识别出命名实体,用NNP标记标注的标识符,就是命名实体。
例子1
import nltk
from nltk import pos_tag, word_tokenize
print(pos_tag(word_tokenize("John and Smith are going to NY and Germany")))
例子2
import nltk
from nltk import pos_tag, word_tokenize
print(pos_tag(word_tokenize("John and Smith are going to NY and Germany")))
#使用机器学习工具包来进行NER,
# 可以使用词性标注来进行命名实体识别,其中,NNP属于命名实体
#[('John', 'NNP'), ('and', 'CC'), ('Smith', 'NNP'), ('are', 'VBP'), ('going', 'VBG'), ('to', 'TO'), ('NY', 'NNP'), ('and', 'CC'), ('Germany', 'NNP')]
#其中nnp为命名实体。