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

harmonizes the CTS of the feature and entity nets

parent 9c92fd34
No related branches found
No related tags found
No related merge requests found
......@@ -15,35 +15,50 @@ net:Instance
rdfs:label "Semantic Net Instance" ;
rdfs:subClassOf net:Structure ;
.
net:Net_Type
rdf:type owl:Class ;
rdfs:label "Semantic Net Type" ;
rdfs:subClassOf net:Structure ;
.
net:Object
rdf:type owl:Class ;
rdfs:label "Object using in semantic net instance" ;
rdfs:subClassOf net:Structure ;
.
net:Object_Type
rdf:type owl:Class ;
rdfs:label "Object Type" ;
rdfs:subClassOf net:Structure ;
.
net:Structure
rdf:type owl:Class ;
rdfs:comment "A semantic net captures a set of nodes, and associates this set with type(s) and value(s)." ;
rdfs:label "Semantic Net Structure" ;
.
net:Type
rdf:type owl:Class ;
rdfs:label "Semantic Net Type" ;
rdfs:subClassOf net:Structure ;
.
net:abstraction
rdf:type owl:Class ;
rdfs:label "abstraction" ;
rdfs:subClassOf net:Type ;
rdfs:subClassOf net:Net_Type ;
.
net:abstractionClass
rdf:type rdf:Property ;
rdfs:label "abstraction class" ;
rdfs:subPropertyOf net:objectValue ;
.
net:atom
rdf:type owl:Class ;
rdfs:label "atom" ;
rdfs:subClassOf net:Object_Type ;
.
net:atomType
rdf:type rdf:Property ;
rdfs:label "atom type" ;
rdfs:subPropertyOf net:objectType ;
.
net:class
rdf:type owl:Class ;
rdfs:label "class" ;
rdfs:subClassOf net:Type ;
rdfs:subClassOf net:Net_Type ;
.
net:classUri
rdf:type rdf:Property ;
......@@ -53,12 +68,12 @@ net:classUri
net:class_list
rdf:type owl:Class ;
rdfs:label "classList" ;
rdfs:subClassOf net:Type ;
rdfs:subClassOf net:Net_Type ;
.
net:complement
rdf:type owl:Class ;
rdfs:label "complement" ;
rdfs:subClassOf net:Type ;
rdfs:subClassOf net:Net_Type ;
.
net:complement_mod_list
rdf:type owl:Class ;
......@@ -73,7 +88,7 @@ net:concept
net:entity
rdf:type owl:Class ;
rdfs:label "entity" ;
rdfs:subClassOf net:Type ;
rdfs:subClassOf net:Net_Type ;
.
net:entityClass
rdf:type rdf:Property ;
......@@ -98,12 +113,12 @@ net:entity_mod_list
net:event
rdf:type owl:Class ;
rdfs:label "event" ;
rdfs:subClassOf net:Type ;
rdfs:subClassOf net:Net_Type ;
.
net:feature
rdf:type owl:Class ;
rdfs:label "feature" ;
rdfs:subClassOf net:Type ;
rdfs:subClassOf net:Net_Type ;
.
net:featureClass
rdf:type rdf:Property ;
......@@ -112,7 +127,12 @@ net:featureClass
.
net:has_actor
rdf:type rdf:Property ;
rdfs:label "has verb" ;
rdfs:label "has actor" ;
rdfs:subPropertyOf net:has_object ;
.
net:has_atom
rdf:type rdf:Property ;
rdfs:label "has atom" ;
rdfs:subPropertyOf net:has_object ;
.
net:has_entity
......@@ -162,7 +182,7 @@ net:has_subClass
.
net:has_target
rdf:type rdf:Property ;
rdfs:label "has verb" ;
rdfs:label "has target" ;
rdfs:subPropertyOf net:has_object ;
.
net:has_verb
......@@ -193,7 +213,7 @@ net:modCat2
net:mod_list
rdf:type owl:Class ;
rdfs:label "modList" ;
rdfs:subClassOf net:Type ;
rdfs:subClassOf net:Net_Type ;
.
net:objectAttribute
rdf:type rdf:Property ;
......@@ -209,6 +229,11 @@ net:objectValue
rdfs:label "valuations"@fr ;
rdfs:subPropertyOf net:objectAttribute ;
.
net:parentClass
rdf:type rdf:Property ;
rdfs:label "parent class" ;
rdfs:subPropertyOf net:objectValue ;
.
net:parentClassUri
rdf:type rdf:Property ;
rdfs:label "parent class uri" ;
......@@ -221,7 +246,7 @@ net:property
net:state_property
rdf:type owl:Class ;
rdfs:label "stateProperty" ;
rdfs:subClassOf net:Type ;
rdfs:subClassOf net:Net_Type ;
.
net:type
rdf:type rdf:Property ;
......@@ -231,7 +256,7 @@ net:type
net:verb
rdf:type owl:Class ;
rdfs:label "verb" ;
rdfs:subClassOf net:Type ;
rdfs:subClassOf net:Net_Type ;
.
net:verbClass
rdf:type rdf:Property ;
......
......@@ -251,10 +251,10 @@ WHERE {
?net1 a net:Instance.
?net1 net:type net:entity.
?net1 net:has_structure ?req.
?net1 net:has_entity ?entityObject1.
?entityObject1 net:entityClass ?entityClass.
?entityObject1 net:concept ?entityConcept.
?entityObject1 net:entityInstance ?mainInstance.
?net1 net:has_atom ?atomObject1.
?atomObject1 net:parentClass ?entityClass.
?atomObject1 net:concept ?entityConcept.
?atomObject1 net:entityInstance ?mainInstance.
# Filter: entity not present in a class list
FILTER NOT EXISTS { ?net2 net:has_subClass ?entityConcept}
# URI (for classes)
......@@ -313,12 +313,12 @@ WHERE {
?verbObject1 net:verbClass ?verbClass.
?verbObject1 net:concept ?verbConcept.
?net1 net:has_actor ?actorObject1.
?actorObject1 net:entityClass ?actorClass.
?actorObject1 net:parentClass ?actorClass.
?actorObject1 net:concept ?actorConcept.
?actorObject1 net:entityInstance ?actorInstance.
?actorObject1 net:instanceUri ?actorInstanceUri.
?net1 net:has_target ?targetObject1.
?targetObject1 net:entityClass ?targetClass.
?targetObject1 net:parentClass ?targetClass.
?targetObject1 net:concept ?targetConcept.
?targetObject1 net:entityInstance ?targetInstance.
?targetObject1 net:instanceUri ?targetInstanceUri.
......@@ -387,8 +387,9 @@ WHERE {
?net1 a net:Instance.
?net1 net:type net:feature.
?net1 net:has_structure ?req.
?net1 net:featureClass ?featureClass.
?net1 net:concept ?featureConcept.
?net1 net:has_atom ?atomObject1.
?atomObject1 net:parentClass ?featureClass.
?atomObject1 net:concept ?featureConcept.
# Filter: entity not present in a class list
FILTER NOT EXISTS { ?net2 net:class2 ?featureConcept}
# URI: class
......@@ -744,13 +745,13 @@ WHERE {
?net2 net:type net:entity.
?net2 net:has_structure ?req.
?net2 net:has_node ?uw2.
?net2 net:has_entity ?actorObject.
?net2 net:has_atom ?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.
?net3 net:has_atom ?targetObject.
# condition: agt(net1, net2) et obj(net1, net3)
?uw1 unl:agt ?uw2.
?uw1 (unl:obj|unl:res) ?uw3.
......@@ -812,13 +813,13 @@ WHERE {
?net2 net:type net:entity.
?net2 net:has_structure ?req.
?net2 net:has_node ?uw2.
?net2 net:has_entity ?actorObject.
?net2 net:has_atom ?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.
?net3 net:has_atom ?targetObject.
# condition: aoj(net1, net2) et obj(net1, net3)
?uw1 unl:aoj ?uw2.
?uw1 (unl:obj|unl:res) ?uw3.
......@@ -889,7 +890,7 @@ CONSTRUCT {
?newNet net:has_structure ?req.
?newNet net:has_node ?uw1, ?uw2, ?uw3.
?newNet net:entityClass ?entityClass.
?newNet net:has_mainClass ?entityObject1.
?newNet net:has_mainClass ?atomObject1.
?newNet net:has_subClass ?newEntity2, ?newEntity3.
?newNet net:has_feature ?newFeature2, ?newFeature3.
}
......@@ -899,9 +900,9 @@ WHERE {
?net1 net:type net:entity.
?net1 net:has_structure ?req.
?net1 net:has_node ?uw1.
?net1 net:has_entity ?entityObject1.
?entityObject1 net:entityClass ?entityClass.
?entityObject1 net:concept ?mainEntity.
?net1 net:has_atom ?atomObject1.
?atomObject1 net:parentClass ?entityClass.
?atomObject1 net:concept ?mainEntity.
# condition: mod(net1, net2)
?uw1 unl:mod ?uw2.
# net2: complement modList
......@@ -999,7 +1000,7 @@ CONSTRUCT {
?newNet net:has_structure ?req.
?newNet net:has_node ?uw1, ?uw2, ?uw3.
?newNet net:entityClass ?entityClass1.
?newNet net:has_mainClass ?entityObject1.
?newNet net:has_mainClass ?atomObject1.
?newNet net:has_subClass ?newEntity2, ?newEntity3.
?newNet net:has_feature ?newFeature2, ?newFeature3.
}
......@@ -1009,9 +1010,9 @@ WHERE {
?net1 net:type net:entity.
?net1 net:has_structure ?req.
?net1 net:has_node ?uw1.
?net1 net:has_entity ?entityObject1.
?entityObject1 net:entityClass ?entityClass1.
?entityObject1 net:concept ?mainEntity.
?net1 net:has_atom ?atomObject1.
?atomObject1 net:parentClass ?entityClass1.
?atomObject1 net:concept ?mainEntity.
# condition: mod(net1, net2)
?uw1 unl:mod ?uw2.
# net2: entity modList
......@@ -1096,7 +1097,7 @@ CONSTRUCT {
?newNet net:has_structure ?req.
?newNet net:has_node ?uw1, ?uw2, ?uw3.
?newNet net:entityClass ?entityClass1.
?newNet net:has_mainClass ?entityObject1.
?newNet net:has_mainClass ?atomObject1.
?newNet net:has_subClass ?newEntity2, ?newEntity3.
}
WHERE {
......@@ -1105,9 +1106,9 @@ WHERE {
?net1 net:type net:entity.
?net1 net:has_structure ?req.
?net1 net:has_node ?uw1.
?net1 net:has_entity ?entityObject1.
?entityObject1 net:entityClass ?entityClass1.
?entityObject1 net:concept ?mainEntity.
?net1 net:has_atom ?atomObject1.
?atomObject1 net:parentClass ?entityClass1.
?atomObject1 net:concept ?mainEntity.
# condition: mod(net1, net2)
?uw1 unl:mod ?uw2.
# net2: entity modList
......@@ -1177,7 +1178,7 @@ CONSTRUCT {
WHERE {
# net1: entity
?object a net:Object.
?object net:entityClass ?objectClass.
?object net:parentClass ?objectClass.
?object net:concept ?objectConcept.
# URI (for classes and instance)
fprm:System_Ontology fprm:frameURI ?frameURI.
......@@ -1324,7 +1325,7 @@ CONSTRUCT {
WHERE {
# net1: entity
?object a net:Object.
?object net:entityClass ?objectClass.
?object net:parentClass ?objectClass.
?object net:entityInstance ?objectInstance.
# URI (for classes and instance)
fprm:System_Ontology fprm:frameURI ?frameURI.
......@@ -1394,20 +1395,25 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
# -- Create Entity net
CONSTRUCT {
# Object: entity
?newEntity a net:Object.
?newEntity net:objectType sys:Entity.
?newEntity net:node ?uw1.
?newEntity net:entityClass ?entityClass.
?newEntity net:concept ?concept1.
?newAtom a net:Object.
?newAtom net:objectType net:atom.
?newAtom net:atomType ?atomType.
# -- old --- ?newAtom net:objectType sys:Entity.
?newAtom net:node ?uw1.
?newAtom net:parentClass ?entityClass.
# -- old --- ?newAtom net:entityClass ?entityClass.
?newAtom net:concept ?concept1.
# Net: Entity
?newNet a net:Instance.
?newNet net:type net:entity.
?newNet net:has_structure ?req.
?newNet net:has_node ?uw1.
?newNet net:has_entity ?newEntity.
?newNet net:has_atom ?newAtom.
# -- old --- ?newNet net:has_entity ?newAtom.
}
WHERE {
# Entity (from System Ontology)
# Atom Description (from System Ontology)
fprm:System_Entity fprm:class ?atomType.
?entity rdf:type fprm:System_Entity.
?entity fprm:class ?entityClass.
?entity fprm:restriction ?entityRestriction.
......@@ -1415,18 +1421,18 @@ WHERE {
?uw1 rdf:type unl:UW_Occurrence.
?uw1 unl:is_substructure_of ?req.
# ------ ?uw1 unl:is_occurrence_of ?lexTrg.
# Filter
# Filter on label
?uw1 rdfs:label ?uw1Label.
FILTER ( regex(str(?uw1Label),str(?entityRestriction)) ).
# Label: Id, concept
?uw1 unl:has_id ?uw1Id.
BIND (strbefore(?uw1Label, '(') AS ?concept1).
# URI (for Entity Object)
# URI (for Atom 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 ?newEntity).
BIND (uri(?e2) AS ?newAtom).
# URI (for Entity Net)
cprm:Config_Parameters cprm:netURI ?netURI.
BIND (concat( ?netURI, ?entityClass, '_') AS ?n1).
......@@ -1450,32 +1456,49 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
# -- Create Feature net
CONSTRUCT {
?semNet a net:Instance.
?semNet net:type net:feature.
?semNet net:has_structure ?req.
?semNet net:has_node ?uw1.
?semNet net:featureClass ?featureClass.
?semNet net:concept ?concept1.
# Object: atom (feature)
?newAtom a net:Object.
?newAtom net:objectType net:atom.
?newAtom net:atomType ?atomType.
?newAtom net:node ?uw1.
?newAtom net:parentClass ?featureClass.
?newAtom net:concept ?concept1.
# Net: Feature
?newNet a net:Instance.
?newNet net:type net:feature.
?newNet net:has_structure ?req.
?newNet net:has_node ?uw1.
# -- old --- ?newNet net:featureClass ?featureClass.
# -- old --- ?newNet net:concept ?concept1.
?newNet net:has_atom ?newAtom.
}
WHERE {
# Feature (from System Ontology)
?entity rdf:type fprm:System_Feature.
?entity fprm:class ?featureClass.
?entity fprm:restriction ?featureRestriction.
# Atom Description (from System Ontology)
fprm:System_Feature fprm:class ?atomType.
?atomDescription rdf:type fprm:System_Feature.
?atomDescription fprm:class ?featureClass.
?atomDescription fprm:restriction ?featureRestriction.
# 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.
# Label(s) / URI
# Filter on label
?uw1 rdfs:label ?uw1Label.
FILTER ( regex(str(?uw1Label),str(?featureRestriction)) ).
# Label: Id, concept
?uw1 unl:has_id ?uw1Id.
cprm:Config_Parameters cprm:netURI ?netURI
BIND (strbefore(?uw1Label, '(') AS ?concept1).
BIND (concat( ?netURI, ?featureClass, '_') AS ?s1).
BIND (concat(?s1, ?uw1Id) AS ?s2).
BIND (uri(?s2) AS ?semNet).
# Filter
FILTER ( regex(str(?uw1Label),str(?featureRestriction)) ).
# URI (for Atom Object)
cprm:Config_Parameters cprm:netURI ?netURI.
cprm:Config_Parameters cprm:objectRef ?objectRef.
BIND (concat( ?netURI, ?objectRef) AS ?a1).
BIND (concat(?a1, ?uw1Id) AS ?a2).
BIND (uri(?a2) AS ?newAtom).
# URI (for Entity Net)
cprm:Config_Parameters cprm:netURI ?netURI.
BIND (concat( ?netURI, ?featureClass, '_') AS ?n1).
BIND (concat(?n1, ?uw1Id) AS ?n2).
BIND (uri(?n2) AS ?newNet).
}""" ;
sh:order 2.1 ;
.
......@@ -1726,8 +1749,8 @@ WHERE {
?net1 a net:Instance.
?net1 net:type net:entity.
?net1 net:has_structure ?sameReq.
?net1 net:has_entity ?sameObject1.
# -- old --- ?entityObject1 net:entityClass ?sameClass.
?net1 net:has_atom ?sameObject1.
# -- old --- ?entityObject1 net:parentClass ?sameClass.
# -- old --- ?entityObject1 net:concept ?sameEntity.
?sameObject1 net:entityInstance ?instanceName1.
# net2: entity classList
......@@ -1798,7 +1821,7 @@ PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
# -- Create Entity net
CONSTRUCT {
# Object: entity
?entityObject1 net:entityInstance ?instanceName.
?atomObject1 net:entityInstance ?instanceName.
}
WHERE {
# net1: entity (with entity object)
......@@ -1806,7 +1829,7 @@ WHERE {
?net1 net:type net:entity.
?net1 net:has_structure ?req.
?net1 net:has_node ?uw1.
?net1 net:has_entity ?entityObject1.
?net1 net:has_atom ?atomObject1.
# condition: agt/obj(uw0, uw1)
?uw0 (unl:agt | unl:obj | unl:aoj) ?uw1.
# UW: type UW-Occurrence and substructure of req sentence
......
......@@ -42,7 +42,7 @@ fprm:System_Feature
rdfs:comment "Parameters related to Feature (System Ontology)." ;
rdfs:label "feature" ;
rdfs:subClassOf fprm:System_Ontology ;
fprm:class "Feature" ;
fprm:class "sys:Feature" ;
.
fprm:System_Ontology
rdf:type owl:Class ;
......
......@@ -142,6 +142,26 @@ def export_result(work_graph, export_ref, export_file):
format='turtle')
def finalize_export_file(export_file):
""" finalize the export file by adding some useful prefixes """
with open(export_file, "rt") as file:
x = file.read()
with open(export_file, "wt") as file:
x = x.replace(
"@prefix sys: <https://unsel.tetras-libre.fr/tenet/frame/system-ontology/> .",
"""@prefix sys: <https://unsel.tetras-libre.fr/tenet/frame/system-ontology/> .
@prefix sys-Event: <https://unsel.tetras-libre.fr/tenet/frame/system-ontology/Event#> .
@prefix sys-State_Property: <https://unsel.tetras-libre.fr/tenet/frame/system-ontology/State_Property#> .
@prefix sys-abstract_thing: <https://unsel.tetras-libre.fr/tenet/frame/system-ontology/abstract_thing#> .
@prefix sys-action_verb: <https://unsel.tetras-libre.fr/tenet/frame/system-ontology/action_verb#> .
@prefix sys-agent: <https://unsel.tetras-libre.fr/tenet/frame/system-ontology/agent#> .
@prefix sys-attributive_verb: <https://unsel.tetras-libre.fr/tenet/frame/system-ontology/attributive_verb#> .
@prefix sys-component: <https://unsel.tetras-libre.fr/tenet/frame/system-ontology/component#> .
@prefix sys-message: <https://unsel.tetras-libre.fr/tenet/frame/system-ontology/message#> .
@prefix sys-place: <https://unsel.tetras-libre.fr/tenet/frame/system-ontology/place#> .""")
file.write(x)
#==============================================================================
# Main Function
......@@ -165,6 +185,7 @@ def run(corpus, output_ref, output_file):
print("\n" + "- Result")
export_result(work_graph, output_ref, output_file)
finalize_export_file(output_file)
print()
......@@ -177,11 +198,11 @@ def run(corpus, output_ref, output_file):
#==============================================================================
if __name__ == '__main__':
run(req_100, 'R100', 'output100.ttl')
run(req_300, 'R200', 'output200.ttl')
run(req_300, 'R300', 'output300.ttl')
run(corpus_40, 'Corpus-CCTP-40', 'outputCCTP40.ttl')
run(corpus_ERTMS, 'Corpus-ERTMS', 'outputERTMS.ttl')
#run(req_100, 'R100', 'output100.ttl')
#run(req_200, 'R200', 'output200.ttl')
run(req_300, 'R300b', 'output300b.ttl')
#run(corpus_40, 'Corpus-CCTP-40', 'outputCCTP40.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