Abstract Meaning Representation
Abstract Meaning Representation
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 # Support en: English, zh: Chinese, ja: Japanese, mul: Multilingual HanLP = HanLPClient('https://www.hanlp.com/api', auth=None, language='mul')
Parse
HanLP.abstract_meaning_representation('男孩希望女孩相信他。')
The return value is the Meaning Representation (MR) format of the corresponding AMR graph for each sentence. Note that the term "boy" has two anchors, corresponding to "boy" and "he," respectively. In other words, the MR format actually includes the result of coreference resolution.
Visualization
Set visualization='svg'
for visualization。
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)
Native APIs
Please refer to docs.