项目作者:刘焕勇
项目地址:
https://github.com/liuhuanyong/ComplexEventExtraction
项目介绍
原始项目名为ComplexEventExtraction,即中文复合事件抽取,包括条件事件、因果事件、顺承事件、反转事件。我个人觉得可以用于识别文本中是否存在逻辑表达,统计文本中的各种逻辑表达的句子数。
事件类型
项目地址https://github.com/liuhuanyong/ComplexEventExtraction 项目介绍很详细,感兴趣的一定要去原项目看一下。
如果我会知识图谱(比如社交网络分析)可视化技能,就能根据分析出的条件、因果、顺承、反转的数据结构,可视化一段文本的知识图谱。图片是刘焕勇别的项目绘制出来的。
1、反转事件图谱
2、条件事件图谱
安装方法
项目地址
https://github.com/liuhuanyong/ComplexEventExtraction
项目介绍很详细,感兴趣的一定要去原项目看一下。
^_^这是大邓封装的库,可以命令行安装
pip3 install https://github.com/thunderhit/eventextraction/archive/master.zip
使用
3.1 主函数
from eventextraction import EventsExtraction
extractor = EventsExtraction()
content = '虽然你做了坏事,但我觉得你是好人。一旦时机成熟,就坚决推行'
datas = extractor.extract_main(content)
print(datas)
运行结果
[{'sent': '虽然你做了坏事,但我觉得你是好人', 'type': 'but', 'tuples': {'pre_wd': '虽然', 'pre_part': '你做了坏事,', 'post_wd': '但', 'post_part ': '我觉得你是好人'}},
{'sent': '一旦时机成熟,就坚决推行', 'type': 'condition', 'tuples': {'pre_wd': '一旦', 'pre_part': '时机成熟,', 'post_wd': '就', 'post_part ': '坚决推行'}}]
3.2 统计
from eventextraction import EventsExtraction
extractor = EventsExtraction()
content = '虽然你做了坏事,但我觉得你是好人。一旦时机成熟,就坚决推行'
datas = extractor.extract_main(content)
print(extractor.stats(datas))
运行结果
{'but': 1, 'condition': 1, 'seq': 0, 'more': 0, 'other': 0}
近期文章