2017-04-21 107 views
-1

我在Python中使用斯坦福NER标记器。这不是标记日期和时间。而是在每个单词上都返回O. 我的一句话是:斯坦福NER没有标记日期和时间

结果我标记是 -

[('What', 'O'), ('sum', 'O'), ('of', 'O'), ('money', 'O'), ('will', 'O'), ('earn', 'O'), ('an', 'O'), ('interest', 'O'), ('of', 'O'), ('$', 'O'), ('162', 'O'), ('in', 'O'), ('3', 'O'), ('years', 'O'), ('at', 'O'), ('the', 'O'), ('rate', 'O'), ('of', 'O'), ('12%', 'O'), ('per', 'O'), ('annum', 'O')] 
后得到“什么笔钱将以每年12%的速度赚取3年$ 162从兴趣”

如何解决这个问题?

回答

1
  1. 下载并安装斯坦福大学NLP集团的Python库stanza

    GitHub上:https://github.com/stanfordnlp/stanza

  2. 与斯坦福CoreNLP 3.7.0,启动服务器:

    命令:java -Xmx4g edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000

    斯坦福CoreNLP 3.7.0:https://stanfordnlp.github.io/CoreNLP/download.html

    (注:确保CLASSPATH包含下载文件夹中的所有罐子)

  3. 问题到Java斯坦福CoreNLP服务器的请求在步骤2中启动:

    from stanza.nlp.corenlp import CoreNLPClient 
    
    client = CoreNLPClient(server='http://localhost:9000', default_annotators=['ssplit', 'tokenize', 'lemma', 'pos', 'ner']) 
    
    annotated = client.annotate("..text to annotate...") 
    
    for sentence in annotated.sentences: 
        print "---" 
        print sentence.tokens 
        print sentence.ner_tags 
    

    我们正在研究具有Python库手柄启动和停止服务器斯坦福CoreNLP 3.8.0。

相关问题