图形(例如,AMR)的PENMAN表示法
项目描述
Penman – 一个用于PENMAN图表示法的库
此包用于对编码在PENMAN表示法(例如,AMR)中的图进行建模,例如以下用于“男孩想去”的示例
(w / want-01
:ARG0 (b / boy)
:ARG1 (g / go
:ARG0 b))
Penman包可以作为Python 库 或作为 脚本 使用。
有关JavaScript,请参阅chanind/penman-js。
功能
- 读取和写入PENMAN序列化的图或三元合取
- 读取注释中的元数据(例如,
# ::id 1234
) - 读取表面对齐(例如,
foo~e.1,2
) - 检查和操作图 或 树 结构
- 自定义图形以供写入
- 调整缩进和紧凑性
- 选择新的顶级节点
- 重新排列边
- 重构树形状
- 重新标记节点变量
- 转换 图
- 规范化角色
- 实化和反实化边
- 具体化属性
- 使用额外的
TOP
三元组嵌入树结构
- AMR模型:角色库存和转换
- 检查图模型合规性
- 已测试(但尚未覆盖100%)
- 已记录文档(参见文档)
库使用
>>> import penman
>>> g = penman.decode('(b / bark-01 :ARG0 (d / dog))')
>>> g.triples
[('b', ':instance', 'bark-01'), ('b', ':ARG0', 'd'), ('d', ':instance', 'dog')]
>>> g.edges()
[Edge(source='b', role=':ARG0', target='d')]
>>> print(penman.encode(g, indent=3))
(b / bark-01
:ARG0 (d / dog))
>>> print(penman.encode(g, indent=None))
(b / bark-01 :ARG0 (d / dog))
(更多信息)
脚本使用
$ echo "(w / want-01 :ARG0 (b / boy) :ARG1 (g / go :ARG0 b))" | penman
(w / want-01
:ARG0 (b / boy)
:ARG1 (g / go
:ARG0 b))
$ echo "(w / want-01 :ARG0 (b / boy) :ARG1 (g / go :ARG0 b))" | penman --make-variables="a{i}"
(a0 / want-01
:ARG0 (a1 / boy)
:ARG1 (a2 / go
:ARG0 a1))
(更多信息)
演示
有关API使用的演示,请参阅包含的Jupyter笔记本
-
在GitHub上查看:docs/api-demo.ipynb
-
在mybinder.org上运行:
(注意:运行前清除输出:单元 > 所有输出 > 清除)
PENMAN表示法
有关PENMAN表示法的描述,请参阅文档。此模块略微扩展了原始表示法,以允许无类型节点(例如,(x)
)和匿名关系(例如,(x : (y))
)。它还可以容纳略微不规则的图以及表面对齐。
引用
如果您在工作中使用了Penman,请引用Goodman, 2020。以下为BibTeX
@inproceedings{goodman-2020-penman,
title = "{P}enman: An Open-Source Library and Tool for {AMR} Graphs",
author = "Goodman, Michael Wayne",
booktitle = "Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics: System Demonstrations",
month = jul,
year = "2020",
address = "Online",
publisher = "Association for Computational Linguistics",
url = "https://www.aclweb.org/anthology/2020.acl-demos.35",
pages = "312--319",
abstract = "Abstract Meaning Representation (AMR) (Banarescu et al., 2013) is a framework for semantic dependencies that encodes its rooted and directed acyclic graphs in a format called PENMAN notation. The format is simple enough that users of AMR data often write small scripts or libraries for parsing it into an internal graph representation, but there is enough complexity that these users could benefit from a more sophisticated and well-tested solution. The open-source Python library Penman provides a robust parser, functions for graph inspection and manipulation, and functions for formatting graphs into PENMAN notation. Many functions are also available in a command-line tool, thus extending its utility to non-Python setups.",
}
对于图变换/归一化工作,请使用以下内容
@inproceedings{Goodman:2019,
title = "{AMR} Normalization for Fairer Evaluation",
author = "Goodman, Michael Wayne",
booktitle = "Proceedings of the 33rd Pacific Asia Conference on Language, Information, and Computation",
year = "2019",
pages = "47--56",
address = "Hakodate"
}
免责声明
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源代码分发
penman-1.3.1.tar.gz (101.3 kB 查看哈希值)
构建分发
penman-1.3.1-py3-none-any.whl (43.4 kB 查看哈希值)
关闭
penman-1.3.1.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 584a95947544c197bcee0e8c837f89e6f6fb7998327c0274a4d2beb473d8e135 |
|
MD5 | c46884f7c8c84380506b84aef73bc9e0 |
|
BLAKE2b-256 | f40b7e3738226fb73afc7aa75cc314968bc78d3e3e8dc343296f54c47a2470a9 |