Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
Requirement Formalization Tool
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thodoris Nestoridis
Requirement Formalization Tool
Commits
d879829f
Commit
d879829f
authored
Feb 03, 2021
by
Thodoris Nestoridis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expand new method of parse the ootology
parent
94573968
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
10 deletions
+26
-10
parse_ontologies.py
...reqman/apps/reqtool/rest_api/services/parse_ontologies.py
+12
-7
instances.py
reqtool/test_scripts/instances.py
+14
-3
No files found.
reqtool/reqman/api/reqman/apps/reqtool/rest_api/services/parse_ontologies.py
View file @
d879829f
from
rdflib
import
Graph
from
rdflib.namespace
import
RDFS
from
rdflib.namespace
import
RDFS
,
URIRef
,
RDF
#from subprocess import call
...
...
@@ -7,17 +7,15 @@ from rdflib.namespace import RDFS
Ontology_file
=
"../../Ontologies/Mokos_18_1_7_47.ttl"
list_of_DSO
=
[
"
DSO"
,
"DSO-AOCS"
,
"DSO-AOCS-instances
"
]
list_of_DSO
=
[
"
http://delab.csd.auth.gr/ontologies/2018/DSO#"
,
"http://delab.csd.auth.gr/ontologies/2018/DSO-AOCS#"
,
"http://delab.csd.auth.gr/ontologies/2018/DSO-AOCS-instances#
"
]
list_of_RMO
=
[
"RMO"
,
"RMO-instances"
,
"DSO-AOCS-instances"
,
"<http://delab.csd.auth.gr/ontologies/2018/RDO-instances"
]
g
=
Graph
()
g
.
load
(
Ontology_file
,
format
=
"turtle"
)
def
findsubclass
():
file2
=
open
(
r"../../Ontologies/instances.txt"
,
"w+"
)
g
=
Graph
()
g
.
load
(
Ontology_file
,
format
=
"turtle"
)
for
subj
,
obj
in
g
.
subject_objects
(
predicate
=
RDFS
.
subClassOf
):
subClass
=
subj
+
"$"
+
obj
+
"
\n
"
file2
.
write
(
subClass
)
...
...
@@ -31,12 +29,19 @@ def findsubclass():
def
get_instances
(
keyword
):
in_list
=
[]
out_list
=
[]
with
open
(
'../../Ontologies/instances.txt'
)
as
f
:
for
data
in
f
:
if
(
data
.
strip
())
.
endswith
(
keyword
):
spliter_1
=
data
.
split
(
'$'
)
spliter_2
=
spliter_1
[
0
]
.
split
(
"#"
)
in_list
.
append
(
spliter_2
[
len
(
spliter_2
)
-
1
])
return
tuple
((
str
(
n
),
str
(
n
))
for
n
in
in_list
)
for
extra
in
in_list
:
for
uri
in
list_of_DSO
:
p
=
URIRef
(
uri
+
extra
)
for
s
,
p
,
o
in
g
.
triples
((
None
,
RDF
.
type
,
p
)):
split
=
s
.
split
(
"#"
)
out_list
.
append
(
split
[
len
(
split
)
-
1
])
return
tuple
((
str
(
n
),
str
(
n
))
for
n
in
(
in_list
+
out_list
))
reqtool/test_scripts/instances.py
View file @
d879829f
from
rdflib
import
Graph
from
rdflib.namespace
import
RDFS
from
rdflib
import
ConjunctiveGraph
,
URIRef
,
RDFS
,
RDF
,
Namespace
def
get_instances
(
keyword
):
an_list
=
[]
with
open
(
'instances.txt'
)
as
f
:
for
data
in
f
:
if
(
data
.
strip
())
.
endswith
(
keyword
):
spliter_1
=
data
.
split
(
'$'
)
spliter_2
=
spliter_1
[
0
]
.
split
(
"#"
)
print
(
spliter_2
[
len
(
spliter_2
)
-
1
])
an_list
.
append
(
spliter_2
[
len
(
spliter_2
)
-
1
])
return
an_list
file2
=
open
(
r"instances.txt"
,
"w+"
)
g
=
Graph
()
g
.
load
(
"../Ontologies/Mokos_18_1_7_47.ttl"
,
format
=
"turtle"
)
for
subj
,
obj
in
g
.
subject_objects
(
predicate
=
RDFS
.
range
):
#EAGLEYE cannot find
for
subj
,
obj
in
g
.
subject_objects
(
predicate
=
RDFS
.
subClassOf
):
subClass
=
subj
+
"$"
+
obj
+
"
\n
"
file2
.
write
(
subClass
)
get_instances
(
"SAO#State"
)
l
=
get_instances
(
"SAO#System"
)
for
i
in
l
:
p
=
URIRef
(
"http://delab.csd.auth.gr/ontologies/2018/DSO#"
+
i
)
for
s
,
p
,
o
in
g
.
triples
((
None
,
RDF
.
type
,
p
)):
print
(
s
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment