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

Generic CTS to create atom nets

parent 3e5dd397
Branches
Tags
No related merge requests found
...@@ -29,7 +29,6 @@ cts:abstraction_extraction ...@@ -29,7 +29,6 @@ cts:abstraction_extraction
rdf:type sh:NodeShape ; rdf:type sh:NodeShape ;
rdfs:label "abstraction extension" ; rdfs:label "abstraction extension" ;
rdfs:subClassOf cts:net_extension ; rdfs:subClassOf cts:net_extension ;
sh:rule cts:create-abstraction-net ;
. .
cts:add-abstraction cts:add-abstraction
rdf:type sh:SPARQLRule ; rdf:type sh:SPARQLRule ;
...@@ -300,10 +299,11 @@ CONSTRUCT { ...@@ -300,10 +299,11 @@ CONSTRUCT {
WHERE { WHERE {
# net1: entity # net1: entity
?net1 a net:Instance. ?net1 a net:Instance.
?net1 net:type net:event. ?net1 net:type net:atom.
?net1 net:atomOf sys:Event.
?net1 net:has_structure ?req. ?net1 net:has_structure ?req.
?net1 net:has_verb ?verbObject1. ?net1 net:has_verb ?verbObject1.
?verbObject1 net:verbClass ?verbClass. ?verbObject1 net:has_parent_class ?verbClass.
?verbObject1 net:has_concept ?verbConcept. ?verbObject1 net:has_concept ?verbConcept.
?net1 net:has_actor ?actorObject1. ?net1 net:has_actor ?actorObject1.
?actorObject1 net:has_parent_class ?actorClass. ?actorObject1 net:has_parent_class ?actorClass.
...@@ -465,10 +465,11 @@ CONSTRUCT { ...@@ -465,10 +465,11 @@ CONSTRUCT {
WHERE { WHERE {
# net1: state property # net1: state property
?net1 a net:Instance. ?net1 a net:Instance.
?net1 net:type net:state_property. ?net1 net:type net:atom.
?net1 net:atomOf sys:State_Property.
?net1 net:has_structure ?req. ?net1 net:has_structure ?req.
?net1 net:has_verb ?verbObject1. ?net1 net:has_verb ?verbObject1.
?verbObject1 net:verbClass ?verbClass. ?verbObject1 net:has_parent_class ?verbClass.
?verbObject1 net:has_concept ?verbConcept. ?verbObject1 net:has_concept ?verbConcept.
?net1 net:has_actor ?actorObject1. ?net1 net:has_actor ?actorObject1.
?actorObject1 net:has_parent_class ?actorClass. ?actorObject1 net:has_parent_class ?actorClass.
...@@ -545,10 +546,11 @@ CONSTRUCT { ...@@ -545,10 +546,11 @@ CONSTRUCT {
WHERE { WHERE {
# net1: entity # net1: entity
?net1 a net:Instance. ?net1 a net:Instance.
?net1 net:type net:verb. ?net1 net:type net:atom.
?net1 net:atomOf sys:Verb.
?net1 net:has_structure ?req. ?net1 net:has_structure ?req.
?net1 net:has_verb ?verbObject1. ?net1 net:has_atom ?verbObject1.
?verbObject1 net:verbClass ?verbClass. ?verbObject1 net:has_parent_class ?verbClass.
?verbObject1 net:has_concept ?verbConcept. ?verbObject1 net:has_concept ?verbConcept.
# -- old --- ?verbObject1 net:has_instance ?mainInstance. # -- old --- ?verbObject1 net:has_instance ?mainInstance.
# Filter: entity not present in a class list # Filter: entity not present in a class list
...@@ -593,10 +595,7 @@ cts:batch_execution ...@@ -593,10 +595,7 @@ cts:batch_execution
sh:rule cts:compute-domain-range-of-event-object-properties ; sh:rule cts:compute-domain-range-of-event-object-properties ;
sh:rule cts:compute-domain-range-of-state-property-object-properties ; sh:rule cts:compute-domain-range-of-state-property-object-properties ;
sh:rule cts:compute-instance-uri-of-entity-net-object ; sh:rule cts:compute-instance-uri-of-entity-net-object ;
sh:rule cts:create-abstraction-net ; sh:rule cts:create-atom-net ;
sh:rule cts:create-entity-net ;
sh:rule cts:create-feature-net ;
sh:rule cts:create-verb-net ;
sh:rule cts:define-uw-id ; sh:rule cts:define-uw-id ;
sh:rule cts:extend-mod-list ; sh:rule cts:extend-mod-list ;
sh:rule cts:init-mod-list ; sh:rule cts:init-mod-list ;
...@@ -697,7 +696,8 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#> ...@@ -697,7 +696,8 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
CONSTRUCT { CONSTRUCT {
# Net: Event # Net: Event
?newNet a net:Instance. ?newNet a net:Instance.
?newNet net:type net:event. ?newNet net:type net:atom.
?newNet net:atomOf sys:Event.
?newNet net:has_structure ?req. ?newNet net:has_structure ?req.
?newNet net:has_node ?uw1, ?uw2, ?uw3. ?newNet net:has_node ?uw1, ?uw2, ?uw3.
?newNet net:has_actor ?actorObject. ?newNet net:has_actor ?actorObject.
...@@ -709,10 +709,11 @@ CONSTRUCT { ...@@ -709,10 +709,11 @@ CONSTRUCT {
WHERE { WHERE {
# net1: verb # net1: verb
?net1 a net:Instance. ?net1 a net:Instance.
?net1 net:type net:verb. ?net1 net:type net:atom.
?net1 net:atomOf sys:Verb.
?net1 net:has_structure ?req. ?net1 net:has_structure ?req.
?net1 net:has_node ?uw1. ?net1 net:has_node ?uw1.
?net1 net:has_verb ?verbObject. ?net1 net:has_atom ?verbObject.
# net2: entity (actor) # net2: entity (actor)
?net2 a net:Instance. ?net2 a net:Instance.
?net2 net:type net:atom. ?net2 net:type net:atom.
...@@ -767,7 +768,8 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#> ...@@ -767,7 +768,8 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
CONSTRUCT { CONSTRUCT {
# Net: State Property # Net: State Property
?newNet a net:Instance. ?newNet a net:Instance.
?newNet net:type net:state_property. ?newNet net:type net:atom.
?newNet net:atomOf sys:State_Property.
?newNet net:has_structure ?req. ?newNet net:has_structure ?req.
?newNet net:has_node ?uw1, ?uw2, ?uw3. ?newNet net:has_node ?uw1, ?uw2, ?uw3.
?newNet net:has_actor ?actorObject. ?newNet net:has_actor ?actorObject.
...@@ -779,10 +781,11 @@ CONSTRUCT { ...@@ -779,10 +781,11 @@ CONSTRUCT {
WHERE { WHERE {
# net1: verb # net1: verb
?net1 a net:Instance. ?net1 a net:Instance.
?net1 net:type net:verb. ?net1 net:type net:atom.
?net1 net:atomOf sys:Verb.
?net1 net:has_structure ?req. ?net1 net:has_structure ?req.
?net1 net:has_node ?uw1. ?net1 net:has_node ?uw1.
?net1 net:has_verb ?verbObject. ?net1 net:has_atom ?verbObject.
# net2: entity (actor) # net2: entity (actor)
?net2 a net:Instance. ?net2 a net:Instance.
?net2 net:type net:atom. ?net2 net:type net:atom.
...@@ -1193,7 +1196,8 @@ CONSTRUCT { ...@@ -1193,7 +1196,8 @@ CONSTRUCT {
WHERE { WHERE {
# net1: event # net1: event
?net1 a net:Instance. ?net1 a net:Instance.
?net1 net:type net:event. ?net1 net:type net:atom.
?net1 net:atomOf sys:Event.
?net1 net:has_structure ?req. ?net1 net:has_structure ?req.
?net1 net:has_verb ?verbObject1. ?net1 net:has_verb ?verbObject1.
?verbObject1 net:has_concept ?verbConcept. ?verbObject1 net:has_concept ?verbConcept.
...@@ -1250,7 +1254,8 @@ CONSTRUCT { ...@@ -1250,7 +1254,8 @@ CONSTRUCT {
WHERE { WHERE {
# net1: event # net1: event
?net1 a net:Instance. ?net1 a net:Instance.
?net1 net:type net:state_property. ?net1 net:type net:atom.
?net1 net:atomOf sys:State_Property.
?net1 net:has_structure ?req. ?net1 net:has_structure ?req.
?net1 net:has_verb ?verbObject1. ?net1 net:has_verb ?verbObject1.
?verbObject1 net:has_concept ?verbConcept. ?verbObject1 net:has_concept ?verbConcept.
...@@ -1315,71 +1320,7 @@ WHERE { ...@@ -1315,71 +1320,7 @@ WHERE {
}""" ; }""" ;
sh:order 3.02 ; sh:order 3.02 ;
. .
cts:create-abstraction-net cts:create-atom-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 Feature net
CONSTRUCT {
# Atom Object
?newObject a net:Object.
?newObject net:objectType ?atomMother.
?newObject net:has_node ?uw1.
?newObject net:has_mother_class ?atomMother.
?newObject net:has_parent_class ?atomClass.
?newObject net:has_concept ?concept1.
# Atom Net
?newNet a net:Instance.
?newNet net:type net:atom.
?newNet net:atomOf ?atomMother.
?newNet net:has_structure ?req.
?newNet net:has_node ?uw1.
?newNet net:has_atom ?newObject.
}
WHERE {
# Atom Description (from System Ontology)
?targetClass rdfs:subClassOf sys:Abstraction.
?targetClass sys:has_mother_class ?atomMother.
?targetClass sys:is_class ?atomClass.
?targetClass sys:has_restriction ?restriction.
# Absraction (from System Ontology)
?abstraction rdf:type fprm:System_Abstraction.
?abstraction fprm:class ?abstractionClass.
?abstraction fprm:restriction ?abstractionRestriction.
# UW: type UW-Occurrence and substructure of req sentence
?uw1 rdf:type unl:UW_Occurrence.
?uw1 unl:is_substructure_of ?req.
# ------ ?uw1 unl:is_occurrence_of ?lexTrg.
# Filter on label
?uw1 rdfs:label ?uw1Label.
FILTER ( regex(str(?uw1Label),str(?restriction)) ).
# Label: Id, concept
?uw1 unl:has_id ?uw1Id.
# URI (for Atom Object)
cprm:Config_Parameters cprm:netURI ?netURI.
cprm:Config_Parameters cprm:objectRef ?objectRef.
BIND (concat( ?netURI, ?objectRef) AS ?o1).
BIND (concat(?o1, ?uw1Id) AS ?o2).
BIND (uri(?o2) AS ?newObject).
# URI (for Atom Net)
cprm:Config_Parameters cprm:netURI ?netURI
BIND (strbefore(?uw1Label, '(') AS ?concept1).
BIND (concat( ?netURI, ?atomClass, '_') AS ?s1).
BIND (concat(?s1, ?uw1Id) AS ?s2).
BIND (uri(?s2) AS ?newNet).
}""" ;
sh:order 2.1 ;
.
cts:create-entity-net
rdf:type sh:SPARQLRule ; rdf:type sh:SPARQLRule ;
sh:construct """PREFIX owl: <http://www.w3.org/2002/07/owl#> sh:construct """PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
...@@ -1411,67 +1352,8 @@ CONSTRUCT { ...@@ -1411,67 +1352,8 @@ CONSTRUCT {
} }
WHERE { WHERE {
# Atom Description (from System Ontology) # Atom Description (from System Ontology)
?targetClass rdfs:subClassOf sys:Entity. # -- old --- ?targetClass rdfs:subClassOf sys:Entity.
?targetClass sys:has_mother_class ?atomMother. ?targetClass rdfs:subClassOf* sys:Structure.
?targetClass sys:is_class ?atomClass.
?targetClass 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.
# ------ ?uw1 unl:is_occurrence_of ?lexTrg.
# Filter on label
?uw1 rdfs:label ?uw1Label.
FILTER ( regex(str(?uw1Label),str(?restriction)) ).
# Label: Id, concept
?uw1 unl:has_id ?uw1Id.
BIND (strbefore(?uw1Label, '(') AS ?concept1).
# URI (for Atom Object)
cprm:Config_Parameters cprm:netURI ?netURI.
cprm:Config_Parameters cprm:objectRef ?objectRef.
BIND (concat( ?netURI, ?objectRef) AS ?o1).
BIND (concat(?o1, ?uw1Id) AS ?o2).
BIND (uri(?o2) AS ?newObject).
# URI (for Atom Net)
cprm:Config_Parameters cprm:netURI ?netURI.
BIND (concat( ?netURI, ?atomClass, '_') AS ?n1).
BIND (concat(?n1, ?uw1Id) AS ?n2).
BIND (uri(?n2) AS ?newNet).
}""" ;
sh:order 2.1 ;
.
cts:create-feature-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 Feature net
CONSTRUCT {
# Atom Object
?newObject a net:Object.
?newObject net:objectType ?atomMother.
?newObject net:has_node ?uw1.
?newObject net:has_mother_class ?atomMother.
?newObject net:has_parent_class ?atomClass.
?newObject net:has_concept ?concept1.
# Atom Net
?newNet a net:Instance.
?newNet net:type net:atom.
?newNet net:atomOf ?atomMother.
?newNet net:has_structure ?req.
?newNet net:has_node ?uw1.
?newNet net:has_atom ?newObject.
}
WHERE {
# Atom Description (from System Ontology)
?targetClass rdfs:subClassOf sys:Feature.
?targetClass sys:has_mother_class ?atomMother. ?targetClass sys:has_mother_class ?atomMother.
?targetClass sys:is_class ?atomClass. ?targetClass sys:is_class ?atomClass.
?targetClass sys:has_restriction ?restriction. ?targetClass sys:has_restriction ?restriction.
...@@ -1499,63 +1381,6 @@ WHERE { ...@@ -1499,63 +1381,6 @@ WHERE {
}""" ; }""" ;
sh:order 2.1 ; sh:order 2.1 ;
. .
cts:create-verb-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 Entity net
CONSTRUCT {
# Object: entity
?newVerb a net:Object.
?newVerb net:objectType sys:Verb.
?newVerb net:has_node ?uw1.
?newVerb net:verbClass ?verbClass.
?newVerb net:has_concept ?concept1.
# Net: Entity
?newNet a net:Instance.
?newNet net:type net:verb.
?newNet net:has_structure ?req.
?newNet net:has_node ?uw1.
?newNet net:has_verb ?newVerb.
}
WHERE {
# Verb (from System Ontology)
?verb rdf:type fprm:System_Verb.
?verb fprm:class ?verbClass.
?verb fprm:restriction ?verbRestriction.
# UW: type UW-Occurrence and substructure of req sentence
?uw1 rdf:type unl:UW_Occurrence.
?uw1 unl:is_substructure_of ?req.
# ------ ?uw1 unl:is_occurrence_of ?lexTrg.
# Filter
?uw1 rdfs:label ?uw1Label.
FILTER ( regex(str(?uw1Label),str(?verbRestriction)) ).
# Label: Id, concept
?uw1 unl:has_id ?uw1Id.
BIND (strbefore(?uw1Label, '(') AS ?concept1).
# 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, ?uw1Id) AS ?e2).
BIND (uri(?e2) AS ?newVerb).
# URI (for Entity Net)
cprm:Config_Parameters cprm:netURI ?netURI.
BIND (concat( ?netURI, ?verbClass, '_') AS ?n1).
BIND (concat(?n1, ?uw1Id) AS ?n2).
BIND (uri(?n2) AS ?newNet).
}""" ;
sh:order 2.1 ;
.
cts:define-uw-id cts:define-uw-id
rdf:type sh:SPARQLRule ; rdf:type sh:SPARQLRule ;
sh:construct """PREFIX owl: <http://www.w3.org/2002/07/owl#> sh:construct """PREFIX owl: <http://www.w3.org/2002/07/owl#>
...@@ -1600,7 +1425,7 @@ cts:entity_extraction ...@@ -1600,7 +1425,7 @@ cts:entity_extraction
sh:rule cts:compose-entity-modlist-1 ; sh:rule cts:compose-entity-modlist-1 ;
sh:rule cts:compose-entity-modlist-2 ; sh:rule cts:compose-entity-modlist-2 ;
sh:rule cts:compose-entity-modlist-3 ; sh:rule cts:compose-entity-modlist-3 ;
sh:rule cts:create-entity-net ; sh:rule cts:create-atom-net ;
sh:rule cts:extend-mod-list ; sh:rule cts:extend-mod-list ;
sh:rule cts:init-mod-list ; sh:rule cts:init-mod-list ;
sh:rule cts:instantiate-classlist-by-extension-1 ; sh:rule cts:instantiate-classlist-by-extension-1 ;
...@@ -1659,7 +1484,6 @@ cts:feature_extraction ...@@ -1659,7 +1484,6 @@ cts:feature_extraction
rdf:type sh:NodeShape ; rdf:type sh:NodeShape ;
rdfs:label "feature extraction" ; rdfs:label "feature extraction" ;
rdfs:subClassOf cts:net_extension ; rdfs:subClassOf cts:net_extension ;
sh:rule cts:create-feature-net ;
. .
cts:generation cts:generation
rdf:type owl:Class ; rdf:type owl:Class ;
......
...@@ -203,7 +203,7 @@ if __name__ == '__main__': ...@@ -203,7 +203,7 @@ if __name__ == '__main__':
#run(req_100, 'R100', 'output100.ttl') #run(req_100, 'R100', 'output100.ttl')
#run(req_200, 'R200', 'output200.ttl') #run(req_200, 'R200', 'output200.ttl')
run(req_300, 'R300b', 'output300b.ttl') run(req_300, 'R300b', 'output300b.ttl')
run(corpus_40, 'Corpus-CCTP-40b', 'outputCCTP40b.ttl') run(corpus_40, 'Corpus-CCTP-40c', 'outputCCTP40c.ttl')
#run(corpus_ERTMS, 'Corpus-ERTMS', 'outputERTMS.ttl') #run(corpus_ERTMS, 'Corpus-ERTMS', 'outputERTMS.ttl')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment