斯坦福 NER 未标记日期和时间

Stanford NER not tagging date and time

我在 python 中使用 Stanford NER 标注器。它没有标记日期和时间。而是 returns O 每个字。 我的句子是:

"What sum of money will earn an interest of $ 162 in 3 years at the rate of 12% per annum"

我标记后得到的结果是-

[('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')]

如何解决这个问题?

  1. 下载并安装 Stanford NLP Group 的 Python 库 stanza .

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

  2. 使用 Stanford 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 包含下载文件夹中的所有 jar)

  3. 向步骤 2 中启动的 Java Stanford CoreNLP 服务器发出请求:

    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 库处理启动和停止 Stanford CoreNLP 3.8.0 的服务器。