Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OWL2YAMS
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cubicweb
OWL2YAMS
Commits
6f834823d046
Commit
6f834823d046
authored
3 years ago
by
Fabien Amarger
Browse files
Options
Downloads
Patches
Plain Diff
fix: Blackify
parent
3f5f1b465d80
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
owl2yams.py
+25
-10
25 additions, 10 deletions
owl2yams.py
with
25 additions
and
10 deletions
owl2yams.py
+
25
−
10
View file @
6f834823
...
...
@@ -12,11 +12,11 @@
ETYPE_URI
=
{}
LITERAL_TYPES_TO_YAMS_TYPES
=
{
RDFS
.
Literal
:
'
String
'
,
XSD
.
string
:
'
String
'
,
XSD
.
int
:
'
Int
'
,
XSD
.
integer
:
'
Int
'
,
XSD
.
float
:
'
Float
'
,
RDFS
.
Literal
:
"
String
"
,
XSD
.
string
:
"
String
"
,
XSD
.
int
:
"
Int
"
,
XSD
.
integer
:
"
Int
"
,
XSD
.
float
:
"
Float
"
,
}
...
...
@@ -50,10 +50,12 @@
entity_schema
=
schema
.
_entities
[
class_fragment
]
ETYPE_URI
[
class_fragment
]
=
class_uri
superior_classes
=
[]
for
_
,
_
,
superior_class_uri
in
owl_model
.
triples
((
class_uri
,
RDFS
.
subClassOf
,
None
)):
for
_
,
_
,
superior_class_uri
in
owl_model
.
triples
(
(
class_uri
,
RDFS
.
subClassOf
,
None
)
):
superior_classes
.
append
(
fragment_from_uri
(
superior_class_uri
))
if
superior_classes
:
entity_schema
.
_specialized_type
=
"
,
"
.
join
(
superior_classes
)
# 2. fetch all datatype properties
...
...
@@ -54,10 +56,14 @@
superior_classes
.
append
(
fragment_from_uri
(
superior_class_uri
))
if
superior_classes
:
entity_schema
.
_specialized_type
=
"
,
"
.
join
(
superior_classes
)
# 2. fetch all datatype properties
for
datatype_property_uri
,
_
,
_
,
in
owl_model
.
triples
((
None
,
RDF
.
type
,
OWL
.
DatatypeProperty
)):
for
(
datatype_property_uri
,
_
,
_
,
)
in
owl_model
.
triples
((
None
,
RDF
.
type
,
OWL
.
DatatypeProperty
)):
datatype_property_uri_fragment
=
fragment_from_uri
(
datatype_property_uri
)
schema
.
add_relation_type
(
RelationType
(
datatype_property_uri_fragment
))
# take first range, if no range use RDFS.Literal
...
...
@@ -61,5 +67,8 @@
datatype_property_uri_fragment
=
fragment_from_uri
(
datatype_property_uri
)
schema
.
add_relation_type
(
RelationType
(
datatype_property_uri_fragment
))
# take first range, if no range use RDFS.Literal
_
,
_
,
literal_type
=
next
(
owl_model
.
triples
((
datatype_property_uri
,
RDFS
.
range
,
None
)),
(
_
,
_
,
RDFS
.
Literal
))
_
,
_
,
literal_type
=
next
(
owl_model
.
triples
((
datatype_property_uri
,
RDFS
.
range
,
None
)),
(
_
,
_
,
RDFS
.
Literal
),
)
yams_type
=
LITERAL_TYPES_TO_YAMS_TYPES
[
literal_type
]
...
...
@@ -65,3 +74,5 @@
yams_type
=
LITERAL_TYPES_TO_YAMS_TYPES
[
literal_type
]
for
_
,
_
,
domain_uri
in
owl_model
.
triples
((
datatype_property_uri
,
RDFS
.
domain
,
None
)):
for
_
,
_
,
domain_uri
in
owl_model
.
triples
(
(
datatype_property_uri
,
RDFS
.
domain
,
None
)
):
domain_uri_fragment
=
fragment_from_uri
(
domain_uri
)
...
...
@@ -67,4 +78,8 @@
domain_uri_fragment
=
fragment_from_uri
(
domain_uri
)
schema
.
add_relation_def
(
RelationDefinition
(
domain_uri_fragment
,
datatype_property_uri_fragment
,
yams_type
))
schema
.
add_relation_def
(
RelationDefinition
(
domain_uri_fragment
,
datatype_property_uri_fragment
,
yams_type
)
)
print
(
serialize_to_python
(
schema
))
This diff is collapsed.
Click to expand it.
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