From 1aed1978dd00e11ba12011c302539e5b8cbd7d12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Lamercerie?=
 <aurelien.lamercerie@laposte.net>
Date: Wed, 17 Nov 2021 00:23:47 +0100
Subject: [PATCH] CTS update: atomOf points to the class containing seeds
 (insteads of mother class)

---
 config/semantic-net.ttl         | 10 ++++++
 config/transduction-schemes.ttl | 63 +++++++++++++++++++++++++++++----
 frame/system-ontology.ttl       | 59 ++++++++++++++++++++++++++----
 prepare_work_data.py            |  8 ++---
 4 files changed, 123 insertions(+), 17 deletions(-)

diff --git a/config/semantic-net.ttl b/config/semantic-net.ttl
index 01b13021..a141868d 100644
--- a/config/semantic-net.ttl
+++ b/config/semantic-net.ttl
@@ -253,6 +253,16 @@ net:objectValue
   rdfs:label "valuations"@fr ;
   rdfs:subPropertyOf net:objectProperty ;
 .
+net:relation
+  rdf:type owl:Class ;
+  rdfs:label "relation" ;
+  rdfs:subClassOf net:Type ;
+.
+net:relationOf
+  rdf:type rdf:Property ;
+  rdfs:label "relation of" ;
+  rdfs:subPropertyOf net:typeProperty ;
+.
 net:state_property
   rdf:type owl:Class ;
   rdfs:label "stateProperty" ;
diff --git a/config/transduction-schemes.ttl b/config/transduction-schemes.ttl
index 7637a30b..b4694ce2 100644
--- a/config/transduction-schemes.ttl
+++ b/config/transduction-schemes.ttl
@@ -296,6 +296,7 @@ cts:batch_execution
   sh:rule cts:compute-domain-range-of-state-property-object-properties ;
   sh:rule cts:compute-instance-uri-of-net-object ;
   sh:rule cts:create-atom-net ;
+  sh:rule cts:create-relation-net ;
   sh:rule cts:create-unary-atom-list-net ;
   sh:rule cts:define-uw-id ;
   sh:rule cts:extend-atom-list-net ;
@@ -402,7 +403,7 @@ WHERE {
    # net1: verb
    ?net1 a net:Instance.
    ?net1 net:type net:atom.
-   ?net1 net:atomOf sys:Verb.
+   ?net1 net:atomOf sys:action_verb.
    ?net1 net:has_structure ?req.
    ?net1 net:has_node ?uw1.
    ?net1 net:has_atom ?verbObject.
@@ -474,7 +475,7 @@ WHERE {
    # net1: verb
    ?net1 a net:Instance.
    ?net1 net:type net:atom.
-   ?net1 net:atomOf sys:Verb.
+   ?net1 net:atomOf sys:attributive_verb.
    ?net1 net:has_structure ?req.
    ?net1 net:has_node ?uw1.
    ?net1 net:has_atom ?verbObject.
@@ -881,10 +882,10 @@ CONSTRUCT {
 }
 WHERE {
    # Atom Description (from System Ontology)
-   ?targetClass rdfs:subClassOf* sys:Structure.
-   ?targetClass sys:has_mother_class ?atomMother.
-   ?targetClass sys:is_class ?atomClass.
-   ?targetClass sys:has_restriction ?restriction.
+   ?atomMother rdfs:subClassOf* sys:Structure.
+   # -- old --- ?targetClass sys:has_mother_class ?atomMother.
+   ?atomMother sys:is_class ?atomClass.
+   ?atomMother sys:has_restriction ?restriction.
    # UW: type UW-Occurrence and substructure of req sentence
    ?uw1 rdf:type unl:UW_Occurrence.
    ?uw1 unl:is_substructure_of ?req.
@@ -909,6 +910,56 @@ WHERE {
 }""" ;
   sh:order 2.11 ;
 .
+cts:create-relation-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#>
+
+# -- Create relation net
+CONSTRUCT {
+   # Net: Relation
+   ?newNet a net:Instance.
+   ?newNet net:type net:relation.
+   ?newNet net:relationOf ?relationMother.
+   ?newNet net:has_structure ?req.
+   ?newNet net:has_node ?uw1.
+   ?newNet net:has_verb ?verbObject.	
+   # -- todo? --- ?newNet net:has_possible_domain ?domainClass.	
+   # -- todo? --- ?newNet net:has_possible_range ?rangeClass.	
+}
+WHERE {
+   # Relation Description (from System Ontology)
+   ?targetProperty rdfs:subPropertyOf* sys:Relation.
+   ?targetProperty sys:has_mother_property ?relationMother.
+   ?targetProperty sys:has_reference ?relationReference.
+   ?targetProperty sys:has_restriction_on_class ?classRestriction.
+   # net1: atom of relation
+   ?net1 a net:Instance.
+   ?net1 net:type net:atom.
+   ?net1 net:atomOf ?atomCategory.
+   ?atomCategory rdfs:subClassOf* ?classRestriction.
+   ?net1 net:has_structure ?req.
+   ?net1 net:has_node ?uw1.
+   ?net1 net:has_atom ?verbObject.
+   ?verbObject net:has_parent_class ?classRestriction.
+   # Label: Id
+   ?uw1 unl:has_id ?uw1Id. 
+   # URI (for Event Net)
+   cprm:Config_Parameters cprm:netURI ?netURI.
+   BIND (concat( ?netURI, ?relationReference, '_') AS ?n1).
+   BIND (concat(?n1, ?uw1Id) AS ?n2).
+   BIND (uri(?n2) AS ?newNet).
+}""" ;
+  sh:order 2.41 ;
+.
 cts:create-unary-atom-list-net
   rdf:type sh:SPARQLRule ;
   sh:construct """PREFIX owl: <http://www.w3.org/2002/07/owl#>
diff --git a/frame/system-ontology.ttl b/frame/system-ontology.ttl
index adece0d4..0e498b68 100644
--- a/frame/system-ontology.ttl
+++ b/frame/system-ontology.ttl
@@ -47,6 +47,14 @@ sys:Feature
   rdfs:subClassOf sys:Structure ;
   sys:is_class "Feature" ;
 .
+sys:Relation
+  rdf:type rdf:Property ;
+  rdfs:label "system property" ;
+.
+sys:Seed
+  rdf:type rdf:Property ;
+  rdfs:label "seed property" ;
+.
 sys:State_Property
   rdf:type owl:Class ;
   rdfs:label "Propriété d'état"@fr ;
@@ -75,6 +83,14 @@ sys:abstract_thing
   sys:has_restriction "icl>abstract_thing" ;
   sys:is_class "abstract_thing" ;
 .
+sys:action
+  rdf:type rdf:Property ;
+  rdfs:label "action" ;
+  rdfs:subPropertyOf sys:Relation ;
+  sys:has_mother_property "sys:action" ;
+  sys:has_reference "relation_action" ;
+  sys:has_restriction_on_class "action_verb" ;
+.
 sys:action_verb
   rdf:type owl:Class ;
   rdfs:label "action verb" ;
@@ -153,7 +169,7 @@ sys:has_feature
 sys:has_frame_base_uri
   rdf:type rdf:Property ;
   rdfs:label "has frame base uri" ;
-  rdfs:subPropertyOf sys:seedProperty ;
+  rdfs:subPropertyOf sys:Seed ;
   sys:has_frame_base_uri "https://unsel.tetras-libre.fr/tenet/frame/system-ontology/" ;
 .
 sys:has_frame_uri
@@ -165,24 +181,49 @@ sys:has_mother_class
   rdf:type rdf:Property ;
   rdfs:label "has mother class" ;
   rdfs:range owl:Thing ;
-  rdfs:subPropertyOf sys:seedProperty ;
+  rdfs:subPropertyOf sys:Seed ;
   sys:has_mother_class "Entity" ;
   sys:has_restriction "icl>administrator" ;
   sys:has_restriction "icl>operator" ;
   sys:has_restriction "icl>person" ;
   sys:is_class "agent" ;
 .
+sys:has_mother_property
+  rdf:type rdf:Property ;
+  rdfs:label "has mother property" ;
+  rdfs:subPropertyOf sys:Seed ;
+.
 sys:has_object_property
   rdf:type rdf:Property ;
   rdfs:label "has object property" ;
-  rdfs:subPropertyOf sys:seedProperty ;
+  rdfs:subPropertyOf sys:Seed ;
   sys:has_object_property "eventObjectProperty" ;
   sys:is_class "Event" ;
 .
+sys:has_reference
+  rdf:type rdf:Property ;
+  rdfs:label "is property" ;
+  rdfs:subPropertyOf sys:Seed ;
+.
 sys:has_restriction
   rdf:type rdf:Property ;
   rdfs:label "has restriction" ;
-  rdfs:subPropertyOf sys:seedProperty ;
+  rdfs:subPropertyOf sys:Seed ;
+.
+sys:has_restriction_on_class
+  rdf:type rdf:Property ;
+  rdfs:label "has restriction on  class" ;
+  rdfs:subPropertyOf sys:Seed ;
+.
+sys:has_restriction_on_unl_relation_source
+  rdf:type rdf:Property ;
+  rdfs:label "has restriction on unl relation source" ;
+  rdfs:subPropertyOf sys:Seed ;
+.
+sys:has_restriction_on_unl_relation_target
+  rdf:type rdf:Property ;
+  rdfs:label "has restriction on unl relation target" ;
+  rdfs:subPropertyOf sys:Seed ;
 .
 sys:has_target
   rdf:type rdf:Property ;
@@ -197,7 +238,7 @@ sys:has_verb
 sys:is_class
   rdf:type rdf:Property ;
   rdfs:label "is class" ;
-  rdfs:subPropertyOf sys:seedProperty ;
+  rdfs:subPropertyOf sys:Seed ;
   sys:has_object_property "statePropertyObjectProperty" ;
   sys:is_class "State_Property" ;
 .
@@ -225,9 +266,13 @@ sys:place
   sys:has_restriction "icl>place" ;
   sys:is_class "place" ;
 .
-sys:seedProperty
+sys:stateProperty
   rdf:type rdf:Property ;
-  rdfs:label "seed property" ;
+  rdfs:label "state property" ;
+  rdfs:subPropertyOf sys:Relation ;
+  sys:has_mother_property "sys:stateProperty" ;
+  sys:has_reference "relation_stateProperty" ;
+  sys:has_restriction_on_class "attributive_verb" ;
 .
 sys:statePropertyObjectProperty
   rdf:type rdf:Property ;
diff --git a/prepare_work_data.py b/prepare_work_data.py
index 04f1f483..95ec501c 100644
--- a/prepare_work_data.py
+++ b/prepare_work_data.py
@@ -204,10 +204,10 @@ def run(corpus, source_ref, target_ref):
 if __name__ == '__main__':
     target_ref = "system"
     #target_ref = "environment"
-    run(req_100, 'R100d', target_ref) 
-    run(req_200, 'R200d', target_ref)
-    run(req_300, 'R300d', target_ref) 
-    run(corpus_40, 'Corpus-CCTP-40d', target_ref)
+    run(req_100, 'R100e', target_ref) 
+    run(req_200, 'R200e', target_ref)
+    run(req_300, 'R300e', target_ref) 
+    #run(corpus_40, 'Corpus-CCTP-40e', target_ref)
     #run(corpus_ERTMS, 'Corpus-ERTMS', target_ref)
     #run(corpus_PEV, 'Corpus-PEV', target_ref)
 
-- 
GitLab