Abstract Meaning Representation
Abstract Meaning Representation
38/300
Introduction
Abstract Meaning Representation captures “who is doing what to whom” in a sentence. Each sentence is represented as a rooted, directed, acyclic graph with labels on edges (relations) and leaves (concepts).
How to Use
Apply for Auth
We are hosting a non-commercial API service and you are welcome to apply for an auth key. An auth key is a password which gives you access to our API and protects our server from being abused.
Create RESTful Client
Create a HanLPClient
:
from hanlp_restful import HanLPClient # Fill in your auth HanLP = HanLPClient('https://www.hanlp.com/api', auth=None, language='mul')
Parse
HanLP.abstract_meaning_representation('男孩希望女孩相信他。')
返回值为每个句子相应的AMR图的Meaning Representation格式。注意上面“男孩”有2个anchor,分别对应“男孩”和“他”。也就是说,MR格式其实包含了指代消解的结果。
可视化
指定visualization='svg'
即可得到矢量图可视化。
from IPython.display import SVG, display def show_svg(g): display(SVG(data=g['svg'])) graph = HanLP.abstract_meaning_representation('The boy wants the girl to believe him.', language='en', visualization='svg')[0] show_svg(graph)
本地调用
本地调用方法请参考教程。
多语种支持
其他标准用于外语或多语种,请参考文档加载相应的外语或多语种模型。