Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tenet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tetras MARS
tenet
Commits
002d116f
Commit
002d116f
authored
Sep 28, 2021
by
Aurélien Lamercerie
Browse files
Options
Downloads
Patches
Plain Diff
Generic CTS to generate atom classes and instances
parent
76f0fd21
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
config/transduction-schemes.ttl
+161
-281
161 additions, 281 deletions
config/transduction-schemes.ttl
frame/system-ontology.ttl
+15
-1
15 additions, 1 deletion
frame/system-ontology.ttl
prepare_work_data.py
+25
-20
25 additions, 20 deletions
prepare_work_data.py
with
202 additions
and
302 deletions
.gitignore
+
1
−
0
View file @
002d116f
...
...
@@ -7,3 +7,4 @@ corpus/ERTMS*
.project
*.ttl.tbc
output*.ttl
output/*
This diff is collapsed.
Click to expand it.
config/transduction-schemes.ttl
+
161
−
281
View file @
002d116f
...
...
@@ -30,50 +30,6 @@ cts:abstraction_extraction
rdfs:
label
"abstraction extension"
;
rdfs:
subClassOf
cts:
net_extension
;
.
cts:
add-abstraction
rdf:
type
sh:
SPARQLRule
;
rdfs:
label
"add-abstraction"
;
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 sys-agent: <https://unsel.tetras-libre.fr/tenet/frame/system-ontology/agent#>
PREFIX fprm: <https://unsel.tetras-libre.fr/tenet/frame/parameters#>
# -- Add Entity class / instance in System Ontology
CONSTRUCT {
# Classification
?subAbstractionUri rdfs:subClassOf ?abstractionUri.
?subAbstractionUri rdfs:label ?abstractionConcept.
?subAbstractionUri sys:from_structure ?req.
# Instantiation: no instance for abstraction
}
WHERE {
# net1: feature
?net1 a net:Instance.
?net1 net:type net:atom.
?net1 net:atomOf sys:Abstraction.
?net1 net:has_structure ?req.
?net1 net:has_atom ?atomObject1.
?atomObject1 net:has_parent_class ?abstractionClass.
?atomObject1 net:has_concept ?abstractionConcept.
# Filter: entity not present in a class list
FILTER NOT EXISTS { ?net2 net:class2 ?abstractionConcept}
# URI: class
cprm:Config_Parameters cprm:baseURI ?baseURI.
fprm:System_Ontology fprm:frameURI ?frameURI.
BIND (concat( ?frameURI, ?abstractionClass) AS ?s1).
BIND (concat(?s1, '#', ?abstractionConcept) AS ?s2).
BIND (uri( ?s1) AS ?abstractionUri).
BIND (uri(?s2) AS ?subAbstractionUri).
}"""
;
sh:
order
3.1
;
.
cts:
add-conjunctive-entity-classes
rdf:
type
sh:
SPARQLRule
;
rdfs:
label
"add-conjunctive-entity-classes"
;
...
...
@@ -117,8 +73,6 @@ WHERE {
?subEntityObject3 net:has_instance ?mainInstance.
# extension: disjunction of UW
?uw2 unl:and ?uw3.
# --old --- FILTER NOT EXISTS { ?net2 net:has_subClass ?mainEntity }.
# --old --- FILTER NOT EXISTS { ?subEntity23Uri owl:equivalentClass ?c }.
# Label(s) / URI (for classes)
?uw2 rdfs:label ?uw2Label.
?uw3 rdfs:label ?uw3Label.
...
...
@@ -127,7 +81,7 @@ WHERE {
BIND (concat(?concept2, '-or-', ?concept3) AS ?concept23)
BIND (concat(?concept23, '_', ?mainEntity) AS ?subEntity23).
# URI (for classes)
fprm:System_Ontology fprm:
frame
URI
?frameURI.
sys:Structure sys:has_
frame
_uri
?frameURI.
BIND (concat( ?frameURI, ?entityClass) AS ?s1).
BIND (concat(?s1, '#', ?mainEntity) AS ?s2).
BIND (concat(?s1, '#', ?subEntity2) AS ?s3).
...
...
@@ -186,8 +140,6 @@ WHERE {
?subEntityObject3 net:has_instance ?mainInstance.
# extension: disjunction of UW
?uw2 unl:or ?uw3.
# --old --- FILTER NOT EXISTS { ?net2 net:has_subClass ?mainEntity }.
# --old --- FILTER NOT EXISTS { ?subEntity23Uri owl:equivalentClass ?c }.
# Label(s) / URI (for classes)
?uw2 rdfs:label ?uw2Label.
?uw3 rdfs:label ?uw3Label.
...
...
@@ -196,7 +148,7 @@ WHERE {
BIND (concat(?concept2, '-or-', ?concept3) AS ?concept23)
BIND (concat(?concept23, '_', ?mainEntity) AS ?subEntity23).
# URI (for classes)
fprm:System_Ontology fprm:
frame
URI
?frameURI.
sys:Structure sys:has_
frame
_uri
?frameURI.
BIND (concat( ?frameURI, ?entityClass) AS ?s1).
BIND (concat(?s1, '#', ?mainEntity) AS ?s2).
BIND (concat(?s1, '#', ?subEntity2) AS ?s3).
...
...
@@ -212,57 +164,6 @@ WHERE {
}"""
;
sh:
order
3.4
;
.
cts:
add-entity
rdf:
type
sh:
SPARQLRule
;
rdfs:
label
"add-entity"
;
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 Entity class / instance in System Ontology
CONSTRUCT {
# Classification
?mainEntityUri rdfs:subClassOf ?entityUri.
?mainEntityUri rdfs:label ?entityConcept.
?mainEntityUri sys:from_structure ?req.
# Instantiation
?mainInstanceUri a ?mainEntityUri.
?mainInstanceUri rdfs:label ?mainInstance.
?mainInstanceUri sys:from_structure ?req.
}
WHERE {
# net1: entity
?net1 a net:Instance.
?net1 net:type net:atom.
?net1 net:atomOf sys:Entity.
?net1 net:has_structure ?req.
?net1 net:has_atom ?atomObject1.
?atomObject1 net:has_parent_class ?entityClass.
?atomObject1 net:has_concept ?entityConcept.
?atomObject1 net:has_instance ?mainInstance.
# Filter: entity not present in a class list
FILTER NOT EXISTS { ?net2 net:has_subClass ?entityConcept}
# URI (for classes)
cprm:Config_Parameters cprm:baseURI ?baseURI.
fprm:System_Ontology fprm:frameURI ?frameURI.
# -- old --- fprm:System_Entity rdfs:label ?entityLabel.
BIND (concat( ?frameURI, ?entityClass) AS ?s1).
BIND (concat(?s1, '#', ?entityConcept) AS ?s2).
BIND (uri( ?s1) AS ?entityUri).
BIND (uri(?s2) AS ?mainEntityUri).
# URI (for instance)
BIND (concat(?s1, '_', ?mainInstance) AS ?s3).
BIND (uri(?s3) AS ?mainInstanceUri).
}"""
;
sh:
order
3.1
;
.
cts:
add-event
rdf:
type
sh:
SPARQLRule
;
rdfs:
label
"add-event"
;
...
...
@@ -319,15 +220,14 @@ WHERE {
BIND (concat(?actorConcept, '-', ?verbConcept) AS ?e1).
BIND (concat(?e1, '-', ?targetConcept) AS ?eventLabel).
# URI (for classes)
fprm:System_Ontology fprm:
frame
URI
?frameURI.
fprm:System_Event fprm:
class ?eventClass.
sys:Structure sys:has_
frame
_uri
?frameURI.
sys:Event sys:is_
class ?eventClass.
BIND (concat( ?frameURI, ?eventClass) AS ?c1).
BIND (concat(?c1, '_', ?eventLabel) AS ?c2).
BIND (uri( ?c1) AS ?eventClassUri).
BIND (uri(?c2) AS ?newEventUri).
# URI (for object property)
fprm:System_Ontology fprm:frameURI ?frameURI.
fprm:System_Event fprm:objectProperty ?eventObjectProperty.
sys:Event sys:has_object_property ?eventObjectProperty.
BIND (concat( ?frameURI, ?eventObjectProperty) AS ?o1).
BIND (concat(?o1, '#', ?verbConcept) AS ?o2).
BIND (uri( ?o1) AS ?eventObjectPropertyUri).
...
...
@@ -335,49 +235,6 @@ WHERE {
}"""
;
sh:
order
3.1
;
.
cts:
add-feature
rdf:
type
sh:
SPARQLRule
;
rdfs:
label
"add-entity-classes"
;
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 Entity class / instance in System Ontology
CONSTRUCT {
# Classification
?subFeatureUri rdfs:subClassOf ?featureUri.
?subFeatureUri rdfs:label ?featureConcept.
?subFeatureUri sys:from_structure ?req.
# Instantiation: no instance for feature
}
WHERE {
# net1: feature
?net1 a net:Instance.
?net1 net:type net:atom.
?net1 net:atomOf sys:Feature.
?net1 net:has_structure ?req.
?net1 net:has_atom ?atomObject1.
?atomObject1 net:has_parent_class ?featureClass.
?atomObject1 net:has_concept ?featureConcept.
# Filter: entity not present in a class list
FILTER NOT EXISTS { ?net2 net:class2 ?featureConcept}
# URI: class
cprm:Config_Parameters cprm:baseURI ?baseURI.
fprm:System_Ontology fprm:frameURI ?frameURI.
BIND (concat( ?frameURI, ?featureClass) AS ?s1).
BIND (concat(?s1, '#', ?featureConcept) AS ?s2).
BIND (uri( ?s1) AS ?featureUri).
BIND (uri(?s2) AS ?subFeatureUri).
}"""
;
sh:
order
3.1
;
.
cts:
add-list-of-entity-classes
rdf:
type
sh:
SPARQLRule
;
sh:
construct
"""PREFIX owl: <http://www.w3.org/2002/07/owl#>
...
...
@@ -416,8 +273,7 @@ WHERE {
?subEntityObject net:has_instance ?mainInstance.
# Filter -- old --- FILTER NOT EXISTS { ?net2 net:has_subClass ?mainEntity}
# URI (for classes)
fprm:System_Ontology fprm:frameURI ?frameURI.
fprm:System_Entity rdfs:label ?entityLabel.
sys:Structure sys:has_frame_uri ?frameURI.
BIND (concat( ?frameURI, ?entityClass) AS ?s1).
BIND (concat(?s1, '#', ?mainEntity) AS ?s2).
BIND (concat(?s1, '#', ?subEntity) AS ?s3).
...
...
@@ -485,14 +341,14 @@ WHERE {
BIND (concat(?actorConcept, '-', ?verbConcept) AS ?e1).
BIND (concat(?e1, '-', ?targetConcept) AS ?statePropertyLabel).
# URI (for classes)
fprm:System_Ontology fprm:
frame
URI
?frameURI.
fprm:System_
State_Property
fprm:
class ?statePropertyClass.
sys:Structure sys:has_
frame
_uri
?frameURI.
sys:
State_Property
sys:is_
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 object property)
fprm:System_
State_Property
fprm:
object
P
roperty ?statePropertyObjectProperty.
sys:
State_Property
sys:has_
object
_p
roperty ?statePropertyObjectProperty.
BIND (concat( ?frameURI, ?statePropertyObjectProperty) AS ?o1).
BIND (concat(?o1, '#', ?verbConcept) AS ?o2).
BIND (uri( ?o1) AS ?statePropertyObjectPropertyUri).
...
...
@@ -518,72 +374,16 @@ WHERE {
}"""
;
sh:
order
3.1
;
.
cts:
add-verb
rdf:
type
sh:
SPARQLRule
;
rdfs:
label
"add-verb"
;
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
?verbUri rdfs:subClassOf ?verbClassUri.
?verbUri rdfs:label ?verbConcept.
?verbUri sys:from_structure ?req.
# Instantiation !!! TODO !!!
# -- old --- ?mainInstanceUri a ?mainVerbUri.
# -- old --- ?mainInstanceUri rdfs:label ?mainInstance.
# -- old --- ?mainInstanceUri sys:from_structure ?req.
}
WHERE {
# net1: entity
?net1 a net:Instance.
?net1 net:type net:atom.
?net1 net:atomOf sys:Verb.
?net1 net:has_structure ?req.
?net1 net:has_atom ?verbObject1.
?verbObject1 net:has_parent_class ?verbClass.
?verbObject1 net:has_concept ?verbConcept.
# -- old --- ?verbObject1 net:has_instance ?mainInstance.
# Filter: entity not present in a class list
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, '#', ?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).
}"""
;
sh:
order
3.1
;
.
cts:
batch_execution
rdf:
type
owl:
Class
;
rdf:
type
sh:
NodeShape
;
rdfs:
label
"batch execution"
;
rdfs:
subClassOf
cts:
Transduction_Schemes
;
sh:
rule
cts:
add-abstraction
;
sh:
rule
cts:
add-conjunctive-entity-classes
;
sh:
rule
cts:
add-disjunctive-entity-classes
;
sh:
rule
cts:
add-entity
;
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-simple-event
;
...
...
@@ -591,17 +391,19 @@ cts:batch_execution
sh:
rule
cts:
compose-entity-modlist-1
;
sh:
rule
cts:
compose-entity-modlist-2
;
sh:
rule
cts:
compose-entity-modlist-3
;
sh:
rule
cts:
compute-class-uri-of-
entity-
net-object
;
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
;
sh:
rule
cts:
compute-instance-uri-of-
entity-
net-object
;
sh:
rule
cts:
compute-instance-uri-of-net-object
;
sh:
rule
cts:
create-atom-net
;
sh:
rule
cts:
define-uw-id
;
sh:
rule
cts:
extend-mod-list
;
sh:
rule
cts:
generate-atom-class
;
sh:
rule
cts:
generate-atom-instance
;
sh:
rule
cts:
init-mod-list
;
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:
instantiate-entity-net
;
sh:
rule
cts:
link-to-scope-entry
;
sh:
rule
cts:
typify-modlist-entity
;
sh:
rule
cts:
typify-modlist-feature
;
...
...
@@ -667,8 +469,7 @@ WHERE {
?featureObject net:has_parent_class ?featureClass.
?featureObject net:has_concept ?featureConcept.
# URI: entity class
fprm:System_Ontology fprm:frameURI ?frameURI.
fprm:System_Entity rdfs:label ?entityLabel.
sys:Structure sys:has_frame_uri ?frameURI.
BIND (concat( ?frameURI, ?entityClass) AS ?c1).
BIND (concat(?c1, '#', ?subEntity) AS ?c2).
BIND (uri(?c2) AS ?subEntityUri).
...
...
@@ -1138,9 +939,9 @@ WHERE {
}"""
;
sh:
order
2.6
;
.
cts:
compute-class-uri-of-
entity-
net-object
cts:
compute-class-uri-of-net-object
rdf:
type
sh:
SPARQLRule
;
rdfs:
label
"compute-class-uri-of-
entity-
net-object"
;
rdfs:
label
"compute-class-uri-of-net-object"
;
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#>
...
...
@@ -1159,12 +960,12 @@ CONSTRUCT {
?object net:classUri ?objectClassUri.
}
WHERE {
#
net1: entity
#
object
?object a net:Object.
?object net:has_parent_class ?objectClass.
?object net:has_concept ?objectConcept.
# URI (for classes
and instance
)
fprm:System_Ontology fprm:
frame
URI
?frameURI.
# URI (for classes)
sys:Structure sys:has_
frame
_uri
?frameURI.
BIND (concat( ?frameURI, ?objectClass) AS ?s1).
BIND (concat(?s1, '#', ?objectConcept) AS ?s2).
BIND (uri( ?s1) AS ?parentClassUri).
...
...
@@ -1222,8 +1023,8 @@ WHERE {
}
)
# URI (for object property)
fprm:System_Ontology fprm:
frame
URI
?frameURI.
fprm:System_Event fprm:
object
P
roperty ?eventObjectProperty.
sys:Structure sys:has_
frame
_uri
?frameURI.
sys:Event sys:has_
object
_p
roperty ?eventObjectProperty.
BIND (concat( ?frameURI, ?eventObjectProperty) AS ?o1).
BIND (concat(?o1, '#', ?verbConcept) AS ?o2).
BIND (uri( ?o2) AS ?newEventObjectPropertyUri).
...
...
@@ -1280,17 +1081,17 @@ WHERE {
}
)
# URI (for object property)
fprm:System_Ontology fprm:
frame
URI
?frameURI.
fprm:System_
State_Property
fprm:
object
P
roperty ?objectPropertyRef.
sys:Structure sys:has_
frame
_uri
?frameURI.
sys:
State_Property
sys:has_
object
_p
roperty ?objectPropertyRef.
BIND (concat( ?frameURI, ?objectPropertyRef) AS ?o1).
BIND (concat(?o1, '#', ?verbConcept) AS ?o2).
BIND (uri( ?o2) AS ?objectPropertyUri).
}"""
;
sh:
order
3.5
;
.
cts:
compute-instance-uri-of-
entity-
net-object
cts:
compute-instance-uri-of-net-object
rdf:
type
sh:
SPARQLRule
;
rdfs:
label
"compute-instance-uri-of-
entity-
net-object"
;
rdfs:
label
"compute-instance-uri-of-net-object"
;
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#>
...
...
@@ -1308,12 +1109,12 @@ CONSTRUCT {
?object net:instanceUri ?objectInstanceUri.
}
WHERE {
#
net1: entity
#
object
?object a net:Object.
?object net:has_parent_class ?objectClass.
?object net:has_instance ?objectInstance.
# URI (for classes and instance)
fprm:System_Ontology fprm:
frame
URI
?frameURI.
sys:Structure sys:has_
frame
_uri
?frameURI.
BIND (concat( ?frameURI, ?objectClass) AS ?s1).
BIND (concat(?s1, '_', ?objectInstance) AS ?s3).
BIND (uri(?s3) AS ?objectInstanceUri).
...
...
@@ -1428,9 +1229,9 @@ cts:entity_extraction
sh:
rule
cts:
create-atom-net
;
sh:
rule
cts:
extend-mod-list
;
sh:
rule
cts:
init-mod-list
;
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:
instantiate-entity-net
;
sh:
rule
cts:
typify-modlist-entity
;
sh:
rule
cts:
typify-modlist-feature
;
.
...
...
@@ -1485,25 +1286,108 @@ cts:feature_extraction
rdfs:
label
"feature extraction"
;
rdfs:
subClassOf
cts:
net_extension
;
.
cts:
generate-atom-class
rdf:
type
sh:
SPARQLRule
;
rdfs:
label
"add-entity-classes"
;
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#>
# -- Generate atom class in System Ontology
CONSTRUCT {
# Classification
?newClassUri rdfs:subClassOf ?parentUri.
?newClassUri rdfs:label ?atomConcept.
?newClassUri sys:from_structure ?req.
}
WHERE {
# net1: atom
?net1 a net:Instance.
?net1 net:type net:atom.
?net1 net:has_structure ?req.
?net1 net:has_atom ?atomObject1.
?atomObject1 net:has_parent_class ?atomParentClass.
?atomObject1 net:has_concept ?atomConcept.
# Filter: entity not present in a class list
FILTER NOT EXISTS { ?net2 net:class2 ?atomConcept}
# URI: class
sys:Structure sys:has_frame_uri ?frameURI.
BIND (concat( ?frameURI, ?atomParentClass) AS ?s1).
BIND (concat(?s1, '#', ?atomConcept) AS ?s2).
BIND (uri( ?s1) AS ?parentUri).
BIND (uri(?s2) AS ?newClassUri).
}"""
;
sh:
order
3.1
;
.
cts:
generate-atom-instance
rdf:
type
sh:
SPARQLRule
;
rdfs:
label
"add-entity"
;
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#>
# -- Generate atom instance in System Ontology
CONSTRUCT {
# Instantiation
?newInstanceUri a ?classUri.
?newInstanceUri rdfs:label ?atomInstance.
?newInstanceUri sys:from_structure ?req.
}
WHERE {
# net1: entity
?net1 a net:Instance.
?net1 net:type net:atom.
?net1 net:atomOf sys:Entity.
?net1 net:has_structure ?req.
?net1 net:has_atom ?atomObject1.
?atomObject1 net:has_parent_class ?atomParentClass.
?atomObject1 net:has_concept ?atomConcept.
?atomObject1 net:has_instance ?atomInstance.
# Filter: entity not present in a class list
FILTER NOT EXISTS { ?net2 net:has_subClass ?atomConcept}
# URI (for classes)
sys:Structure sys:has_frame_uri ?frameURI.
BIND (concat( ?frameURI, ?atomParentClass) AS ?s1).
BIND (concat(?s1, '#', ?atomConcept) AS ?s2).
BIND (uri( ?s1) AS ?parentUri).
BIND (uri(?s2) AS ?classUri).
# URI (for instance)
BIND (concat(?s1, '_', ?atomInstance) AS ?s3).
BIND (uri(?s3) AS ?newInstanceUri).
}"""
;
sh:
order
3.1
;
.
cts:
generation
rdf:
type
owl:
Class
;
rdf:
type
sh:
NodeShape
;
rdfs:
label
"generation"
;
rdfs:
subClassOf
cts:
Transduction_Schemes
;
sh:
rule
cts:
add-abstraction
;
sh:
rule
cts:
add-conjunctive-entity-classes
;
sh:
rule
cts:
add-disjunctive-entity-classes
;
sh:
rule
cts:
add-entity
;
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
;
sh:
rule
cts:
compute-class-uri-of-
entity-
net-object
;
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
;
sh:
rule
cts:
compute-instance-uri-of-entity-net-object
;
sh:
rule
cts:
compute-instance-uri-of-net-object
;
sh:
rule
cts:
generate-atom-class
;
sh:
rule
cts:
generate-atom-instance
;
.
cts:
init-mod-list
rdf:
type
sh:
SPARQLRule
;
...
...
@@ -1548,6 +1432,43 @@ WHERE {
}"""
;
sh:
order
2.3
;
.
cts:
instantiate-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#>
# -- Instantiate atom net
CONSTRUCT {
# Object: entity
?atomObject1 net:has_instance ?instanceName.
}
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.
# condition: agt/obj(uw0, 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.
# Label: id, name
?uw1 unl:has_id ?uw1Id.
BIND (?uw1Id AS ?instanceName).
}"""
;
sh:
order
2.2
;
.
cts:
instantiate-classlist-by-extension-1
rdf:
type
sh:
SPARQLRule
;
sh:
construct
"""PREFIX owl: <http://www.w3.org/2002/07/owl#>
...
...
@@ -1625,46 +1546,6 @@ WHERE {
}"""
;
sh:
order
2.8
;
.
cts:
instantiate-entity-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
?atomObject1 net:has_instance ?instanceName.
}
WHERE {
# net1: entity (with entity object)
?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.
# condition: agt/obj(uw0, 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.
# -- old ---- ?uw1 rdf:type unl:UW_Occurrence.
# -- old ---- ?uw1 unl:is_substructure_of ?req.
# -- old ---- ?uw1 unl:is_occurrence_of ?lexTrg.
# Label: id, name
?uw1 unl:has_id ?uw1Id.
BIND (?uw1Id AS ?instanceName).
}"""
;
sh:
order
2.2
;
.
cts:
link-to-scope-entry
rdf:
type
sh:
SPARQLRule
;
sh:
construct
"""PREFIX owl: <http://www.w3.org/2002/07/owl#>
...
...
@@ -1742,9 +1623,9 @@ CONSTRUCT {
}
WHERE {
# Entity (from System Ontology)
?
entity rdf:type fprm:System_
Entity.
?
entity fprm:
class ?entityClass.
?
entity fprm:
restriction ?entityRestriction.
?
targetClass rdfs:subClassOf* sys:
Entity.
?
targetClass sys:is_
class ?entityClass.
?
targetClass sys:has_
restriction ?entityRestriction.
# net: modList
?semNet a net:Instance.
?semNet net:type net:mod_list.
...
...
@@ -1780,9 +1661,9 @@ CONSTRUCT {
}
WHERE {
# Entity Feature (from System Ontology)
?
entity rdf:type fprm:System_
Feature.
?
entity fprm:
class ?featureClass.
?
entity fprm:
restriction ?featureRestriction.
?
targetClass rdfs:subClassOf* sys:
Feature.
?
targetClass sys:is_
class ?featureClass.
?
targetClass sys:has_
restriction ?featureRestriction.
# net: modList
?semNet a net:Instance.
?semNet net:type net:mod_list.
...
...
@@ -1802,5 +1683,4 @@ cts:verb_extraction
rdf:
type
sh:
NodeShape
;
rdfs:
label
"verb extraction"
;
rdfs:
subClassOf
cts:
net_extension
;
sh:
rule
cts:
add-verb
;
.
This diff is collapsed.
Click to expand it.
frame/system-ontology.ttl
+
15
−
1
View file @
002d116f
...
...
@@ -30,13 +30,15 @@ sys:Entity
rdfs:
label
"entity"
@en
;
rdfs:
label
"entité"
@fr
;
rdfs:
subClassOf
sys:
Structure
;
sys:
is_class
"
sys:
Entity"
;
sys:
is_class
"Entity"
;
.
sys:
Event
rdf:
type
owl:
Class
;
rdfs:
label
"Event"
@en
;
rdfs:
label
"Evénèment"
@fr
;
rdfs:
subClassOf
sys:
Structure
;
sys:
has_object_property
"eventObjectProperty"
;
sys:
is_class
"Event"
;
.
sys:
Feature
rdf:
type
owl:
Class
;
...
...
@@ -50,10 +52,13 @@ sys:State_Property
rdfs:
label
"Propriété d'état"
@fr
;
rdfs:
label
"State Property"
@en
;
rdfs:
subClassOf
sys:
Structure
;
sys:
has_object_property
"statePropertyObjectProperty"
;
sys:
is_class
"State_Property"
;
.
sys:
Structure
rdf:
type
owl:
Class
;
rdfs:
label
"System Ontology Structure"
;
sys:
has_frame_uri
"https://unsel.tetras-libre.fr/tenet/frame/system-ontology/"
;
.
sys:
Verb
rdf:
type
owl:
Class
;
...
...
@@ -150,6 +155,11 @@ sys:has_frame_base_uri
rdfs:
subPropertyOf
sys:
seedProperty
;
sys:
has_frame_base_uri
"https://unsel.tetras-libre.fr/tenet/frame/system-ontology/"
;
.
sys:
has_frame_uri
rdf:
type
rdf:
Property
;
rdfs:
label
"has frame uri"
;
rdfs:
subPropertyOf
sys:
structureProperty
;
.
sys:
has_mother_class
rdf:
type
rdf:
Property
;
rdfs:
label
"has mother class"
;
...
...
@@ -223,6 +233,10 @@ sys:statePropertyObjectProperty
rdfs:
label
"state property object property"
;
rdfs:
subPropertyOf
sys:
objectProperty
;
.
sys:
structureProperty
rdf:
type
rdf:
Property
;
rdfs:
label
"structure property"
;
.
sys:
verbClassProperty
rdf:
type
rdf:
Property
;
rdfs:
label
"verb property"
;
...
...
This diff is collapsed.
Click to expand it.
prepare_work_data.py
+
25
−
20
View file @
002d116f
...
...
@@ -24,16 +24,19 @@ CONFIG_DIR = "config/"
FRAME_DIR
=
"
frame/
"
CORPUS_DIR
=
"
corpus/
"
CTS_DIR
=
"
cts/
"
OUTPUT_DIR
=
"
output/
"
# Config Definition
TURTLE_SUFFIX
=
"
.ttl
"
ONTO_FILE
=
"
-ontology
"
+
TURTLE_SUFFIX
dash_file
=
"
dash-data-shapes.ttl
"
# data from "http://datashapes.org/dash.ttl"
schema_file
=
"
unl-rdf-schema.ttl
"
semantic_net_file
=
"
semantic-net.ttl
"
cts_file
=
"
transduction-schemes.ttl
"
c_param_file
=
"
config-parameters.ttl
"
req_onto_file
=
"
requirement
-ontology.ttl
"
sys_onto_file
=
"
system
-ontology.ttl
"
f_param_file
=
"
ontology-parameters.ttl
"
# -- old ---
req_onto_file = "requirement
" + ONTO_FILE
# -- old ---
sys_onto_file = "system
" + ONTO_FILE
# -- old ---
f_param_file = "ontology-parameters.ttl"
# Dev Tests
base_uri
=
"
https://unsel.tetras-libre.fr/tenet/working
"
...
...
@@ -78,20 +81,20 @@ def load_config(work_graph):
print
(
"
----- Config Parameter Definition (
"
+
str
(
len
(
work_graph
))
+
"
)
"
)
def
load_frame
(
work_graph
):
def
load_frame
(
work_graph
,
target_system
):
print
(
"
-- Frame Ontology Loading:
"
)
file_ref
=
FRAME_DIR
+
req_onto_file
work_graph
.
parse
(
file_ref
)
print
(
"
----- Requirement Frame Ontology (
"
+
str
(
len
(
work_graph
))
+
"
)
"
)
# -- old ---
file_ref = FRAME_DIR + req_onto_file
# -- old ---
work_graph.parse(file_ref)
# -- old ---
print("----- Requirement Frame Ontology (" + str(len(work_graph)) + ")")
file_ref
=
FRAME_DIR
+
sys_onto_file
file_ref
=
FRAME_DIR
+
target_system
+
ONTO_FILE
work_graph
.
parse
(
file_ref
)
print
(
"
----- System Frame Ontology (
"
+
str
(
len
(
work_graph
))
+
"
)
"
)
file_ref
=
FRAME_DIR
+
f_param_file
work_graph
.
parse
(
file_ref
)
print
(
"
----- Ontology Parameters (
"
+
str
(
len
(
work_graph
))
+
"
)
"
)
# -- old ---
file_ref = FRAME_DIR + f_param_file
# -- old ---
work_graph.parse(file_ref)
# -- old ---
print("----- Ontology Parameters (" + str(len(work_graph)) + ")")
#def define_namespace(work_graph):
...
...
@@ -169,14 +172,14 @@ def finalize_export_file(export_file):
# Main Function
#==============================================================================
def
run
(
corpus
,
ou
tput
_ref
,
output_file
):
def
run
(
corpus
,
s
ou
rce
_ref
,
target_ref
):
try
:
print
(
"
[Tenet] Prepare work data from corpus
"
+
corpus
)
print
(
"
\n
"
+
"
- Graph Initialization
"
)
work_graph
=
Graph
()
load_config
(
work_graph
)
load_frame
(
work_graph
)
load_frame
(
work_graph
,
target_ref
)
#define_namespace(work_graph)
print
(
"
\n
"
+
"
- Preparation of Transduction Process
"
)
...
...
@@ -186,7 +189,8 @@ def run(corpus, output_ref, output_file):
load_sentences
(
work_graph
,
corpus
)
print
(
"
\n
"
+
"
- Result
"
)
export_result
(
work_graph
,
output_ref
,
output_file
)
output_file
=
OUTPUT_DIR
+
source_ref
+
TURTLE_SUFFIX
export_result
(
work_graph
,
source_ref
,
output_file
)
finalize_export_file
(
output_file
)
print
()
...
...
@@ -200,11 +204,12 @@ def run(corpus, output_ref, output_file):
#==============================================================================
if
__name__
==
'
__main__
'
:
#run(req_100, 'R100', 'output100.ttl')
#run(req_200, 'R200', 'output200.ttl')
run
(
req_300
,
'
R300b
'
,
'
output300b.ttl
'
)
run
(
corpus_40
,
'
Corpus-CCTP-40c
'
,
'
outputCCTP40c.ttl
'
)
#run(corpus_ERTMS, 'Corpus-ERTMS', 'outputERTMS.ttl')
target_ref
=
"
system
"
run
(
req_100
,
'
R100
'
,
target_ref
)
run
(
req_200
,
'
R200
'
,
target_ref
)
run
(
req_300
,
'
R300a
'
,
target_ref
)
run
(
corpus_40
,
'
Corpus-CCTP-40c
'
,
target_ref
)
run
(
corpus_ERTMS
,
'
Corpus-ERTMS
'
,
target_ref
)
...
...
This diff is collapsed.
Click to expand it.
Aurélien Lamercerie
@alam
mentioned in issue
#8 (closed)
·
Sep 28, 2021
mentioned in issue
#8 (closed)
mentioned in issue #8
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment