首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从CoreNLP获取原始句子

从CoreNLP获取原始句子
EN

Stack Overflow用户
提问于 2017-04-16 14:59:35
回答 1查看 576关注 0票数 1

我正在查看我的数据,想把它分成几个句子。我用的是吡咯烷酮。

代码语言:javascript
复制
from pycorenlp import StanfordCoreNLP
nlp = StanfordCoreNLP('http://localhost:9000')
output = nlp.annotate(text, properties={
    'annotators': 'tokenize,ssplit',
    'outputFormat': 'json'
})
for tempsentence in output['sentences']:
     # store important sentences ...

现在我存储了一些对我的应用很重要的句子。其中有些包含“或”,而且CoreNLP似乎改变了这些句子。转换成-LRB和RRB如果我没记错的话。

我是否有可能从CoreNLP那里得到原语(因为我需要稍后再运行一次CoreNLP,如果“现在”消失了,我的数据看起来就不那么自然了,而第二次CoreNLP运行似乎不再识别某些商数了。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-17 02:08:57

  1. 下载并安装节库:https://github.com/stanfordnlp/stanza
  2. 返回的结果将具有原始令牌。

示例:

代码语言:javascript
复制
from stanza.nlp.corenlp import CoreNLPClient
client = CoreNLPClient(server='http://localhost:9000', default_annotators=['ssplit', 'tokenize'])
result = client.annotate("...")
for sentence in result.sentences:
  for token in sentence.tokens:
    print token.word + "\t" + token.originalText
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43438548

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档