Skip to content
Snippets Groups Projects
Commit 42db5151 authored by Aurélien Lamercerie's avatar Aurélien Lamercerie
Browse files

Main method parsing LN sentences to generate AMR graphs

parent c13800c9
No related branches found
No related tags found
No related merge requests found
Showing
with 603 additions and 228 deletions
...@@ -3,3 +3,4 @@ __pycache__ ...@@ -3,3 +3,4 @@ __pycache__
*.todo *.todo
*.ttl.tbc *.ttl.tbc
*catalog-v001.xml *catalog-v001.xml
venv/*
...@@ -5,11 +5,48 @@ AMR Batch is a python library to parse natural language sentences in order to bu ...@@ -5,11 +5,48 @@ AMR Batch is a python library to parse natural language sentences in order to bu
This library is currently under development, and therefore in unstable state. This library is currently under development, and therefore in unstable state.
## Environment Setup
The python code has been tested under Python 3.7 and Linux Manjaro, but should be run on most common systems (Linux, Windows, Mac). ### Installation
This project was developp under Python 3.7 and Manjaro Linux system, but should be run on most common systems (Linux, Windows, Mac).
All dependencies are listed in requirements.txt. All dependencies are listed in requirements.txt.
First, it is recommended to use a [virtual environment](https://docs.python.org/fr/3/tutorial/venv.html).
For example, 'venv' can be create and use with the following commands:
python3 -m venv venv
source venv/bin/activate
The necessary libraries are defined in the file 'requirements.txt', and can be installed in the virtual environment using package installer as pip:
pip install -r requirements.txt
See specific installation instructions about amrlib
([amrlib-install](https://amrlib.readthedocs.io/en/latest/install/)).
So, it is necessary to install the models used by amrlib library.
Models can be downloaded from
[amrlib-models](https://github.com/bjascob/amrlib-models).
These files need to be extracted and reside in a directory. The path to this directory can then be passed as a parameter of the main method. The model STOG 'xfm_bart_large-v0_1_0' (from source dir 'amrbatch/models/') is used by default if no model is given.
## Usage ## Usage
The script **test_amrbatch_main.py** (test directory) gives an example of using the library. The script **test_amrbatch_main.py** (test directory) gives an example of using the library.
# References
-------------------------------------------------------------------------------
[amrlib](https://github.com/bjascob/amrlib):
A python library that makes AMR parsing, generation and visualization simple.
[amr-ld](https://github.com/BMKEG/amr-ld/):
A Python library for mapping AMRs to linked data formats (such as RDF and JSON-LD).
Burns, G.A., Hermjakob, U., Ambite, J.L. (2016).
Abstract Meaning Representations as Linked Data.
In: , et al. The Semantic Web – ISWC 2016. ISWC 2016.
Lecture Notes in Computer Science(), vol 9982. Springer, Cham.
https://doi.org/10.1007/978-3-319-46547-0_2
.project
.pydevproject
.history
.settings
*.pyc
out.rdf
.DS_Store
[
{
"root": {
"domain": {
"op1": {
"@id": "g",
"@type": "gene",
"name": {
"@id": "n",
"@type": "name",
"op1": "KRAS"
}
},
"@id": "a",
"@type": "and",
"op2": {
"@id": "g2",
"@type": "gene",
"name": {
"@id": "n2",
"@type": "name",
"op1": "PIK3CA"
}
},
"op3": {
"@id": "g3",
"@type": "gene",
"name": {
"@id": "n3",
"@type": "name",
"op1": "BRAF"
}
}
},
"@id": "o",
"@type": "oncogene",
"location": {
"@id": "c",
"@type": "cancer"
}
},
"has-date": "2014-08-13T14:22:25",
"@context": {
"and": "http://amr.isi.edu/rdf/core-amr#and",
"oncogene": "http://amr.isi.edu/rdf/core-amr#oncogene",
"kill-01": "https://verbs.colorado.edu/propbank#kill-01",
"name": "http://amr.isi.edu/rdf/core-amr#name",
"cancer": "http://amr.isi.edu/rdf/core-amr#cancer",
"most": "http://amr.isi.edu/rdf/core-amr#most",
"@base": "http://amr.isi.edu/amr_data/bio.ras_0001_1#",
"human": "http://amr.isi.edu/rdf/core-amr#human",
"gene": "http://amr.isi.edu/entity-types#gene",
"root": "http://amr.isi.edu/rdf/core-amr#root",
"frequent": "http://amr.isi.edu/rdf/core-amr#frequent",
"mutate-01": "https://verbs.colorado.edu/propbank#mutate-01"
},
"@id": "bio.ras_0001_1",
"@type": "http://amr.isi.edu/rdf/core-amr#AMR",
"has-sentence": "The most frequently mutated oncogenes in the deadliest cancers responsible for human mortality are KRAS , PIK3CA and BRAF ."
}
]
\ No newline at end of file
<http://amr.isi.edu/amr_data/bio.ras_0001_1#k> <http://amr.isi.edu/rdf/core-amr#ARG1> <http://amr.isi.edu/amr_data/bio.ras_0001_1#h> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#root01> <http://amr.isi.edu/rdf/core-amr#has-sentence> "The most frequently mutated oncogenes in the deadliest cancers responsible for human mortality are KRAS , PIK3CA and BRAF ." .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#f> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#frequent> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#n> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#name> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#g2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/entity-types#gene> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#a> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#and> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#o> <http://amr.isi.edu/rdf/core-amr#location> <http://amr.isi.edu/amr_data/bio.ras_0001_1#c> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#root01> <http://amr.isi.edu/rdf/core-amr#has-id> "bio.ras_0001_1" .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#m> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#most> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#f> <http://amr.isi.edu/rdf/core-amr#degree> <http://amr.isi.edu/amr_data/bio.ras_0001_1#m3> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#n2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#name> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#n3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#name> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#root01> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#AMR> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#a> <http://amr.isi.edu/rdf/core-amr#op3> <http://amr.isi.edu/amr_data/bio.ras_0001_1#g3> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#k> <http://amr.isi.edu/rdf/core-amr#ARG0> <http://amr.isi.edu/amr_data/bio.ras_0001_1#c> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#a> <http://amr.isi.edu/rdf/core-amr#op1> <http://amr.isi.edu/amr_data/bio.ras_0001_1#g> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#n2> <http://amr.isi.edu/rdf/core-amr#op1> "PIK3CA" .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#g> <http://amr.isi.edu/rdf/core-amr#name> <http://amr.isi.edu/amr_data/bio.ras_0001_1#n> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#m3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#most> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#o> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#oncogene> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#m2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://verbs.colorado.edu/propbank#mutate-01> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#k> <http://amr.isi.edu/rdf/core-amr#degree> <http://amr.isi.edu/amr_data/bio.ras_0001_1#m> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#m2> <http://amr.isi.edu/rdf/core-amr#frequency> <http://amr.isi.edu/amr_data/bio.ras_0001_1#f> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#k> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://verbs.colorado.edu/propbank#kill-01> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#h> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#human> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#g3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/entity-types#gene> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#root01> <http://amr.isi.edu/rdf/core-amr#root> <http://amr.isi.edu/amr_data/bio.ras_0001_1#o> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#c> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#cancer> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#n3> <http://amr.isi.edu/rdf/core-amr#op1> "BRAF" .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#o> <http://amr.isi.edu/rdf/core-amr#TOP> <http://amr.isi.edu/amr_data/bio.ras_0001_1#o> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#o> <http://amr.isi.edu/rdf/core-amr#domain> <http://amr.isi.edu/amr_data/bio.ras_0001_1#a> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#g2> <http://amr.isi.edu/rdf/core-amr#name> <http://amr.isi.edu/amr_data/bio.ras_0001_1#n2> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#g> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/entity-types#gene> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#n> <http://amr.isi.edu/rdf/core-amr#op1> "KRAS" .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#m2> <http://amr.isi.edu/rdf/core-amr#ARG1> <http://amr.isi.edu/amr_data/bio.ras_0001_1#o> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#g3> <http://amr.isi.edu/rdf/core-amr#name> <http://amr.isi.edu/amr_data/bio.ras_0001_1#n3> .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#root01> <http://amr.isi.edu/rdf/core-amr#has-date> "2014-08-13T14:22:25" .
<http://amr.isi.edu/amr_data/bio.ras_0001_1#a> <http://amr.isi.edu/rdf/core-amr#op2> <http://amr.isi.edu/amr_data/bio.ras_0001_1#g2> .
# ::id bio.ras_0001_1 ::date 2014-08-13T14:22:25
# ::snt The most frequently mutated oncogenes in the deadliest cancers responsible for human mortality are KRAS , PIK3CA and BRAF .
(o / oncogene
:domain (a / and
:op1 (g / gene :name (n / name :op1 "KRAS"))
:op2 (g2 / gene :name (n2 / name :op1 "PIK3CA"))
:op3 (g3 / gene :name (n3 / name :op1 "BRAF")))
:location (c / cancer
:ARG0-of (k / kill-01
:ARG1 (h / human)
:degree (m / most)))
:ARG1-of (m2 / mutate-01
:frequency (f / frequent
:degree (m3 / most))))
@prefix ns1: <http://amr.isi.edu/rdf/core-amr#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#root01> a ns1:AMR ;
ns1:has-date "2015-02-27T00:14:25" ;
ns1:has-id "pmid_1177_7939.32" ;
ns1:has-sentence "In previous studies, we showed that Sos-1, E3b1, and Eps8 could form a trimeric complex in vivo upon concomitant overexpression of the three proteins." ;
ns1:root <http://amr.isi.edu/amr_data/pmid_1177_7939.32#s> .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#c> a ns1:concomitant .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#e2> a <http://amr.isi.edu/entity-types#enzyme> ;
ns1:name <http://amr.isi.edu/amr_data/pmid_1177_7939.32#n3> .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#f> a <https://verbs.colorado.edu/propbank#form-01> ;
ns1:ARG0 <http://amr.isi.edu/amr_data/pmid_1177_7939.32#a> ;
ns1:ARG1 <http://amr.isi.edu/amr_data/pmid_1177_7939.32#m> ;
ns1:condition <http://amr.isi.edu/amr_data/pmid_1177_7939.32#o> ;
ns1:manner <http://amr.isi.edu/amr_data/pmid_1177_7939.32#i> ;
ns1:mod <http://amr.isi.edu/amr_data/pmid_1177_7939.32#p> .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#i> a ns1:in-vivo .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#m> a <http://amr.isi.edu/entity-types#macro-molecular-complex> ;
ns1:mod <http://amr.isi.edu/amr_data/pmid_1177_7939.32#t> .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#n> a ns1:name ;
ns1:op1 "Sos-1" .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#n2> a ns1:name ;
ns1:op1 "E3b1" .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#n3> a ns1:name ;
ns1:op1 "Eps8" .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#o> a <https://verbs.colorado.edu/propbank#overexpress-00> ;
ns1:ARG2 <http://amr.isi.edu/amr_data/pmid_1177_7939.32#a> ;
ns1:manner <http://amr.isi.edu/amr_data/pmid_1177_7939.32#c> .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#p> a ns1:possible .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#p2> a <http://amr.isi.edu/entity-types#protein> ;
ns1:name <http://amr.isi.edu/amr_data/pmid_1177_7939.32#n> .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#p3> a <http://amr.isi.edu/entity-types#protein> ;
ns1:name <http://amr.isi.edu/amr_data/pmid_1177_7939.32#n2> .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#p5> a ns1:previous .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#s2> a ns1:study ;
ns1:time <http://amr.isi.edu/amr_data/pmid_1177_7939.32#p5> .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#t> a ns1:trimeric .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#w> a ns1:we .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#a> a ns1:and ;
ns1:op1 <http://amr.isi.edu/amr_data/pmid_1177_7939.32#p2> ;
ns1:op2 <http://amr.isi.edu/amr_data/pmid_1177_7939.32#p3> ;
ns1:op3 <http://amr.isi.edu/amr_data/pmid_1177_7939.32#e2> .
<http://amr.isi.edu/amr_data/pmid_1177_7939.32#s> a <https://verbs.colorado.edu/propbank#show-01> ;
ns1:ARG0 <http://amr.isi.edu/amr_data/pmid_1177_7939.32#w> ;
ns1:ARG1 <http://amr.isi.edu/amr_data/pmid_1177_7939.32#f> ;
ns1:TOP <http://amr.isi.edu/amr_data/pmid_1177_7939.32#s> ;
ns1:medium <http://amr.isi.edu/amr_data/pmid_1177_7939.32#s2> .
# ::id pmid_1177_7939.32 ::date 2015-02-27T00:14:25 ::authors mrizea
# ::snt In previous studies, we showed that Sos-1, E3b1, and Eps8 could form a trimeric complex in vivo upon concomitant overexpression of the three proteins.
# ::note Sentence+ loaded by script SntLoaderUlf1.7.pl
# ::save-date Wed Apr 1, 2015 ::user bbadarau ::file pmid_1177_7939_32.txt
(s / show-01
:ARG0 (w / we)
:ARG1 (f / form-01
:ARG0 (a / and
:op1 (p2 / protein :name (n / name :op1 "Sos-1"))
:op2 (p3 / protein :name (n2 / name :op1 "E3b1"))
:op3 (e2 / enzyme :name (n3 / name :op1 "Eps8")))
:ARG1 (m / macro-molecular-complex
:mod (t / trimeric))
:mod (p / possible)
:manner (i / in-vivo)
:condition (o / overexpress-00
:ARG2 a
:manner (c / concomitant)))
:medium (s2 / study
:time (p5 / previous)))
\ No newline at end of file
<http://amr.isi.edu/amr_data/test-01#root01> <http://amr.isi.edu/rdf/core-amr#has-sentence> "The sun is a star." .
<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-EntityType" .
<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> .
<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Concept" .
<http://amr.isi.edu/amr_data/test-01#s> <http://amr.isi.edu/rdf/amr-terms#domain> <http://amr.isi.edu/amr_data/test-01#s2> .
<http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Role> .
<http://amr.isi.edu/entity-types#star> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#NamedEntity> .
<http://amr.isi.edu/amr_data/test-01#root01> <http://amr.isi.edu/rdf/core-amr#has-id> "test-01" .
<http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Role" .
<http://amr.isi.edu/rdf/amr-terms#domain> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Role> .
<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> .
<http://amr.isi.edu/amr_data/test-01#s> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/entity-types#star> .
<http://amr.isi.edu/amr_data/test-01#root01> <http://amr.isi.edu/rdf/core-amr#root> <http://amr.isi.edu/amr_data/test-01#s> .
<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Frame" .
<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> .
<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> .
<http://amr.isi.edu/amr_data/test-01#root01> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#AMR> .
<http://amr.isi.edu/amr_data/test-01#s2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/amr-terms#sun> .
<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Term" .
<http://amr.isi.edu/rdf/amr-terms#sun> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> .
<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Role" .
# ::id test-01
# ::snt The sun is a star.
(s / star
:domain (s2 / sun))
\ No newline at end of file
<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Term" .
<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> .
<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> .
<http://amr.isi.edu/amr_data/test-02#root01> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#AMR> .
<http://amr.isi.edu/amr_data/test-02#p> <http://www.w3.org/2000/01/rdf-schema#label> "Earth" .
<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Concept" .
<http://amr.isi.edu/amr_data/test-02#root01> <http://amr.isi.edu/rdf/core-amr#root> <http://amr.isi.edu/amr_data/test-02#p> .
<http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Role> .
<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Role" .
<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> .
<http://amr.isi.edu/entity-types#planet> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#NamedEntity> .
<http://amr.isi.edu/amr_data/test-02#p> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/entity-types#planet> .
<http://amr.isi.edu/amr_data/test-02#root01> <http://amr.isi.edu/rdf/core-amr#has-id> "test-02" .
<http://amr.isi.edu/amr_data/test-02#root01> <http://amr.isi.edu/rdf/core-amr#has-sentence> "Earth is a planet." .
<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Frame" .
<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> .
<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-EntityType" .
<http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Role" .
# ::id test-1 # ::id test-02
# ::snt The sun is a star.
(s / star
:domain (s2 / sun))
# ::id test-2
# ::snt Earth is a planet. # ::snt Earth is a planet.
(p / planet (p / planet
:domain p :domain p
:name (n / name :name (n / name
:op1 "Earth")) :op1 "Earth"))
\ No newline at end of file
#!/usr/bin/python3.10
# -*-coding:Utf-8 -*
#==============================================================================
# AMR Batch: Filepath Manager
#------------------------------------------------------------------------------
# Handler to manage file paths.
#==============================================================================
import sys, os, glob
import shutil
# Reference Suffix
TEXT_SUFFIX = ".txt"
SENTENCE_SUFFIX = ".sentence.txt"
PENMAN_AMR_GRAPH_SUFFIX = ".stog.amr.penman"
DOT_AMR_GRAPH_SUFFIX = ".stog.amr.dot"
PNG_AMR_GRAPH_SUFFIX = ".stog.amr.png"
AMR_RDF_SUFFIX = ".stog.amr.nt"
AMR_TTL_SUFFIX = ".stog.amr.ttl"
# AMRLD Parameters
LIB_PATH = os.path.dirname(os.path.abspath(__file__)) + '/'
AMRLD_DIR = f'{LIB_PATH}amrld/'
WK_DIR = 'wk/'
AMRLD_WORKDIR = AMRLD_DIR + WK_DIR
#==============================================================================
# Class
#==============================================================================
class FilepathManager:
""" Class to handle filepaths.
"""
#--------------------------------------------------------------------------
# Constructor
#--------------------------------------------------------------------------
def __init__(self, input_filepath, output_dirpath=None):
self.base_reference = os.path.splitext(os.path.basename(input_filepath))[0]
self.input_filepath = input_filepath
self.input_dirpath = os.path.dirname(input_filepath)
if output_dirpath is None:
self.output_dirpath = self._input_dirpath
else:
self.output_dirpath = output_dirpath
#--------------------------------------------------------------------------
# Filepath Accessors
#--------------------------------------------------------------------------
def get_workdata_output_dirpath(self, data_ref):
return f'{self.output_dirpath}{data_ref}/'
def get_sentence_output_filepath(self):
return f'{self.output_dirpath}{self.base_reference}{SENTENCE_SUFFIX}'
def get_data_output_filepath(self, data):
return f'{self.output_dirpath}{data["output_data_dir"]}'
def get_penman_amr_graph_output_filepath(self, data):
dirpath = self.get_data_output_filepath(data)
filename = f'{data["data_ref"]}{PENMAN_AMR_GRAPH_SUFFIX}'
return f'{dirpath}{filename}'
def get_dot_amr_graph_output_filepath(self, data):
dirpath = self.get_data_output_filepath(data)
filename = f'{data["data_ref"]}{DOT_AMR_GRAPH_SUFFIX}'
return f'{dirpath}{filename}'
def get_png_amr_graph_output_filepath(self, data):
dirpath = self.get_data_output_filepath(data)
filename = f'{data["data_ref"]}{PNG_AMR_GRAPH_SUFFIX}'
return f'{dirpath}{filename}'
def get_amr_rdf_triple_output_filepath(self, data):
dirpath = self.get_data_output_filepath(data)
filename = f'{data["data_ref"]}{AMR_RDF_SUFFIX}'
return f'{dirpath}{filename}'
def get_amr_rdf_turtle_output_filepath(self, data):
dirpath = self.get_data_output_filepath(data)
filename = f'{data["data_ref"]}{AMR_TTL_SUFFIX}'
return f'{dirpath}{filename}'
def get_amr_graph_amrld_filepath(self, data):
dirpath = f'{AMRLD_WORKDIR}'
filename = f'{data["data_ref"]}{PENMAN_AMR_GRAPH_SUFFIX}'
return f'{dirpath}{filename}'
def get_amr_rdf_amrld_filepath(self, data):
dirpath = f'{AMRLD_WORKDIR}'
filename = f'{data["data_ref"]}{AMR_RDF_SUFFIX}'
return f'{dirpath}{filename}'
def get_amr_graph_wk_filepath(self, data):
dirpath = f'{WK_DIR}'
filename = f'{data["data_ref"]}{PENMAN_AMR_GRAPH_SUFFIX}'
return f'{dirpath}{filename}'
def get_amr_rdf_wk_filepath(self, data):
dirpath = f'{WK_DIR}'
filename = f'{data["data_ref"]}{AMR_RDF_SUFFIX}'
return f'{dirpath}{filename}'
[loggers]
keys=root
[handlers]
keys=consoleSimpleHandler,consoleWarningHandler,fileHandler
[formatters]
keys=simpleFormat,warningFormat,fileFormat
[logger_root]
level=DEBUG
handlers=consoleWarningHandler,consoleSimpleHandler,fileHandler
[handler_consoleSimpleHandler]
class=StreamHandler
level=INFO
formatter=simpleFormat
args=(sys.stdout,)
[handler_consoleWarningHandler]
class=StreamHandler
level=WARNING
formatter=warningFormat
args=(sys.stdout,)
[handler_fileHandler]
class=FileHandler
level=DEBUG
formatter=fileFormat
args=('amrbatch.log', 'w+', 'utf8')
[formatter_simpleFormat]
format=%(message)s
[formatter_warningFormat]
format=%(asctime)s - %(levelname)s (%(name)s, %(lineno)d)
[formatter_fileFormat]
format= - %(levelname)s - %(message)s
...@@ -8,39 +8,278 @@ ...@@ -8,39 +8,278 @@
#============================================================================== #==============================================================================
import sys, os, glob import sys, os, glob
import shutil import shutil, re
import subprocess
import amrlib
from rdflib import Graph from rdflib import Graph
import traceback
import logging.config
from amrlib.graph_processing.amr_plot import AMRPlot
from filepath_manager import FilepathManager
# -- Config File Path
LIB_PATH = os.path.dirname(os.path.abspath(__file__)) + '/'
LOGGING_CONF_FILE_PATH = f'{LIB_PATH}logging.conf'
CONFIG_FILE_PATH = f'{LIB_PATH}config.xml'
# AMRLD Parameters
AMRLD_DIR = f'{LIB_PATH}amrld/'
AMRLD_WORKDIR = f'{AMRLD_DIR}wk/'
# -- Logging
logging.config.fileConfig(LOGGING_CONF_FILE_PATH, disable_existing_loggers=True)
logger = logging.getLogger('root')
#==============================================================================
# Functions to manage in-process data
#==============================================================================
def is_valid_sentence(sentence):
""" True if the sentence is correct.
"""
is_empty = ((sentence == "") | (sentence == "\n"))
lang_mark_re = re.compile("\([a-z]+\)(.)*")
is_language_mark = lang_mark_re.match(sentence) is not None
return not (is_empty | is_language_mark)
def clean_sentence(sentence):
""" Sentence cleanup as needed """
sentence = re.sub("(\.)*\\n", "", sentence)
return sentence
def define_new_data(base_ref, number, sentence):
number_str = str(number).rjust(2,"0")
data_ref = base_ref + "-" + number_str
output_data_dir = data_ref + "/"
id_line_str = "# ::id " + data_ref + "\n"
sentence = clean_sentence(sentence)
sentence += "."
new_data = {
"base_ref" : data_ref,
"number" : number,
"output_data_dir" : output_data_dir,
"data_ref" : data_ref,
"id_line_str" : id_line_str,
"sentence" : sentence,
"graph" : ""
}
return new_data
def get_amr_graph_list(workdata_list):
amr_graph_list = []
for workdata in workdata_list:
amr_graph_list.append(workdata['graph'])
return amr_graph_list
#==============================================================================
# Preparation Steps
#==============================================================================
def __prepare_workdata(filepath_manager):
logger.info('-- Reading input files to recover a list of sentences')
input_filepath = filepath_manager.input_filepath
base_reference = filepath_manager.base_reference
workdata_list = list()
sentence_number = 0
with open(input_filepath, "r") as reading_file: # r = read
for line in reading_file.readlines():
sentences = line.split(". ")
for sentence in sentences:
if is_valid_sentence(sentence):
sentence_number += 1
new_data = define_new_data(base_reference, sentence_number, sentence)
workdata_list.append(new_data)
logger.debug(f' *** sentence {sentence_number} *** \n{new_data}')
logger.info(f'----- number of sentences: {len(workdata_list)}')
return workdata_list
def __build_output_dir_tree(filepath_manager, workdata_list):
base_output_dirpath = filepath_manager.output_dirpath
logger.debug(f'-- Making output directory tree ({base_output_dirpath})')
os.makedirs(base_output_dirpath, exist_ok=True)
for data in workdata_list:
output_dir = filepath_manager.get_workdata_output_dirpath(data["output_data_dir"])
os.makedirs(output_dir, exist_ok=True)
def __generate_sentence_file(filepath_manager, workdata_list):
sentence_filepath = filepath_manager.get_sentence_output_filepath()
logger.debug(f"-- Generating sentence file ")
with open(sentence_filepath, "w") as writing_file: # w = write
first = True
for workdata in workdata_list:
if not first: writing_file.write("\n")
writing_file.write(workdata["sentence"])
first = False
#==============================================================================
# Conversion Steps
#==============================================================================
def __generate_penman_amr_graph(filepath_manager, data):
""" AMR graph generation in penman format """
graph = data["graph"]
output_filepath = filepath_manager.get_penman_amr_graph_output_filepath(data)
logger.debug(f"----- AMR Graph file (penman): {os.path.basename(output_filepath)}")
with open(output_filepath, "w") as writing_file: # w = write
writing_file.write(data["id_line_str"])
writing_file.write(graph)
def __generate_dot_amr_graph(filepath_manager, data):
""" AMR graph generation in dot and png format """
graph = data["graph"]
try:
# -- generating dot/png files using AMRLib and GraphViz
dot_filename = filepath_manager.get_dot_amr_graph_output_filepath(data)
format = 'png'
logger.debug(f'----- AMR Graph file (dot): {os.path.basename(dot_filename)}')
plot = AMRPlot(dot_filename, format)
plot.build_from_graph(graph)
plot.graph.render()
render_fn = dot_filename + '.' + format # -- renaming PNG file
good_png_fn = filepath_manager.get_png_amr_graph_output_filepath(data)
logger.debug(f'----- AMR Graph file (png): {{os.path.basename(good_png_fn)}}')
os.rename(render_fn, good_png_fn)
except:
logger.warning('Exception when trying to plot')
traceback.print_exc()
def __convert_sentences_to_graphs(amr_model, workdata_list):
""" Converting text sentences to AMR graphs """
logger.info("-- Loading AMR model")
stog = amrlib.load_stog_model(model_dir=amr_model)
logger.info("-- Converting sentences to AMR graphs")
wd_number = 0
for data in workdata_list:
wd_number += 1
stog_result = stog.parse_sents([data["sentence"]])
logger.info(f'----- Sentence {wd_number} successfully processed')
logger.debug(stog_result)
data["graph"] = stog_result[0]
logger.info(f'----- Total processed graph number: {wd_number}')
return workdata_list
def __generate_amr_graph_files(filepath_manager, workdata_list):
logger.info("-- Generating AMR graph files")
for data in workdata_list:
__generate_penman_amr_graph(filepath_manager, data)
__generate_dot_amr_graph(filepath_manager, data)
#============================================================================== #==============================================================================
# Steps # Serialization Steps
#============================================================================== #==============================================================================
# TODO def __serialize_amr_graph_to_rdf_triple(filepath_manager, data):
""" Serialize AMR graph to AMR-RDF triple """
# -- Filepath
input_file = filepath_manager.get_penman_amr_graph_output_filepath(data)
input_amrld_file = filepath_manager.get_amr_graph_amrld_filepath(data)
output_amrld_file = filepath_manager.get_amr_rdf_amrld_filepath(data)
input_wk_file = filepath_manager.get_amr_graph_wk_filepath(data)
output_wk_file = filepath_manager.get_amr_rdf_wk_filepath(data)
amr_triple_file = filepath_manager.get_amr_rdf_triple_output_filepath(data)
# -- AMR-LD processing
amrld_process = ["python3", "amr_to_rdf.py",
"-i", input_wk_file,
"-o", output_wk_file]
if (os.path.isfile(input_file)):
logger.info("-- Serialize AMR graphs to RDF using amr-ld library")
logger.debug(f'----- penman filepath: {input_file}')
logger.debug(f'----- AMRLD filepath: {input_amrld_file}')
shutil.copyfile(input_file, input_amrld_file)
current_dirpath = os.getcwd()
os.chdir(AMRLD_DIR)
subprocess.run(amrld_process)
os.chdir(current_dirpath)
# -- Copy result
if (os.path.isfile(output_amrld_file)):
logger.info(f'-- Generating AMR RDF file (triple): {os.path.basename(amr_triple_file)}')
shutil.copyfile(output_amrld_file, amr_triple_file)
def __convert_rdf_triple_to_rdf_turtle(filepath_manager, data):
""" Converting AMR-RDF triple to AMR-RDF turtle """
# -- Filepath
amr_triple_file = filepath_manager.get_amr_rdf_triple_output_filepath(data)
amr_turtle_file = filepath_manager.get_amr_rdf_turtle_output_filepath(data)
# -- Conversion
if (os.path.isfile(amr_triple_file)):
logger.info(f'-- Generating AMR RDF file (turtle): {os.path.basename(amr_turtle_file)}')
g = Graph()
g.parse(amr_triple_file)
g.serialize(destination=amr_turtle_file, format='turtle')
def __convert_amr_graphs_to_rdf(filepath_manager, data_list):
""" Converting AMR graphs to AMR-RDF """
for data in data_list:
__serialize_amr_graph_to_rdf_triple(filepath_manager, data)
__convert_rdf_triple_to_rdf_turtle(filepath_manager, data)
#============================================================================== #==============================================================================
# AMR Main Methods # Main Method(s)
#============================================================================== #==============================================================================
def parse_sentences_from_file(input_file_path, def parse_sentences_from_file(input_filepath,
output_penman_file_path=None, amr_model_path,
technical_dir_path=None): output_dirpath=None,
amrld_serialization=False):
""" """
Method to parse an input file containing natural language sentences and Method to parse an input file containing natural language sentences and
construct the corresponding AMR graphs (and their RDF serializations if required). construct the corresponding AMR graphs (and their RDF serializations if required).
The method returns an AMR graph string in PENMAN format. AMR graphs are also The method returns an AMR graph string in PENMAN format. AMR graphs are also
serialized in RDF turtle format using the AMR-LD library if requested serialized in RDF turtle format using the AMR-LD library if required
(by defining output_turtle_file_path as a parameter). (by defining turtle_output_file_path as parameter).
Parameters Parameters
---------- ----------
input_file_path: a path to a text file. input_filepath: a path to a text file.
output_penman_file_path: a file path where the output graphs is written in PENMAN format if defined (the function still outputs the string). output_dirpath: a directory path where the output data are written if defined (the function still outputs the string).
output_turtle_file_path: a file path where the output AMRLD representation is written in TURTLE format if defined. turtle_output_file_path: a file path where the output AMRLD representation is written in TURTLE format if defined.
technical_dir_path: a dir path where some technical and log files are written if defined. technical_dir_path: a dir path where some technical and log files are written if defined.
Returns Returns
...@@ -49,7 +288,35 @@ def parse_sentences_from_file(input_file_path, ...@@ -49,7 +288,35 @@ def parse_sentences_from_file(input_file_path,
""" """
pass logger.info('[AMR Batch] NL Document Parsing')
# -- Prepare the sentences to be converted
logger.info('\n === Preparation === ')
filepath_manager = FilepathManager(input_filepath, output_dirpath)
logger.info(f'-- base reference: {filepath_manager.base_reference}')
logger.info(f'-- input filepath: {filepath_manager.input_filepath}')
logger.info(f'-- output dirpath: {filepath_manager.output_dirpath}')
assert os.path.exists(input_filepath), f'input file does not exists ({input_filepath})'
workdata_list = __prepare_workdata(filepath_manager)
__build_output_dir_tree(filepath_manager, workdata_list)
__generate_sentence_file(filepath_manager, workdata_list)
# -- Convert sentences to graphs
logger.info('\n === Text Convert to AMR Graphs === ')
logger.info(f'-- library: amrlib')
logger.debug(f' ({AMRLD_DIR})')
logger.info(f'-- model: {os.path.basename(amr_model_path)}')
logger.debug(f' ({amr_model_path})')
logger.debug(f'-- working directory: {AMRLD_WORKDIR}')
workdata_list = __convert_sentences_to_graphs(amr_model_path, workdata_list)
__generate_amr_graph_files(filepath_manager, workdata_list)
if amrld_serialization==True:
# -- Convert graphs to RDF
logger.info('\n === AMR Graphs Serialization to AMR-RDF Representation === ')
logger.info("-- library: amrlk")
__convert_amr_graphs_to_rdf(filepath_manager, workdata_list)
return '' return get_amr_graph_list(workdata_list)
- INFO - [AMR Batch] NL Document Parsing
- INFO -
=== Preparation ===
- INFO - -- base reference: test
- INFO - -- input filepath: /home/lamenji/Workspace/Tetras/amrbatch/tests/input/test.txt
- INFO - -- output dirpath: /home/lamenji/Workspace/Tetras/amrbatch/tests/output/Test-20230303/
- INFO - -- Reading input files to recover a list of sentences
- DEBUG - *** sentence 1 ***
{'base_ref': 'test-01', 'number': 1, 'output_data_dir': 'test-01/', 'data_ref': 'test-01', 'id_line_str': '# ::id test-01\n', 'sentence': 'The sun is a star.', 'graph': ''}
- DEBUG - *** sentence 2 ***
{'base_ref': 'test-02', 'number': 2, 'output_data_dir': 'test-02/', 'data_ref': 'test-02', 'id_line_str': '# ::id test-02\n', 'sentence': 'Earth is a planet.', 'graph': ''}
- INFO - ----- number of sentences: 2
- DEBUG - -- Making output directory tree (/home/lamenji/Workspace/Tetras/amrbatch/tests/output/Test-20230303/)
- DEBUG - -- Generating sentence file
- INFO -
=== Text Convert to AMR Graphs ===
- INFO - -- library: amrlib
- DEBUG - (/home/lamenji/Workspace/Tetras/amrbatch/amrbatch/amrld/)
- INFO - -- model: model_parse_xfm_bart_large-v0_1_0
- DEBUG - (/home/lamenji/Workspace/Tetras/amrbatch/tests/../amr_models/model_parse_xfm_bart_large-v0_1_0)
- DEBUG - -- working directory: /home/lamenji/Workspace/Tetras/amrbatch/amrbatch/amrld/wk/
- INFO - -- Loading AMR model
- INFO - -- Converting sentences to AMR graphs
- INFO - ----- Sentence 1 successfully processed
- DEBUG - ['# ::snt The sun is a star.\n(s / star\n :domain (s2 / sun))']
- INFO - ----- Sentence 2 successfully processed
- DEBUG - ['# ::snt Earth is a planet.\n(p / planet\n :domain p\n :name (n / name\n :op1 "Earth"))']
- INFO - ----- Total processed graph number: 2
- INFO - -- Generating AMR graph files
- DEBUG - ----- AMR Graph file (penman): test-01.stog.amr.penman
- DEBUG - ----- AMR Graph file (dot): test-01.stog.amr.dot
- DEBUG - ----- AMR Graph file (png): {os.path.basename(good_png_fn)}
- DEBUG - ----- AMR Graph file (penman): test-02.stog.amr.penman
- DEBUG - ----- AMR Graph file (dot): test-02.stog.amr.dot
- DEBUG - ----- AMR Graph file (png): {os.path.basename(good_png_fn)}
- INFO -
=== AMR Graphs Serialization to AMR-RDF Representation ===
- INFO - -- library: amrlk
- INFO - -- Serialize AMR graphs to RDF using amr-ld library
- DEBUG - ----- penman filepath: /home/lamenji/Workspace/Tetras/amrbatch/tests/output/Test-20230303/test-01/test-01.stog.amr.penman
- DEBUG - ----- AMRLD filepath: /home/lamenji/Workspace/Tetras/amrbatch/amrbatch/amrld/wk/test-01.stog.amr.penman
- INFO - -- Generating AMR RDF file (triple): test-01.stog.amr.nt
- INFO - -- Generating AMR RDF file (turtle): test-01.stog.amr.ttl
- INFO - -- Serialize AMR graphs to RDF using amr-ld library
- DEBUG - ----- penman filepath: /home/lamenji/Workspace/Tetras/amrbatch/tests/output/Test-20230303/test-02/test-02.stog.amr.penman
- DEBUG - ----- AMRLD filepath: /home/lamenji/Workspace/Tetras/amrbatch/amrbatch/amrld/wk/test-02.stog.amr.penman
- INFO - -- Generating AMR RDF file (triple): test-02.stog.amr.nt
- INFO - -- Generating AMR RDF file (turtle): test-02.stog.amr.ttl
digraph amr_graph {
rankdir=LR size="12,8"
s [label="s/star" shape=circle]
s2 [label="s2/sun" shape=circle]
s -> s2 [label=":domain"]
}
<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> .
<http://amr.isi.edu/entity-types#star> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#NamedEntity> .
<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> .
<http://amr.isi.edu/rdf/amr-terms#sun> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> .
<http://amr.isi.edu/amr_data/test-01#root01> <http://amr.isi.edu/rdf/core-amr#has-sentence> "The sun is a star." .
<http://amr.isi.edu/amr_data/test-01#s2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/amr-terms#sun> .
<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> .
<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Term" .
<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Concept" .
<http://amr.isi.edu/amr_data/test-01#s> <http://amr.isi.edu/rdf/amr-terms#domain> <http://amr.isi.edu/amr_data/test-01#s2> .
<http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Role> .
<http://amr.isi.edu/rdf/amr-terms#domain> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Role> .
<http://amr.isi.edu/amr_data/test-01#s> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/entity-types#star> .
<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> .
<http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Role" .
<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Frame" .
<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-EntityType" .
<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Role" .
<http://amr.isi.edu/amr_data/test-01#root01> <http://amr.isi.edu/rdf/core-amr#has-id> "test-01" .
<http://amr.isi.edu/amr_data/test-01#root01> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#AMR> .
<http://amr.isi.edu/amr_data/test-01#root01> <http://amr.isi.edu/rdf/core-amr#root> <http://amr.isi.edu/amr_data/test-01#s> .
# ::id test-01
# ::snt The sun is a star.
(s / star
:domain (s2 / sun))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment