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

Update CTS to improve composition of atom and list

parent 38794edb
Branches
Tags
No related merge requests found
......@@ -388,8 +388,8 @@ cts:batch_execution
sh:rule cts:complement-list-of-entity-classes ;
sh:rule cts:compose-agt-verb-obj-as-simple-event ;
sh:rule cts:compose-aoj-verb-obj-as-simple-state-property ;
sh:rule cts:compose-atom-with-list-1 ;
sh:rule cts:compose-atom-with-list-2 ;
sh:rule cts:compose-atom-with-list-by-mod-1 ;
sh:rule cts:compose-atom-with-list-by-mod-2 ;
sh:rule cts:compute-class-uri-of-net-object ;
sh:rule cts:compute-domain-range-of-event-object-properties ;
sh:rule cts:compute-domain-range-of-state-property-object-properties ;
......@@ -407,7 +407,6 @@ cts:batch_execution
sh:rule cts:instantiate-classlist-by-extension-2 ;
sh:rule cts:link-to-scope-entry ;
sh:rule cts:specify-axis-of-list-net ;
sh:rule cts:specify-items-of-list-net ;
.
cts:batch_execution_1
rdf:type cts:batch_execution ;
......@@ -625,7 +624,7 @@ WHERE {
}""" ;
sh:order 2.41 ;
.
cts:compose-atom-with-list-1
cts:compose-atom-with-list-by-mod-1
rdf:type sh:SPARQLRule ;
sh:construct """PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
......@@ -640,86 +639,72 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
# -- Compose an atom net and a list net (with distinct item classes)
CONSTRUCT {
# Object: feature 2
?newFeature2 a net:Object.
?newFeature2 net:objectType \"Feature\".
?newFeature2 net:has_node ?uw2.
?newFeature2 net:has_parent_class ?listItemClass.
?newFeature2 net:has_concept ?concept2.
# Object: feature 3
?newFeature3 a net:Object.
?newFeature3 net:objectType \"Feature\".
?newFeature3 net:has_node ?uw3.
?newFeature3 net:has_parent_class ?listItemClass.
?newFeature3 net:has_concept ?concept3.
# Object: entity 2
?newEntity2 a net:Object.
?newEntity2 net:objectType \"Entity\".
?newEntity2 net:has_node ?uw2.
?newEntity2 net:has_parent_class ?listItemClass.
?newEntity2 net:has_concept ?subEntity2.
?newEntity2 net:has_feature ?newFeature2.
?newObject12 a net:Object.
?newObject12 net:objectType net:composite.
?newObject12 net:has_node ?uw1, ?uw2.
?newObject12 net:has_mother_class ?net1Mother.
# -- TODO --- ?newObject12 net:has_parent_class ?net1Class.
?newObject12 net:has_concept ?subConceptA.
?newObject12 net:has_feature ?net2ItemA.
# Object: entity 3
?newEntity3 a net:Object.
?newEntity3 net:objectType \"Entity\".
?newEntity3 net:has_node ?uw3.
?newEntity3 net:has_parent_class ?entityClass2.
?newEntity3 net:has_concept ?subEntity3.
?newEntity3 net:has_feature ?newFeature3.
?newObject13 a net:Object.
?newObject13 net:objectType net:composite.
?newObject13 net:has_node ?uw1, ?uw3.
?newObject13 net:has_mother_class ?net1Mother.
# -- TODO --- ?newObject13 net:has_parent_class ?net1Class.
?newObject13 net:has_concept ?subConceptB.
?newObject13 net:has_feature ?net2ItemB.
# Net: Entity ClassList
?newNet a net:Instance.
?newNet net:type net:entity_class_list.
?newNet net:has_structure ?req.
?newNet net:has_node ?uw1, ?uw2, ?uw3.
?newNet net:entityClass ?atomParentClass.
?newNet net:has_mainClass ?atomObject1.
?newNet net:has_subClass ?newEntity2, ?newEntity3.
?newNet net:has_feature ?newFeature2, ?newFeature3.
?newNet net:entityClass ?net1ParentClass.
?newNet net:has_mainClass ?net1Object.
?newNet net:has_subClass ?newObject12, ?newObject13.
}
WHERE {
# net1: agent
# net1: atom
?net1 a net:Instance.
?net1 net:type net:atom.
?net1 net:atomOf sys:Entity.
?net1 net:has_structure ?req.
?net1 net:has_node ?uw1.
?net1 net:has_atom ?atomObject1.
?atomObject1 net:has_parent_class ?atomParentClass.
?atomObject1 net:has_concept ?mainEntity.
?net1 net:has_atom ?net1Object.
?net1Object net:has_mother_class ?net1Mother.
?net1Object net:has_parent_class ?net1ParentClass.
?net1Object net:has_concept ?net1Concept.
# condition: mod(net1, net2)
?uw1 unl:mod ?uw2.
# net2: entity modList
# net2: list
?net2 a net:Instance.
?net2 net:type net:list.
?net2 net:listOf ?listItemClass.
?net2 net:has_structure ?req.
?net2 net:has_node ?uw2, ?uw3.
?net2 net:has_item ?net2ItemA.
?net2ItemA net:has_node ?uw2.
?net2ItemA net:has_concept ?net2ConceptA.
?net2 net:has_item ?net2ItemB.
?net2ItemB net:has_node ?uw3.
?net2ItemB net:has_concept ?net2ConceptB.
# Filter
FILTER ( ?uw1 != ?uw3 ).
FILTER ( ?atomParentClass != ?listItemClass ).
# Label: Id, concept, subEntity
FILTER NOT EXISTS { ?net2 net:has_node ?uw1 }.
FILTER ( ?net1ParentClass != ?listItemClass ).
# Label: Id, concept
?uw1 unl:has_id ?uw1Id.
?uw2 unl:has_id ?uw2Id.
?uw3 unl:has_id ?uw3Id.
?uw2 rdfs:label ?uw2Label.
?uw3 rdfs:label ?uw3Label.
BIND (strbefore(?uw2Label, '(') AS ?concept2)
BIND (strbefore(?uw3Label, '(') AS ?concept3)
BIND (concat(?concept2, '_', ?mainEntity) AS ?subEntity2).
BIND (concat(?concept3, '_', ?mainEntity) AS ?subEntity3).
# URI (for Feature Object)
BIND (concat( ?net2ConceptA, '_', ?net1Concept) AS ?subConceptA).
BIND (concat( ?net2ConceptB, '_', ?net1Concept) AS ?subConceptB).
# URI (for Object)
cprm:Config_Parameters cprm:netURI ?netURI.
cprm:Config_Parameters cprm:objectRef ?objectRef.
BIND (concat( ?netURI, ?objectRef) AS ?o1).
BIND (concat(?o1, ?uw2Id) AS ?f2).
BIND (concat(?o1, ?uw3Id) AS ?f3).
BIND (uri(?f2) AS ?newFeature2).
BIND (uri(?f3) AS ?newFeature3).
# URI (for Entity Object)
BIND (concat(?f2, '_', ?subEntity2) AS ?e2).
BIND (concat(?f3, '_', ?subEntity3) AS ?e3).
BIND (uri(?e2) AS ?newEntity2).
BIND (uri(?e3) AS ?newEntity3).
BIND (concat(?o1, ?uw1Id, '-', ?uw2Id) AS ?o2).
BIND (concat(?o1, ?uw1Id, '-', ?uw3Id) AS ?o3).
BIND (uri(?o2) AS ?newObject12).
BIND (uri(?o3) AS ?newObject13).
# URI (for ClassList Net)
cprm:Config_Parameters cprm:netURI ?netURI.
net:class_list rdfs:label ?classListLabel.
......@@ -729,7 +714,7 @@ WHERE {
}""" ;
sh:order 2.32 ;
.
cts:compose-atom-with-list-2
cts:compose-atom-with-list-by-mod-2
rdf:type sh:SPARQLRule ;
sh:construct """PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
......@@ -744,66 +729,39 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
# -- Compose an atom net and an list net (with same item classes)
CONSTRUCT {
# Object: entity 2
?newEntity2 a net:Object.
?newEntity2 net:objectType \"Entity\".
?newEntity2 net:has_node ?uw2.
?newEntity2 net:has_parent_class ?listItemClass.
?newEntity2 net:has_concept ?subEntity2.
# Object: entity 3
?newEntity3 a net:Object.
?newEntity3 net:objectType \"Entity\".
?newEntity3 net:has_node ?uw3.
?newEntity3 net:has_parent_class ?listItemClass.
?newEntity3 net:has_concept ?subEntity3.
# Net: Entity ClassList
?newNet a net:Instance.
?newNet net:type net:entity_class_list.
?newNet net:has_structure ?req.
?newNet net:has_node ?uw1, ?uw2, ?uw3.
?newNet net:entityClass ?atomParentClass.
?newNet net:has_mainClass ?atomObject1.
?newNet net:has_subClass ?newEntity2, ?newEntity3.
?newNet net:entityClass ?net1ParentClass.
?newNet net:has_mainClass ?net1Object.
?newNet net:has_subClass ?object2, ?object3.
}
WHERE {
# net1: atom
?net1 a net:Instance.
?net1 net:type net:atom.
?net1 net:atomOf sys:Entity.
?net1 net:has_structure ?req.
?net1 net:has_node ?uw1.
?net1 net:has_atom ?atomObject1.
?atomObject1 net:has_parent_class ?atomParentClass.
?atomObject1 net:has_concept ?mainEntity.
?net1 net:has_atom ?net1Object.
?net1Object net:has_parent_class ?net1ParentClass.
# condition: mod(net1, net2)
?uw1 unl:mod ?uw2.
# net2: entity modList
# net2: list
?net2 a net:Instance.
?net2 net:type net:list.
?net2 net:listOf ?listItemClass.
?net2 net:has_structure ?req.
?net2 net:has_node ?uw2, ?uw3.
?net2 net:has_item ?object2, ?object3.
# Filter
FILTER ( ?uw1 != ?uw3 ).
FILTER ( ?atomParentClass = ?listItemClass ).
FILTER ( ?net1ParentClass = ?listItemClass ).
# Label: Id, subEntity
?uw1 unl:has_id ?uw1Id.
?uw2 unl:has_id ?uw2Id.
?uw3 unl:has_id ?uw3Id.
?uw2 rdfs:label ?uw2Label.
?uw3 rdfs:label ?uw3Label.
BIND (strbefore(?uw2Label, '(') AS ?subEntity2)
BIND (strbefore(?uw3Label, '(') AS ?subEntity3)
# URI (for Entity Object)
cprm:Config_Parameters cprm:netURI ?netURI.
cprm:Config_Parameters cprm:objectRef ?objectRef.
BIND (concat( ?netURI, ?objectRef) AS ?e1).
BIND (concat(?e1, ?uw2Id) AS ?e2a).
BIND (concat(?e1, ?uw3Id) AS ?e3a).
BIND (concat(?e2a, '_', ?subEntity2) AS ?e2b).
BIND (concat(?e3a, '_', ?subEntity3) AS ?e3b).
BIND (uri(?e2b) AS ?newEntity2).
BIND (uri(?e3b) AS ?newEntity3).
# URI (for ClassList Net)
cprm:Config_Parameters cprm:netURI ?netURI.
net:class_list rdfs:label ?classListLabel.
......@@ -1010,14 +968,14 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
# -- Create Atom Net (entity)
CONSTRUCT {
# Object: entity
# Object
?newObject a net:Object.
?newObject net:objectType ?atomMother.
?newObject net:objectType net:atom.
?newObject net:has_node ?uw1.
?newObject net:has_mother_class ?atomMother.
?newObject net:has_parent_class ?atomClass.
?newObject net:has_concept ?concept1.
# Net: Entity
# Net
?newNet a net:Instance.
?newNet net:type net:atom.
?newNet net:atomOf ?atomMother.
......@@ -1071,23 +1029,29 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
# -- Initialize a ModList net
CONSTRUCT {
?semNet a net:Instance.
?semNet net:type net:list.
?semNet net:type net:unary_list.
?semNet net:has_structure ?req.
?semNet net:has_node ?uw1.
?semNet net:has_concept ?concept1.
?newNet a net:Instance.
?newNet net:type net:list.
?newNet net:type net:unary_list.
?newNet net:listOf ?net1ParentClass.
?newNet net:has_structure ?req.
?newNet net:has_node ?uw1.
?newNet net:has_item ?object1.
}
WHERE {
# UW: type UW-Occurrence and substructure of req sentence
?uw0 rdf:type unl:UW_Occurrence.
?uw0 unl:is_substructure_of ?req.
# Net: atom
?net1 a net:Instance.
?net1 net:type net:atom.
?net1 net:atomOf ?net1Mother.
?net1 net:has_structure ?req.
?net1 net:has_node ?uw1.
?net1 net:has_atom ?object1.
?object1 net:has_parent_class ?net1ParentClass.
# selection: target UW of modifier (mod)
?uw0 unl:mod ?uw1.
FILTER NOT EXISTS { ?uw1 (unl:and|unl:or) ?uw2 }
# UW: type UW-Occurrence and substructure of req sentence
?uw1 rdf:type unl:UW_Occurrence.
?uw1 unl:is_substructure_of ?req.
?uw0 rdf:type unl:UW_Occurrence.
?uw0 unl:is_substructure_of ?req.
# Label(s) / URI
?uw1 rdfs:label ?uw1Label.
?uw1 unl:has_id ?uw1Id.
......@@ -1097,7 +1061,7 @@ WHERE {
# -- old --- BIND (strbefore(?uw2Label, '(') AS ?concept2).
BIND (concat( ?netURI, ?listLabel, '_') AS ?s1).
BIND (concat(?s1, ?uw1Id) AS ?s2).
BIND (uri(?s2) AS ?semNet).
BIND (uri(?s2) AS ?newNet).
}""" ;
sh:order 2.21 ;
.
......@@ -1142,15 +1106,14 @@ cts:entity_extraction
rdf:type sh:NodeShape ;
rdfs:label "entity extraction" ;
rdfs:subClassOf cts:net_extension ;
sh:rule cts:compose-atom-with-list-1 ;
sh:rule cts:compose-atom-with-list-2 ;
sh:rule cts:compose-atom-with-list-by-mod-1 ;
sh:rule cts:compose-atom-with-list-by-mod-2 ;
sh:rule cts:create-atom-net ;
sh:rule cts:extend-list-net ;
sh:rule cts:init-conjunctive-list-net ;
sh:rule cts:instantiate-atom-net ;
sh:rule cts:instantiate-classlist-by-extension-1 ;
sh:rule cts:instantiate-classlist-by-extension-2 ;
sh:rule cts:specify-items-of-list-net ;
.
cts:event_extraction
rdf:type owl:Class ;
......@@ -1174,22 +1137,23 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
# -- Extend a ModList net
CONSTRUCT {
?semNet net:has_node ?uw2.
?semNet net:has_concept ?concept2.
?net1 net:has_node ?uw2.
?net1 net:has_item ?object2.
}
WHERE {
# selection: modList net
?semNet a net:Instance.
?semNet net:type net:list.
?semNet net:has_node ?uw1.
# net1: list
?net1 a net:Instance.
?net1 net:type net:list.
?net1 net:has_structure ?req.
?net1 net:has_node ?uw1.
# extension: disjunction of UW
?uw1 (unl:or|unl:and) ?uw2.
# UW: type UW-Occurrence and substructure of req sentence
?uw2 rdf:type unl:UW_Occurrence.
?uw2 unl:is_substructure_of ?req.
# Label(s) / URI
?uw2 rdfs:label ?uw2Label.
BIND (strbefore(?uw2Label, '(') AS ?concept2)
# net2: atom
?net2 a net:Instance.
?net2 net:type net:atom.
?net2 net:has_structure ?req.
?net2 net:has_node ?uw2.
?net2 net:has_atom ?object2.
}""" ;
sh:order 2.22 ;
.
......@@ -1317,17 +1281,23 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
# -- Initialize a ModList net
CONSTRUCT {
?semNet a net:Instance.
?semNet net:type net:list.
?semNet net:type net:conjunctive_list.
?semNet net:has_structure ?req.
?semNet net:has_node ?uw1.
?semNet net:has_concept ?concept1.
?newNet a net:Instance.
?newNet net:type net:list.
?newNet net:type net:conjunctive_list.
?newNet net:listOf ?net1ParentClass.
?newNet net:has_structure ?req.
?newNet net:has_node ?uw1.
?newNet net:has_item ?object1.
}
WHERE {
# UW: type UW-Occurrence and substructure of req sentence
?uw1 rdf:type unl:UW_Occurrence.
?uw1 unl:is_substructure_of ?req.
# Net: atom
?net1 a net:Instance.
?net1 net:type net:atom.
?net1 net:atomOf ?net1Mother.
?net1 net:has_structure ?req.
?net1 net:has_node ?uw1.
?net1 net:has_atom ?object1.
?object1 net:has_parent_class ?net1ParentClass.
# selection: target UW of modifier (mod)
?uw1 unl:and ?uw2.
# UW: type UW-Occurrence and substructure of req sentence
......@@ -1342,7 +1312,7 @@ WHERE {
# -- old --- BIND (strbefore(?uw2Label, '(') AS ?concept2).
BIND (concat( ?netURI, ?listLabel, '_') AS ?s1).
BIND (concat(?s1, ?uw1Id) AS ?s2).
BIND (uri(?s2) AS ?semNet).
BIND (uri(?s2) AS ?newNet).
}""" ;
sh:order 2.21 ;
.
......@@ -1361,17 +1331,23 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
# -- Initialize a ModList net
CONSTRUCT {
?semNet a net:Instance.
?semNet net:type net:list.
?semNet net:type net:disjunctive_list.
?semNet net:has_structure ?req.
?semNet net:has_node ?uw1.
?semNet net:has_concept ?concept1.
?newNet a net:Instance.
?newNet net:type net:list.
?newNet net:type net:disjunctive_list.
?newNet net:listOf ?net1ParentClass.
?newNet net:has_structure ?req.
?newNet net:has_node ?uw1.
?newNet net:has_item ?object1.
}
WHERE {
# UW: type UW-Occurrence and substructure of req sentence
?uw1 rdf:type unl:UW_Occurrence.
?uw1 unl:is_substructure_of ?req.
# Net: atom
?net1 a net:Instance.
?net1 net:type net:atom.
?net1 net:atomOf ?net1Mother.
?net1 net:has_structure ?req.
?net1 net:has_node ?uw1.
?net1 net:has_atom ?object1.
?object1 net:has_parent_class ?net1ParentClass.
# selection: target UW of modifier (mod)
?uw1 unl:or ?uw2.
# UW: type UW-Occurrence and substructure of req sentence
......@@ -1386,7 +1362,7 @@ WHERE {
# -- old --- BIND (strbefore(?uw2Label, '(') AS ?concept2).
BIND (concat( ?netURI, ?listLabel, '_') AS ?s1).
BIND (concat(?s1, ?uw1Id) AS ?s2).
BIND (uri(?s2) AS ?semNet).
BIND (uri(?s2) AS ?newNet).
}""" ;
sh:order 2.21 ;
.
......@@ -1412,7 +1388,6 @@ WHERE {
# net1: atom
?net1 a net:Instance.
?net1 net:type net:atom.
# -- old --- ?net1 net:atomOf sys:Entity.
?net1 net:has_structure ?req.
?net1 net:has_node ?uw1.
?net1 net:has_atom ?atomObject1.
......@@ -1445,10 +1420,9 @@ CONSTRUCT {
?subObject2 net:has_instance ?instanceName1.
}
WHERE {
# net1: entity with instance
# net1: atom with instance
?net1 a net:Instance.
?net1 net:type net:atom.
?net1 net:atomOf sys:Entity.
?net1 net:has_structure ?sameReq.
?net1 net:has_atom ?sameObject1.
?sameObject1 net:has_instance ?instanceName1.
......@@ -1458,7 +1432,6 @@ WHERE {
?net2 net:entityClass ?sameClass.
?net2 net:has_structure ?sameReq.
?net2 net:has_mainClass ?sameObject1.
# -- old --- ?net2 net:has_mainClass ?sameEntity.
?net2 net:has_subClass ?subObject2.
# Filter
FILTER NOT EXISTS { ?subObject2 net:has_instance ?instanceName2 } .
......@@ -1568,54 +1541,19 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
# -- Specify the class of items in the list
CONSTRUCT {
?semNet net:listBy ?unlRel.
?net1 net:listBy ?unlRel.
}
WHERE {
# UW: type UW-Occurrence and substructure of req sentence
?uw0 rdf:type unl:UW_Occurrence.
?uw0 unl:is_substructure_of ?req.
# net: modList
?semNet a net:Instance.
?semNet net:type net:list.
?semNet net:has_node ?uw1.
?net1 a net:Instance.
?net1 net:type net:list.
?net1 net:has_node ?uw1.
# selection: target UW of modifier (mod)
?uw0 ?unlRel ?uw1.
}""" ;
sh:order 2.23 ;
.
cts:specify-items-of-list-net
rdf:type sh:SPARQLRule ;
sh:construct """PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX unl: <https://unl.tetras-libre.fr/rdf/schema#>
PREFIX net: <https://unsel.tetras-libre.fr/tenet/semantic-net#>
PREFIX cprm: <https://unsel.tetras-libre.fr/tenet/config/parameters#>
PREFIX req: <https://unsel.tetras-libre.fr/tenet/frame/requirement-ontology#>
PREFIX sys: <https://unsel.tetras-libre.fr/tenet/frame/system-ontology/>
PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
# -- Specify the class of items in the list
CONSTRUCT {
?semNet net:listOf ?atomClass.
}
WHERE {
# Entity Feature (from System Ontology)
?targetClass rdfs:subClassOf* sys:Structure.
?targetClass sys:is_class ?atomClass.
?targetClass sys:has_restriction ?atomRestriction.
# net: modList
?semNet a net:Instance.
?semNet net:type net:list.
?semNet net:has_node ?uw1.
# UW: type UW-Occurrence and substructure of req sentence
?uw1 rdf:type unl:UW_Occurrence.
?uw1 unl:is_substructure_of ?req.
# Label(s) / URI
?uw1 rdfs:label ?uw1Label.
# Filter
FILTER ( regex(str(?uw1Label),str(?atomRestriction)) ).
FILTER NOT EXISTS { ?net1 net:has_node ?uw0 }.
}""" ;
sh:order 2.23 ;
.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment