Abstract Meaning Representation


Abstract Meaning Representation

38/300
loading

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 keyopen in new window. 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 HanLPClientopen in new window:

      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)

    

本地调用

本地调用方法请参考教程open in new window

多语种支持

其他标准用于外语或多语种,请参考文档open in new window加载相应的外语或多语种模型。

Last update: 7/3/2022, 5:16:22 PM
Contributors: hankcs