2017-04-21 48 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。

相關問題