Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DBRepo
Manage
Activity
Members
Labels
Plan
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FAIR Data Austria DB Repository
DBRepo
Commits
5a8b62e3
Commit
5a8b62e3
authored
10 months ago
by
Bugra Altug
Browse files
Options
Downloads
Patches
Plain Diff
extract equivalence correction
parent
58415add
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
dbrepo-somapper/matching/read_inputs.py
+6
-17
6 additions, 17 deletions
dbrepo-somapper/matching/read_inputs.py
with
6 additions
and
17 deletions
dbrepo-somapper/matching/read_inputs.py
+
6
−
17
View file @
5a8b62e3
...
...
@@ -283,7 +283,7 @@ class OntologyParser:
# Direct/Indirect imports need to be deleted from ontologies (or imported as seperate. see Owlready2 documentation). Protege can be used for this.
# OWL 2.0 ontologies in NTriples, RDF/XML or OWL/XML format are supported. (OWL/XML is recommended.)
# Relation (A is a B, B is a C, C is a A) is not supported: http://owlready.306.s1.nabble.com/TypeError-metaclass-conflict-td2889.html
def
parse
(
self
,
_loc
:
str
,
_include_only
:
OntologyClassTypes
=
None
,
_use_reasoner
=
True
,
_only_local
:
bool
=
True
)
->
OntologyData
:
def
parse
(
self
,
_loc
:
str
,
_include_only
:
[
OntologyClassTypes
]
=
None
,
_use_reasoner
=
True
,
_only_local
:
bool
=
True
)
->
OntologyData
:
self
.
_data
=
OntologyData
()
try
:
Loggers
.
info
(
LoggerTypes
.
LOAD_SERVICE
,
"
Parsing ontology
"
+
str
(
_loc
))
...
...
@@ -400,13 +400,9 @@ class OntologyParser:
def
_fill_indirect_class_datatype
(
self
,
subject
,
property
,
value
):
if
isinstance
(
property
,
or2
.
DataPropertyClass
):
# Datatype
if
isinstance
(
value
,
or2
.
LogicalClassConstruct
):
logical_values
=
self
.
_extract_class_construct_information
(
value
)
logical_values
=
[
self
.
_get_iri
(
v
)
for
_
,
v
in
logical_values
]
self
.
_data
.
safe_append_class_indirectdatatypes
(
self
.
_get_iri
(
subject
),
logical_values
)
elif
isinstance
(
value
,
type
):
self
.
_data
.
safe_append_class_indirectdatatypes
(
self
.
_get_iri
(
subject
),
[
self
.
_get_iri
(
value
)])
elif
type
(
value
)
==
subject
:
# Individuals will use their parent data types.
values
=
self
.
_extract_range_construct_information
(
value
)
self
.
_data
.
safe_append_class_indirectdatatypes
(
self
.
_get_iri
(
subject
),
values
)
elif
type
(
value
)
==
subject
:
# Individuals will use their parent data types. This is done in the "get_individual_datatypes"
self
.
_data
.
safe_append_class_indirectdatatypes
(
self
.
_get_iri
(
subject
),
[])
def
_fill_indirectly_defined_object_property_class
(
self
,
property
,
value
):
...
...
@@ -424,11 +420,9 @@ class OntologyParser:
Loggers
.
info
(
LoggerTypes
.
LOAD_SERVICE
,
"
Extracting class construct information.
"
)
if
isinstance
(
class_construct
,
or2
.
Restriction
):
Loggers
.
info
(
LoggerTypes
.
LOAD_SERVICE
,
"
(
"
+
str
(
class_construct
.
value
)
+
"
) Extracting restriction.
"
)
if
isinstance
(
class_construct
.
value
,
or2
.
Restriction
):
if
isinstance
(
class_construct
.
value
,
or2
.
Restriction
):
# property chain (op some (dp exactly 1 int))
#return [(class_construct.property, class_construct.value.property)] + self._extract_class_construct_information(class_construct.value) # Gets all chained relations
return
self
.
_extract_class_construct_information
(
class_construct
.
value
)
# Gets only chain end.
elif
isinstance
(
class_construct
.
value
,
or2
.
ConstrainedDatatype
):
return
[(
class_construct
.
property
,
class_construct
.
value
.
base_datatype
)]
else
:
return
[(
class_construct
.
property
,
class_construct
.
value
)]
elif
isinstance
(
class_construct
,
or2
.
LogicalClassConstruct
):
# Complex construction with logical operators
...
...
@@ -455,11 +449,6 @@ class OntologyParser:
Loggers
.
info
(
LoggerTypes
.
LOAD_SERVICE
,
"
(
"
+
str
(
class_construct
.
property
)
+
"
) Extracting inverse.
"
)
# [(type(class_construct) , class_construct.property)]
return
[]
elif
isinstance
(
class_construct
,
type
):
Loggers
.
info
(
LoggerTypes
.
LOAD_SERVICE
,
"
(
"
+
str
(
class_construct
)
+
"
) Extracting python type.
"
)
return
[(
str
(
type
(
class_construct
)),
class_construct
)]
elif
hasattr
(
class_construct
,
'
value
'
)
and
isinstance
(
class_construct
.
value
,
or2
.
ConstrainedDatatype
):
return
[(
class_construct
.
property
,
class_construct
.
value
.
base_datatype
)]
else
:
Loggers
.
error
(
LoggerTypes
.
LOAD_SERVICE
,
"
In class_construct_information unknown type:
"
+
str
(
type
(
class_construct
)))
return
[]
...
...
@@ -505,7 +494,7 @@ class OntologyParser:
tmp
+=
self
.
_extract_range_construct_information
(
cls
)
return
tmp
else
:
Loggers
.
error
(
LoggerTypes
.
LOAD_SERVICE
,
"
In range_construct_information unknown type:
"
+
str
(
type
(
_construct
)))
Loggers
.
error
(
LoggerTypes
.
LOAD_SERVICE
,
"
In range_construct_information unknown
:
\"
"
+
str
(
_construct
)
+
"
\"
type:
\"
"
+
str
(
type
(
_construct
))
+
"
\"
.
"
)
return
[]
def
_get_name
(
self
,
_entity
:
or2
)
->
str
:
...
...
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