gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 22:38:27 32 4
gpt4 key购买 nike

我在 python 中使用斯坦福 NER 标记器。它没有标记日期和时间。相反,每个单词都返回 O。我的句子是:

“多少钱才能在 3 年内以年利率 12% 的利率赚取 162 美元的利息”

我标记后得到的结果是-

[('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. 下载并安装斯坦福 NLP Group 的 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 包含下载文件夹中的所有 jar)

  3. 向第 2 步中启动的 Java Stanley 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 库处理斯坦福 CoreNLP 3.8.0 的服务器启动和停止。

关于python - 斯坦福 NER 未标记日期和时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43533701/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com