关于共指消解

Allennlp 安装和使用问题
allennlp使用
Allen:coreference resolution 共指demo网站
建立有效的共指消解模型 #该项目基于huggingface和allennlp进行了改进,有开源代码。
AllenNLP是由艾伦人工智能研究所开发的用于构建用于自然语言处理的深度学习模型的开源库。它建立在PyTorch之上,旨在为希望轻松构建高质量深度NLP模型的研究人员,工程师,学生等提供支持。它为现代NLP中的通用组件和模型提供了高级抽象和API。它还提供了可扩展的框架,可以轻松地运行和管理NLP实验。
AllenNLP是一个基于PyTorch的NLP研究库,可为开发者提供语言任务中的各种业内最佳训练模型。官网提供了一个很好的入门教程AllenNLP Guide,能够让初学者在30分钟内就了解AllenNLP的使用方法。
https://www.jiqizhixin.com/articles/2019-08-13-3 四种常见NLP框架使用总结(里面有关于allennlp的部分)

AllenNLP 安装和使用

AllenNLP 的python调用方法,github
1、安装指令

pip install allennlp
pip install allennlp-models

2、coreference demo

from allennlp.predictors.predictor import Predictor
# path can be url or local path (pre-downloaded file) 首次下载需一定时间
predictor = Predictor.from_path("https://storage.googleapis.com/allennlp-public-models/coref-spanbert-large-2021.03.10.tar.gz")
text = "Eva and Martha didn't want their friend Jenny to feel lonely so they invited her to the party."
prediction = predictor.predict(document=text)  # get prediction
# Result: {'top_spans': [[0, 0], [0, 2], [2, 2], [6, 6], [6, 8], [13, 13], [15, 15], [17, 18]], 'antecedent_indices': [[0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]], 'predicted_antecedents': [-1, -1, -1, 1, -1, 1, 4, -1], 'document': ['Eva', 'and', 'Martha', 'did', "n't", 'want', 'their', 'friend', 'Jenny', 'to', 'feel', 'lonely', 'so', 'they', 'invited', 'her', 'to', 'the', 'party', '.'], 'clusters': [[[0, 2], [6, 6], [13, 13]], [[6, 8], [15, 15]]]}
print(prediction['clusters'])  # list of clusters (the indices of spaCy tokens) 
# Result: [[[0, 2], [6, 6], [13, 13]], [[6, 8], [15, 15]]]
print(predictor.coref_resolved(text))  # resolved text
# Result: "Eva and Martha didn't want Eva and Martha's friend Jenny to feel lonely so Eva and Martha invited their friend Jenny to the party."

比较重要的一节代码

spacy安装和使用问题(tokenizer)

pip install spacy
import spacy
nlp = spacy.load('en_core_web_sm')  # load the model
text = "Eva and Martha didn't want their friend Jenny to feel lonely so they invited her to the party."
doc = nlp(text)  # get the spaCy Doc (composed of Tokens)
print(list(doc)) # tokens

spacy教程

加载en_core_web_sm模型可能会出现SSL error的问题,可以到官方release下载和当前spacy版本对应的模型,然后利用pip进行安装:

pip show spacy # show the version of spacy
pip install en_core_web_sm-x.x.x.tar.gz # install the model without proxy - method 1
python -m spacy download en_core_web_sm # install the model with proxy - method 2

stanford CoreNLP

CoreNLP Demo
CoreNLP Overview
stanfordNLP Corenlp github
python中stanfordCorenlp使用教程
CoreNLP 客户端调用api

NeuralCoref Demo:Coreference Resolution in spaCy with Neural Networks
在这里插入图片描述
在评价测试集中,一篇论文中用到的方法,但是还没有测试过
Lexical Chains meet Word Embeddings in Document-level Statistical
github地址

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值