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

Update CTR to deal with reification concept

parent dd07faae
No related branches found
No related tags found
No related merge requests found
......@@ -428,13 +428,74 @@ ns1:Role rdf:type owl:Class ;
:hasRelationName "quant" .
### https://amr.tetras-libre.fr/rdf/schema#role_ARG0
:role_ARG0 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Core_Role ;
:label "ARG0" .
### https://amr.tetras-libre.fr/rdf/schema#role_ARG1
:role_ARG1 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Core_Role ;
:label "ARG1" .
### https://amr.tetras-libre.fr/rdf/schema#role_ARG2
:role_ARG2 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Core_Role ;
:label "ARG2" .
### https://amr.tetras-libre.fr/rdf/schema#role_ARG3
:role_ARG3 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Core_Role ;
:label "ARG3" .
### https://amr.tetras-libre.fr/rdf/schema#role_ARG4
:role_ARG4 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Core_Role ;
:label "ARG4" .
### https://amr.tetras-libre.fr/rdf/schema#role_ARG5
:role_ARG5 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Core_Role ;
:label "ARG5" .
### https://amr.tetras-libre.fr/rdf/schema#role_ARG6
:role_ARG6 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Core_Role ;
:label "ARG6" .
### https://amr.tetras-libre.fr/rdf/schema#role_ARG7
:role_ARG7 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Core_Role ;
:label "ARG7" .
### https://amr.tetras-libre.fr/rdf/schema#role_ARG8
:role_ARG8 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Core_Role ;
:label "ARG8" .
### https://amr.tetras-libre.fr/rdf/schema#role_ARG9
:role_ARG9 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Core_Role ;
:label "ARG9" .
### https://amr.tetras-libre.fr/rdf/schema#role_domain
:role_domain rdf:type owl:Class ;
rdfs:subClassOf :AMR_NonCore_Role ;
:hasRelationName "domain" ;
:toReifyAsConcept "domain" ;
:toReifyWithBaseEdge "ARG0" ;
:toReifyWithHeadEdge "ARG1" .
:toReifyWithHeadEdge "ARG1" ;
:label "domain" .
### https://amr.tetras-libre.fr/rdf/schema#role_have-degree-91
......@@ -450,7 +511,8 @@ ns1:Role rdf:type owl:Class ;
:getPropertyType owl:DataProperty ;
:toReifyAsConcept "manner" ;
:toReifyWithBaseEdge "ARG0" ;
:toReifyWithHeadEdge "ARG1" .
:toReifyWithHeadEdge "ARG1" ;
:label "manner" .
### https://amr.tetras-libre.fr/rdf/schema#role_mod
......@@ -461,57 +523,68 @@ ns1:Role rdf:type owl:Class ;
owl:ObjectProperty ;
:toReifyAsConcept "mod" ;
:toReifyWithBaseEdge "ARG0" ;
:toReifyWithHeadEdge "ARG1" .
:toReifyWithHeadEdge "ARG1" ;
:label "mod" .
### https://amr.tetras-libre.fr/rdf/schema#role_name
:role_name rdf:type owl:Class ;
rdfs:subClassOf :AMR_NonCore_Role .
rdfs:subClassOf :AMR_NonCore_Role ;
:label "name" .
### https://amr.tetras-libre.fr/rdf/schema#role_op1
:role_op1 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Op_Role .
rdfs:subClassOf :AMR_Op_Role ;
:label "op1" .
### https://amr.tetras-libre.fr/rdf/schema#role_op2
:role_op2 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Op_Role .
rdfs:subClassOf :AMR_Op_Role ;
:label "op2" .
### https://amr.tetras-libre.fr/rdf/schema#role_op3
:role_op3 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Op_Role .
rdfs:subClassOf :AMR_Op_Role ;
:label "op3" .
### https://amr.tetras-libre.fr/rdf/schema#role_op4
:role_op4 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Op_Role .
rdfs:subClassOf :AMR_Op_Role ;
:label "op4" .
### https://amr.tetras-libre.fr/rdf/schema#role_op5
:role_op5 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Op_Role .
rdfs:subClassOf :AMR_Op_Role ;
:label "op5" .
### https://amr.tetras-libre.fr/rdf/schema#role_op6
:role_op6 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Op_Role .
rdfs:subClassOf :AMR_Op_Role ;
:label "op6" .
### https://amr.tetras-libre.fr/rdf/schema#role_op7
:role_op7 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Op_Role .
rdfs:subClassOf :AMR_Op_Role ;
:label "op7" .
### https://amr.tetras-libre.fr/rdf/schema#role_op8
:role_op8 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Op_Role .
rdfs:subClassOf :AMR_Op_Role ;
:label "op8" .
### https://amr.tetras-libre.fr/rdf/schema#role_op9
:role_op9 rdf:type owl:Class ;
rdfs:subClassOf :AMR_Op_Role .
rdfs:subClassOf :AMR_Op_Role ;
:label "op9" .
### https://amr.tetras-libre.fr/rdf/schema#role_part
......@@ -527,7 +600,8 @@ ns1:Role rdf:type owl:Class ;
### https://amr.tetras-libre.fr/rdf/schema#role_quant
:role_quant rdf:type owl:Class ;
rdfs:subClassOf :AMR_Specific_Role .
rdfs:subClassOf :AMR_Specific_Role ;
:label "quant" .
#################################################################
......
......@@ -226,69 +226,69 @@ rule_set['reclassify-concept-5'] = {
# ---------------------------------------------
# Reclassification of roles
# Reclassification of roles *** OLD ***
# ---------------------------------------------
rule_set['reclassify-role-1'] = {
'label': "reclassify-role-1",
'comment': "Reclassify role to AMR core role",
'construction': """
# -- New AMR core role
?newRole rdfs:subClassOf amr:AMR_Core_Role ;
amr:label ?roleId ;
amr:fromAmrLk ?r.
""",
'clause': """
# -- Identify core role
?r a ns1:FrameRole.
""",
'binding':"""
# -- Label
BIND (strafter(str(?r), '#') AS ?rLabel1)
BIND (strafter(str(?r), str(ns1:)) AS ?rLabel2)
BIND (IF (STRLEN(?rLabel1) > 0, ?rLabel1, ?rLabel2) AS ?rLabel)
# -- Id
BIND (strbefore(?rLabel, '.') AS ?rolesetId)
BIND (strafter(?rLabel, '.') AS ?roleId)
# -- New role
BIND (CONCAT(str(amr:), 'role') AS ?n1).
BIND (CONCAT(?n1, '_', ?roleId) AS ?n2).
BIND (uri(?n2) AS ?newRole).
"""
}
rule_set['reclassify-role-2'] = {
'label': "reclassify-rolet-2",
'comment': "Reclassify role to AMR non-core role",
'construction': """
# -- New AMR non core role
?newRole rdfs:subClassOf amr:AMR_NonCore_Role ;
amr:label ?rLabel ;
amr:fromAmrLk ?r.
""",
'clause': """
# -- Identify non core role
?r a ns3:Role.
FILTER ( ?r != ns1:FrameRole ).
# rule_set['reclassify-role-1'] = {
# 'label': "reclassify-role-1",
# 'comment': "Reclassify role to AMR core role",
# 'construction': """
# # -- New AMR core role
# ?newRole rdfs:subClassOf amr:AMR_Core_Role ;
# amr:label ?roleId ;
# amr:fromAmrLk ?r.
# """,
# 'clause': """
# # -- Identify core role
# ?r a ns1:FrameRole.
# """,
# 'binding':"""
# # -- Label
# BIND (strafter(str(?r), '#') AS ?rLabel1)
# BIND (strafter(str(?r), str(ns1:)) AS ?rLabel2)
# BIND (IF (STRLEN(?rLabel1) > 0, ?rLabel1, ?rLabel2) AS ?rLabel)
# # -- Id
# BIND (strbefore(?rLabel, '.') AS ?rolesetId)
# BIND (strafter(?rLabel, '.') AS ?roleId)
# # -- New role
# BIND (CONCAT(str(amr:), 'role') AS ?n1).
# BIND (CONCAT(?n1, '_', ?roleId) AS ?n2).
# BIND (uri(?n2) AS ?newRole).
# """
# }
# -- Filter core role
FILTER NOT EXISTS {?newRole rdfs:subClassOf* amr:AMR_Role ;
amr:fromAmrLk ?r.}
""",
'binding':"""
# -- Label
BIND (strafter(str(?r), '#') AS ?rLabel1)
BIND (strafter(str(?r), str(ns1:)) AS ?rLabel2)
BIND (IF (STRLEN(?rLabel1) > 0, ?rLabel1, ?rLabel2) AS ?rLabel)
# rule_set['reclassify-role-2'] = {
# 'label': "reclassify-rolet-2",
# 'comment': "Reclassify role to AMR non-core role",
# 'construction': """
# # -- New AMR non core role
# ?newRole rdfs:subClassOf amr:AMR_NonCore_Role ;
# amr:label ?rLabel ;
# amr:fromAmrLk ?r.
# """,
# 'clause': """
# # -- Identify non core role
# ?r a ns3:Role.
# FILTER ( ?r != ns1:FrameRole ).
# -- New role
BIND (CONCAT(str(amr:), 'role') AS ?n1).
BIND (CONCAT(?n1, '_', ?rLabel) AS ?n2).
BIND (uri(?n2) AS ?newRole).
"""
}
# # -- Filter core role
# FILTER NOT EXISTS {?newRole rdfs:subClassOf* amr:AMR_Role ;
# amr:fromAmrLk ?r.}
# """,
# 'binding':"""
# # -- Label
# BIND (strafter(str(?r), '#') AS ?rLabel1)
# BIND (strafter(str(?r), str(ns1:)) AS ?rLabel2)
# BIND (IF (STRLEN(?rLabel1) > 0, ?rLabel1, ?rLabel2) AS ?rLabel)
# # -- New role
# BIND (CONCAT(str(amr:), 'role') AS ?n1).
# BIND (CONCAT(?n1, '_', ?rLabel) AS ?n2).
# BIND (uri(?n2) AS ?newRole).
# """
# }
# ---------------------------------------------
......@@ -417,6 +417,7 @@ rule_set['add-new-variable-for-reified-concept'] = {
'construction': """
# -- New variable
?newVariable a amr:AMR_Variable ;
amr:isReifiedVariable true ;
amr:label ?vLabel.
# -- Linking new variable to LK role (for tracing)
......@@ -499,21 +500,24 @@ rule_set['add-amr-leaf-for-reified-concept'] = {
'construction': """
# -- New leaf
?newLeaf a amr:AMR_Leaf ;
amr:hasVariable ?newV ;
amr:isReifiedLeaf true ;
amr:hasVariable ?v ;
amr:hasConcept ?c.
""",
'clause': """
# -- Identify (concept, variable) tuples
# -- Identify reified concept
?c rdfs:subClassOf* amr:AMR_Concept ;
amr:isReifiedConcept true ;
amr:label ?cLabel ;
amr:fromAmrLk ?linkedC.
# -- Identify new variable
?newV a amr:AMR_Variable ;
# -- Identify reified variable
?v a amr:AMR_Variable ;
amr:isReifiedVariable true ;
amr:label ?vLabel.
# -- identify matching between concept and (new) variable
?newV a ?linkedC.
# -- Identify matching between reified concept and variable
?v a ?linkedC.
""",
'binding':"""
# -- New labels
......@@ -535,7 +539,6 @@ rule_set['add-amr-leaf-for-reified-concept'] = {
# Addition of edges
# ---------------------------------------------
rule_set['add-amr-edge-for-core-relation'] = {
'label': "add-amr-edge-for-core-relation",
'comment': ("Add AMR edge corresponding to: ",
......@@ -543,9 +546,10 @@ rule_set['add-amr-edge-for-core-relation'] = {
'construction': """
# -- New edge
?newEdge a amr:AMR_Edge ;
amr:hasRolesetID ?rolesetId ;
amr:hasRoleID ?roleId ;
amr:hasRoleTag ?roleTag.
amr:hasRoleID ?roleId.
# -- old --- amr:hasRolesetID ?rolesetId ;
# -- old --- amr:hasRoleID ?roleId ;
# -- old --- amr:hasRoleTag ?roleTag.
# -- New relation between leafs
?leaf1 ?newEdge ?leaf2.
......@@ -555,6 +559,13 @@ rule_set['add-amr-edge-for-core-relation'] = {
?r a ?amrLkRelation.
VALUES ?amrLkRelation {ns1:FrameRole ns3:Role}
# -- Filter reified role
FILTER NOT EXISTS {
?newConcept rdfs:subClassOf amr:AMR_Predicat_Concept ;
amr:isReifiedConcept true ;
amr:fromAmrLk ?r.
}
# -- identify leafs and variables
?leaf1 amr:hasVariable ?v1.
?leaf2 amr:hasVariable ?v2.
......@@ -574,14 +585,13 @@ rule_set['add-amr-edge-for-core-relation'] = {
BIND (strafter(str(?r), str(ns1:)) AS ?rLabel2)
BIND (IF (STRLEN(?rLabel1) > 0, ?rLabel1, ?rLabel2) AS ?rLabel)
BIND (IF (CONTAINS(?rLabel, "."),
?rLabel,
CONCAT("amr.", ?rLabel)) AS ?roleTag)
BIND (strbefore(?roleTag, '.') AS ?rolesetId)
BIND (strafter(?roleTag, '.') AS ?roleId)
BIND (IF (STRLEN(?roleId) > 0, ?roleId, ?rLabel) AS ?rLabel)
# -- old --- BIND (?rLabel AS ?roleTag)
# -- old --- BIND (strafter(str(?v1), '#') AS ?v1Label)
# -- old --- BIND (strafter(str(?v2), '#') AS ?v2Label)
strafter(?rLabel, '.'),
?rLabel) AS ?roleId)
# -- old --- BIND (IF (STRLEN(?rLabel1) > 0, ?rLabel1, ?rLabel2) AS ?rLabel3)
# -- old --- BIND (IF (CONTAINS(?rLabel3, "."), ?rLabel3, CONCAT("amr.", ?rLabel3)) AS ?roleTag)
# -- old --- BIND (strbefore(?roleTag, '.') AS ?rolesetId)
# -- old --- BIND (strafter(?roleTag, '.') AS ?roleId)
# -- old --- BIND (IF (STRLEN(?roleId) > 0, ?roleId, ?rLabel3) AS ?rLabel)
# -- New edge
BIND (CONCAT(str(amr:), 'edge') AS ?n1).
......@@ -592,6 +602,94 @@ rule_set['add-amr-edge-for-core-relation'] = {
"""
}
rule_set['add-amr-edge-for-reified-concept'] = {
'label': "add-amr-edge-for-reified-concept",
'comment': ("Add AMR edge corresponding to: ",
" (x) reification of LK non-core relation to concept"),
'construction': """
# -- New edge (ARG0)
?newEdge0 a amr:AMR_Edge ;
amr:hasRoleID ?roleId0.
# -- old --- amr:hasRolesetID ?rolesetId0 ;
# -- old --- amr:hasRoleID ?roleId0 ;
# -- old --- amr:hasRoleTag ?roleTag0.
# -- New edge (ARG1)
?newEdge1 a amr:AMR_Edge ;
amr:hasRoleID ?roleId1.
# -- old --- amr:hasRolesetID ?rolesetId1 ;
# -- old --- amr:hasRoleID ?roleId1 ;
# -- old --- amr:hasRoleTag ?roleTag1.
# -- New relations between leafs
?reifiedLeaf ?newEdge0 ?leaf1.
?reifiedLeaf ?newEdge1 ?leaf2.
""",
'clause': """
# -- Identify reified leaf
?reifiedLeaf a amr:AMR_Leaf ;
amr:isReifiedLeaf true ;
amr:hasVariable ?reifiedVariable ;
amr:hasConcept ?reifiedConcept.
?reifiedVariable amr:label ?rvLabel.
# -- Identify LK relation corresponding to the reified concept
?reifiedConcept amr:fromAmrLk ?r.
# -- Identify leafs and variables
?leaf1 amr:hasVariable ?v1.
?leaf2 amr:hasVariable ?v2.
?v1 a amr:AMR_Variable ;
amr:label ?v1Label ;
amr:fromAmrLk ?v1Link.
?v2 a amr:AMR_Variable ;
amr:label ?v2Label ;
amr:fromAmrLk ?v2Link.
# -- Identify matching
?v1Link ?r ?v2Link.
""",
'binding':"""
# -- New labels
# -- old --- BIND (strafter(str(?r), '#') AS ?rLabel1)
# -- old --- BIND (strafter(str(?r), str(ns1:)) AS ?rLabel2)
# -- old --- BIND (IF (STRLEN(?rLabel1) > 0, ?rLabel1, ?rLabel2) AS ?rLabel3)
# -- old --- BIND (IF (CONTAINS(?rLabel3, "."),
# -- old --- ?rLabel3,
# -- old --- CONCAT("amr.", ?rLabel3)) AS ?roleTag)
# -- old --- BIND (strbefore(?roleTag, '.') AS ?rolesetId)
# -- old --- BIND (strafter(?roleTag, '.') AS ?roleId)
# -- old --- BIND (IF (STRLEN(?roleId) > 0, ?roleId, ?rLabel3) AS ?rLabel)
# -- New labels for ARG0 edge
# -- old --- BIND ("amr.ARG0" AS ?roleTag0)
# -- old --- BIND (strbefore(?roleTag0, '.') AS ?rolesetId0)
# -- old --- BIND (strafter(?roleTag0, '.') AS ?roleId0)
# -- New labels for ARG1 edge
# -- old --- BIND ("amr.ARG1" AS ?roleTag1)
# -- old --- BIND (strbefore(?roleTag1, '.') AS ?rolesetId1)
# -- old --- BIND (strafter(?roleTag1, '.') AS ?roleId1)
# -- New labels
BIND ("ARG0" AS ?roleId0)
BIND ("ARG1" AS ?roleId1)
# -- New edge (ARG0)
BIND (CONCAT(str(amr:), 'edge') AS ?n01).
BIND (CONCAT(?n01, '_', ?v1Label) AS ?n02).
BIND (CONCAT(?n02, '_', ?roleId0) AS ?n03).
BIND (CONCAT(?n03, '_', ?rvLabel) AS ?n04).
BIND (uri(?n04) AS ?newEdge0).
# -- New edge (ARG1)
BIND (CONCAT(str(amr:), 'edge') AS ?n11).
BIND (CONCAT(?n11, '_', ?rvLabel) AS ?n12).
BIND (CONCAT(?n12, '_', ?roleId1) AS ?n13).
BIND (CONCAT(?n13, '_', ?v2Label) AS ?n14).
BIND (uri(?n14) AS ?newEdge1).
"""
}
rule_set['add-amr-edge-for-name-relation'] = {
'label': "add-amr-edge-for-name-relation",
......@@ -604,9 +702,10 @@ rule_set['add-amr-edge-for-name-relation'] = {
# -- New edge
?newEdge a amr:AMR_Edge ;
amr:hasRolesetID ?rolesetId ;
amr:hasRoleID ?roleId ;
amr:hasRoleTag ?roleTag.
amr:hasRoleID ?roleId.
# -- old --- amr:hasRolesetID ?rolesetId ;
# -- old --- amr:hasRoleID ?roleId ;
# -- old --- amr:hasRoleTag ?roleTag.
# -- New relation between leaf and value
?leaf ?newEdge ?newValue.
......@@ -656,9 +755,10 @@ rule_set['add-amr-edge-for-quant-relation'] = {
# -- New edge
?newEdge a amr:AMR_Edge ;
amr:hasRolesetID ?rolesetId ;
amr:hasRoleID ?roleId ;
amr:hasRoleTag ?roleTag.
amr:hasRoleID ?roleId.
# -- old --- amr:hasRolesetID ?rolesetId ;
# -- old --- amr:hasRoleID ?roleId ;
# -- old --- amr:hasRoleTag ?roleTag.
# -- New relation between leaf and value
?leaf ?newEdge ?newValue.
......@@ -706,9 +806,10 @@ rule_set['add-amr-edge-for-polarity-relation'] = {
# -- New edge
?newEdge a amr:AMR_Edge ;
amr:hasRolesetID ?rolesetId ;
amr:hasRoleID ?roleId ;
amr:hasRoleTag ?roleTag.
amr:hasRoleID ?roleId.
# -- old --- amr:hasRolesetID ?rolesetId ;
# -- old --- amr:hasRoleID ?roleId ;
# -- old --- amr:hasRoleTag ?roleTag.
# -- New relation between leaf and value
?leaf ?newEdge ?newValue.
......@@ -749,7 +850,7 @@ rule_set['add-amr-edge-for-polarity-relation'] = {
# ---------------------------------------------
# Update leafs and edges
# Update leafs and edges *** TODO ***
# ---------------------------------------------
rule_set['update-amr-edge-role-1'] = {
......@@ -770,23 +871,23 @@ rule_set['update-amr-edge-role-1'] = {
'binding': ''
}
rule_set['update-amr-edge-role-2'] = {
'label': "update-amr-edge-role-2",
'comment': ("Update AMR edge by adding relation with AMR_Role",
"(using comparison between label and role tag)"),
'construction': """
?edge amr:hasAmrRole ?role.
""",
'clause': """
?edge a amr:AMR_Edge ;
amr:hasRoleTag ?edgeRoleId.
?role rdfs:subClassOf* amr:AMR_Role ;
amr:label ?roleLabel.
FILTER ( ?roleLabel != '' ).
FILTER ( ?edgeRoleId = ?roleLabel ).
""",
'binding': ''
}
# rule_set['update-amr-edge-role-2'] = {
# 'label': "update-amr-edge-role-2",
# 'comment': ("Update AMR edge by adding relation with AMR_Role",
# "(using comparison between label and role tag)"),
# 'construction': """
# ?edge amr:hasAmrRole ?role.
# """,
# 'clause': """
# ?edge a amr:AMR_Edge ;
# amr:hasRoleTag ?edgeRoleId.
# ?role rdfs:subClassOf* amr:AMR_Role ;
# amr:label ?roleLabel.
# FILTER ( ?roleLabel != '' ).
# FILTER ( ?edgeRoleId = ?roleLabel ).
# """,
# 'binding': ''
# }
# ---------------------------------------------
......
......@@ -76,21 +76,22 @@ amr_reification_sequence = {
'reclassify-concept-3',
'reclassify-concept-4',
'reclassify-concept-5',
'reclassify-role-1',
'reclassify-role-2',
# --old --- 'reclassify-role-1',
# --old --- 'reclassify-role-2',
'reify-roles-as-concept',
'reclassify-existing-variable',
'add-new-variable-for-reified-concept',
'add-amr-leaf-for-reclassified-concept',
'add-amr-leaf-for-reified-concept',
'add-amr-edge-for-core-relation',
'add-amr-edge-for-reified-concept',
'add-amr-edge-for-name-relation',
'add-amr-edge-for-quant-relation',
'add-amr-edge-for-polarity-relation',
# --old --- 'set-amr-label-for-variables',
# --old --- 'set-amr-label-for-roles',
'update-amr-edge-role-1',
'update-amr-edge-role-2',
# --old --- 'update-amr-edge-role-2',
'add-amr-root']
}
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment