From 35ba1366af50890c02d4e0c3eec0914593ac056d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Lamercerie?= <aurelien.lamercerie@laposte.net> Date: Mon, 13 Sep 2021 17:41:53 +0200 Subject: [PATCH] Extraction of state property as class and ObjectProperty --- config/semantic-net.ttl | 5 + config/transduction-schemes.ttl | 177 +++++++++++++++++++++++++++++--- frame/ontology-parameters.ttl | 10 +- frame/system-ontology.ttl | 5 + prepare_work_data.py | 4 +- 5 files changed, 184 insertions(+), 17 deletions(-) diff --git a/config/semantic-net.ttl b/config/semantic-net.ttl index e050aca4..af3e91a0 100644 --- a/config/semantic-net.ttl +++ b/config/semantic-net.ttl @@ -193,6 +193,11 @@ net:property rdf:type rdf:Property ; rdfs:label "netProperty" ; . +net:state_property + rdf:type owl:Class ; + rdfs:label "stateProperty" ; + rdfs:subClassOf net:Type ; +. net:type rdf:type rdf:Property ; rdfs:label "type "@fr ; diff --git a/config/transduction-schemes.ttl b/config/transduction-schemes.ttl index cb1fddb1..87d27f5e 100644 --- a/config/transduction-schemes.ttl +++ b/config/transduction-schemes.ttl @@ -299,6 +299,7 @@ CONSTRUCT { ?newEventObjectPropertyUri rdfs:subPropertyOf ?eventObjectPropertyUri. ?newEventObjectPropertyUri rdfs:domain ?actorClassUri. ?newEventObjectPropertyUri rdfs:range ?targetClassUri. + ?newEventObjectPropertyUri sys:from_structure ?req. ?actorUri ?newEventObjectPropertyUri ?targetUri. } WHERE { @@ -443,6 +444,85 @@ WHERE { }""" ; sh:order 3.2 ; . +cts:add-state-property + rdf:type sh:SPARQLRule ; + rdfs:label "add-event" ; + 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#> + +# -- Add Verb class / instance in System Ontology +CONSTRUCT { + # Classification + ?newStatePropertyUri rdfs:subClassOf ?statePropertyClassUri. + ?newStatePropertyUri rdfs:label ?statePropertyLabel. + ?newStatePropertyUri sys:from_structure ?req. + # Instantiation !!! TODO !!! + # -- old --- ?mainInstanceUri a ?newStatePropertyUri. + # -- old --- ?mainInstanceUri rdfs:label ?mainInstance. + # -- old --- ?mainInstanceUri sys:from_structure ?req. + # Object Property + ?newStatePropertyObjectPropertyUri a owl:ObjectProperty. + ?newStatePropertyObjectPropertyUri rdfs:subPropertyOf ?statePropertyObjectPropertyUri. + ?newStatePropertyObjectPropertyUri rdfs:domain ?actorClassUri. + ?newStatePropertyObjectPropertyUri rdfs:range ?targetClassUri. + ?newStatePropertyObjectPropertyUri sys:from_structure ?req. + ?actorUri ?statePropertyObjectPropertyUri ?targetUri. +} +WHERE { + # net1: entity + ?net1 a net:Instance. + ?net1 net:type net:state_property. + ?net1 net:has_structure ?req. + ?net1 net:has_verb ?verbObject1. + ?verbObject1 net:verbClass ?verbClass. + ?verbObject1 net:concept ?verbConcept. + ?net1 net:has_actor ?actorObject1. + ?actorObject1 net:entityClass ?actorClass. + ?actorObject1 net:concept ?actorConcept. + ?net1 net:has_target ?targetObject1. + ?targetObject1 net:entityClass ?targetClass. + ?targetObject1 net:concept ?targetConcept. + # Label: event + BIND (concat(?actorConcept, '-', ?verbConcept) AS ?e1). + BIND (concat(?e1, '-', ?targetConcept) AS ?statePropertyLabel). + # URI (for classes) + fprm:System_Ontology fprm:frameURI ?frameURI. + fprm:System_State_Property fprm:class ?statePropertyClass. + BIND (concat( ?frameURI, ?statePropertyClass) AS ?c1). + BIND (concat(?c1, '_', ?statePropertyLabel) AS ?c2). + BIND (uri( ?c1) AS ?statePropertyClassUri). + BIND (uri(?c2) AS ?newStatePropertyUri). + # URI (for instance) + # -- old --- BIND (concat( ?frameURI, ?eventClass) AS ?i1). + # -- old --- BIND (concat(?i1, '_', ?mainInstance) AS ?i2). + # -- old --- BIND (uri(?i2) AS ?mainInstanceUri). + # URI (for object property) + fprm:System_State_Property fprm:objectProperty ?statePropertyObjectProperty. + BIND (concat( ?frameURI, ?statePropertyObjectProperty) AS ?o1). + BIND (concat(?o1, '_', ?verbConcept) AS ?o2). + BIND (uri( ?o1) AS ?statePropertyObjectPropertyUri). + BIND (uri( ?o2) AS ?newStatePropertyObjectPropertyUri). + # URI (for Entity classes) + fprm:System_Ontology fprm:frameURI ?frameURI. + BIND (concat( ?frameURI, ?actorClass) AS ?e1a). + BIND (concat(?e1a, '_', ?actorConcept) AS ?e1b). + BIND (uri(?e1a) AS ?actorClassUri). + BIND (uri(?e1b) AS ?actorUri). + BIND (concat( ?frameURI, ?targetClass) AS ?e2a). + BIND (concat(?e2a, '_', ?targetConcept) AS ?e2b). + BIND (uri(?e2a) AS ?targetClassUri). + BIND (uri(?e2b) AS ?targetUri). +}""" ; + sh:order 3.1 ; +. cts:add-verb rdf:type sh:SPARQLRule ; rdfs:label "add-verb" ; @@ -460,9 +540,9 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#> # -- Add Verb class / instance in System Ontology CONSTRUCT { # Classification - ?mainVerbUri rdfs:subClassOf ?verbUri. - ?mainVerbUri rdfs:label ?mainEntity. - ?mainVerbUri sys:from_structure ?req. + ?verbUri rdfs:subClassOf ?verbClassUri. + ?verbUri rdfs:label ?verbConcept. + ?verbUri sys:from_structure ?req. # Instantiation !!! TODO !!! # -- old --- ?mainInstanceUri a ?mainVerbUri. # -- old --- ?mainInstanceUri rdfs:label ?mainInstance. @@ -475,19 +555,19 @@ WHERE { ?net1 net:has_structure ?req. ?net1 net:has_verb ?verbObject1. ?verbObject1 net:verbClass ?verbClass. - ?verbObject1 net:concept ?mainVerb. + ?verbObject1 net:concept ?verbConcept. # -- old --- ?verbObject1 net:entityInstance ?mainInstance. # Filter: entity not present in a class list - FILTER NOT EXISTS { ?net2 net:has_subClass ?mainVerb} + FILTER NOT EXISTS { ?net2 net:has_subClass ?verbConcept} # URI (for classes) cprm:Config_Parameters cprm:baseURI ?baseURI. fprm:System_Ontology fprm:frameURI ?frameURI. fprm:System_Event fprm:class ?eventURI. # -- old --- fprm:System_Entity rdfs:label ?verbLabel. BIND (concat( ?frameURI, ?verbClass) AS ?s1). - BIND (concat(?s1, '_', ?mainVerb) AS ?s2). - BIND (uri( ?s1) AS ?verbUri). - BIND (uri(?s2) AS ?mainVerbUri). + BIND (concat(?s1, '_', ?verbConcept) AS ?s2). + BIND (uri( ?s1) AS ?verbClassUri). + BIND (uri(?s2) AS ?verbUri). # URI (for instance) # -- old --- BIND (concat(?s1, '_', ?mainInstance) AS ?s3). # -- old --- BIND (uri(?s3) AS ?mainInstanceUri). @@ -506,10 +586,12 @@ cts:batch_execution sh:rule cts:add-event ; sh:rule cts:add-feature ; sh:rule cts:add-list-of-entity-classes ; + sh:rule cts:add-state-property ; sh:rule cts:add-verb ; sh:rule cts:bypass-reification ; sh:rule cts:complement-list-of-entity-classes ; - sh:rule cts:compose-agt-verb-obj-as-event ; + 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-entity-modlist-1 ; sh:rule cts:compose-entity-modlist-2 ; sh:rule cts:compose-entity-modlist-3 ; @@ -600,7 +682,7 @@ WHERE { }""" ; sh:order 3.3 ; . -cts:compose-agt-verb-obj-as-event +cts:compose-agt-verb-obj-as-simple-event 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#> @@ -615,7 +697,7 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#> # -- Compose a subject Entity (agt), an action Verb and an object Entity (obj) to obtain an event CONSTRUCT { - # Net: Entity ClassList + # Net: Event ?newNet a net:Instance. ?newNet net:type net:event. ?newNet net:has_structure ?req. @@ -659,6 +741,65 @@ WHERE { }""" ; sh:order 2.9 ; . +cts:compose-aoj-verb-obj-as-simple-state-property + 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#> + +# -- Compose a subject Entity (aoj), an action Verb and an object Entity (obj) / result Entity (res) to obtain a state property +CONSTRUCT { + # Net: State Property + ?newNet a net:Instance. + ?newNet net:type net:state_property. + ?newNet net:has_structure ?req. + ?newNet net:has_node ?uw1, ?uw2, ?uw3. + ?newNet net:has_actor ?actorObject. + ?newNet net:has_verb ?verbObject. + ?newNet net:has_target ?targetObject. +} +WHERE { + # net1: verb + ?net1 a net:Instance. + ?net1 net:type net:verb. + ?net1 net:has_structure ?req. + ?net1 net:has_node ?uw1. + ?net1 net:has_verb ?verbObject. + # net2: entity (actor) + ?net2 a net:Instance. + ?net2 net:type net:entity. + ?net2 net:has_structure ?req. + ?net2 net:has_node ?uw2. + ?net2 net:has_entity ?actorObject. + # net3: entity (target) + ?net3 a net:Instance. + ?net3 net:type net:entity. + ?net3 net:has_structure ?req. + ?net3 net:has_node ?uw3. + ?net3 net:has_entity ?targetObject. + # condition: aoj(net1, net2) et obj(net1, net3) + ?uw1 unl:aoj ?uw2. + ?uw1 (unl:obj|unl:res) ?uw3. + # Label: Id + ?uw1 unl:has_id ?uw1Id. + ?uw2 unl:has_id ?uw2Id. + ?uw3 unl:has_id ?uw3Id. + # URI (for Event Net) + cprm:Config_Parameters cprm:netURI ?netURI. + net:event rdfs:label ?eventLabel. + BIND (concat( ?netURI, ?eventLabel, '_') AS ?n1). + BIND (concat(?n1, ?uw1Id, '-', ?uw2Id, '-', ?uw3Id) AS ?n2). + BIND (uri(?n2) AS ?newNet). +}""" ; + sh:order 2.9 ; +. cts:compose-entity-modlist-1 rdf:type sh:SPARQLRule ; sh:construct """PREFIX owl: <http://www.w3.org/2002/07/owl#> @@ -1229,9 +1370,9 @@ cts:entity_extraction cts:event_extraction rdf:type owl:Class ; rdf:type sh:NodeShape ; - rdfs:label "property extraction" ; + rdfs:label "event extraction" ; rdfs:subClassOf cts:net_extension ; - sh:rule cts:compose-agt-verb-obj-as-event ; + sh:rule cts:compose-agt-verb-obj-as-simple-event ; . cts:extend-mod-list rdf:type sh:SPARQLRule ; @@ -1290,6 +1431,7 @@ cts:generation sh:rule cts:add-event ; sh:rule cts:add-feature ; sh:rule cts:add-list-of-entity-classes ; + sh:rule cts:add-state-property ; sh:rule cts:add-verb ; sh:rule cts:complement-list-of-entity-classes ; . @@ -1440,7 +1582,7 @@ WHERE { ?net1 net:has_node ?uw1. ?net1 net:has_entity ?entityObject1. # condition: agt/obj(uw0, uw1) - ?uw0 (unl:agt | unl:obj) ?uw1. + ?uw0 (unl:agt | unl:obj | unl:aoj) ?uw1. # UW: type UW-Occurrence and substructure of req sentence ?uw0 rdf:type unl:UW_Occurrence. ?uw0 unl:is_substructure_of ?req. @@ -1497,6 +1639,13 @@ cts:preprocessing sh:rule cts:define-uw-id ; sh:rule cts:link-to-scope-entry ; . +cts:state_property_extraction + rdf:type owl:Class ; + rdf:type sh:NodeShape ; + rdfs:label "state property extraction" ; + rdfs:subClassOf cts:net_extension ; + sh:rule cts:compose-aoj-verb-obj-as-simple-state-property ; +. cts:typify-modlist-entity rdf:type sh:SPARQLRule ; sh:construct """PREFIX owl: <http://www.w3.org/2002/07/owl#> diff --git a/frame/ontology-parameters.ttl b/frame/ontology-parameters.ttl index 6f33e43a..1840152f 100644 --- a/frame/ontology-parameters.ttl +++ b/frame/ontology-parameters.ttl @@ -51,6 +51,14 @@ fprm:System_Ontology rdfs:subClassOf fprm:Frame_Parameters ; fprm:frameURI "https://unsel.tetras-libre.fr/tenet/frame/system-ontology#" ; . +fprm:System_State_Property + rdf:type owl:Class ; + rdfs:comment "Parameters related to State Property (System Ontology)." ; + rdfs:label "state_property" ; + rdfs:subClassOf fprm:System_Ontology ; + fprm:class "State_Property" ; + fprm:objectProperty "statePropertyObjectProperty" ; +. fprm:System_Verb rdf:type owl:Class ; rdfs:comment "Parameters related to Verb (System Ontology)." ; @@ -112,7 +120,7 @@ fprm:system_agent fprm:system_attributive_verb rdf:type fprm:System_Verb ; rdfs:label "attributiveVerb" ; - fprm:class "attrbutive_verb" ; + fprm:class "attributive_verb" ; fprm:restriction "icl>be" ; . fprm:system_component diff --git a/frame/system-ontology.ttl b/frame/system-ontology.ttl index 8fb22cbf..643053e7 100644 --- a/frame/system-ontology.ttl +++ b/frame/system-ontology.ttl @@ -137,6 +137,11 @@ sys:place rdfs:label "place"@en ; rdfs:subClassOf sys:Feature ; . +sys:statePropertyObjectProperty + rdf:type rdf:Property ; + rdfs:label "state property object property" ; + rdfs:subPropertyOf sys:objectProperty ; +. sys:verbClassProperty rdf:type rdf:Property ; rdfs:label "verb property" ; diff --git a/prepare_work_data.py b/prepare_work_data.py index f4fc5d36..77dab3bb 100644 --- a/prepare_work_data.py +++ b/prepare_work_data.py @@ -37,7 +37,7 @@ f_param_file = "ontology-parameters.ttl" # Dev Tests base_uri = "https://unsel.tetras-libre.fr/tenet/working" -req_110 = "CCTP-SRSA-IP-20210831-R110/" +req_100 = "CCTP-SRSA-IP-20210831-R100/" req_300 = "CCTP-SRSA-IP-20210831-R300/" corpus_40 = "CCTP-SRSA-IP-20210831/" @@ -162,7 +162,7 @@ def run(corpus, output_ref, output_file): if __name__ == '__main__': run(req_300, 'R300', 'output300.ttl') - run(req_110, 'R110', 'output110.ttl') + run(req_100, 'R100', 'output100.ttl') run(corpus_40, 'CCTP-Corpus-40', 'output40.ttl') -- GitLab