NLP中的命名实体

时间:2017-06-20 17:14:49

标签: python-3.x nlp nltk stanford-nlp named-entity-recognition

我正在尝试使用stanford NER标记器在一个小测试中获取命名实体。这是代码:

Sub VBA_to_append_existing_text_file()

'Declaring the strFile_Path variable as String Data Type to store the text file path.
Dim strFile_Path As String

'Assigning the Existing File path to the variable strFile_Path.
strFile_Path = "C:\your_path_here\test.txt"

'Opening the text file for Append with FileNumber as 1.
Open strFile_Path For Append As #1

'Writing to the sample text to the File using FileNumber and Write Command.
YourValue = Worksheets("Sheet1").Range("A1").Value
Write #1, YourValue

'Closing the File using FileNumber.
Close #1

End Sub

我得到的输出是:

from nltk.tag import StanfordNERTagger
st = StanfordNERTagger('english.all.3class.distsim.crf.ser')
print st.tag('Ram offers computer science course'.split())

我不明白为什么所有标签都是'O'。虽然拉姆是一个人,但计算机是一个对象,科学和课程也是可分类的对象。

我有没有办法为我的句子命名实体如下:

[(u'Ram', u'O'), (u'offers', u'O'), (u'computer', u'O'), (u'science', u'O'), (u'course', u'O')]

0 个答案:

没有答案