Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-226
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-226
2022-226
Commits
6f7c3ac3
Commit
6f7c3ac3
authored
Sep 13, 2022
by
Wickramasinghe R.J.P
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ontology generator updated
parent
1caf9779
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
17 deletions
+51
-17
Ontology_Based_Information_System/Ontology Generator/owl_generator.py
...ed_Information_System/Ontology Generator/owl_generator.py
+51
-17
No files found.
Ontology_Based_Information_System/Ontology Generator/owl_generator.py
View file @
6f7c3ac3
...
@@ -2,11 +2,13 @@ from owlready2 import *
...
@@ -2,11 +2,13 @@ from owlready2 import *
import
csv
,
types
import
csv
,
types
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
onto
=
get_ontology
(
"d
ogSkinDisease
.owl"
)
.
load
()
onto
=
get_ontology
(
"d
d
.owl"
)
.
load
()
onto_individuals
=
get_ontology
(
"http://www.semanticweb.org/dogdisease/ontologies/2022/4/dogDisease.owl"
)
onto_individuals
=
get_ontology
(
"http://www.semanticweb.org/dogdisease/ontologies/2022/4/dogDisease.owl"
)
onto_individuals
.
imported_ontologies
.
append
(
onto
)
onto_individuals
.
imported_ontologies
.
append
(
onto
)
listOfClasses
=
[]
f
=
open
(
"dogDisease.csv"
,
encoding
=
'utf-8'
)
f
=
open
(
"dogDisease.csv"
,
encoding
=
'utf-8'
)
reader
=
csv
.
reader
(
f
)
reader
=
csv
.
reader
(
f
)
next
(
reader
)
next
(
reader
)
...
@@ -14,39 +16,71 @@ if __name__ == '__main__':
...
@@ -14,39 +16,71 @@ if __name__ == '__main__':
with
onto_individuals
:
with
onto_individuals
:
for
row
in
reader
:
for
row
in
reader
:
Disease
,
DiseaseDescription
,
DiseaseCause
,
DiseaseCauseDescription
,
DiseaseDiagnose
,
DiseaseDiagnoseDescription
,
DiseasePrevention
,
DiseasePreventionDescription
,
DiseaseSymptoms
,
DiseaseSymptomsDescription
,
DiseaseTreatment
,
DiseaseTreatmentDescription
=
row
Disease
,
DiseaseDescription
,
DiseaseCause
,
DiseaseCauseDescription
,
DiseaseDiagnose
,
DiseaseDiagnoseDescription
,
DiseasePrevention
,
DiseasePreventionDescription
,
DiseaseSymptoms
,
DiseaseSymptomsDescription
,
DiseaseTreatment
,
DiseaseTreatmentDescription
=
row
individual
=
onto
.
Disease
(
Disease
)
Class_name
=
str
(
Disease
)
SuperClasses
=
[
onto
.
NamedDisease
]
Class
=
types
.
new_class
(
Class_name
,
tuple
(
SuperClasses
))
listOfClasses
.
append
(
Class
)
individual
=
Class
()
if
DiseaseDescription
:
if
DiseaseDescription
:
individual
.
hasDescription
.
append
(
DiseaseDescription
)
individual
.
hasDescription
.
append
(
DiseaseDescription
)
if
DiseaseCause
:
if
DiseaseCause
:
diseaseCauseClass
=
onto
.
DiseaseCause
(
DiseaseCause
)
Sub_Class_name_cause
=
Class_name
+
"Cause"
SuperClasses
=
[
onto
.
DiseaseCause
]
ClassCause
=
types
.
new_class
(
Sub_Class_name_cause
,
tuple
(
SuperClasses
))
listOfClasses
.
append
(
ClassCause
)
individualCause
=
ClassCause
()
# diseaseCauseClass = onto.DiseaseCause(DiseaseCause)
if
DiseaseCauseDescription
:
if
DiseaseCauseDescription
:
diseaseCauseClass
.
hasCasueDescription
.
append
(
DiseaseCauseDescription
)
individualCause
.
hasCasueDescription
.
append
(
DiseaseCauseDescription
)
individual
.
hasCause
.
append
(
diseaseCauseClass
)
# individualCause.hasCause.append(ClassCause
)
if
DiseaseDiagnose
:
if
DiseaseDiagnose
:
diseaseDiagnoseClass
=
onto
.
DiseaseDiagnose
(
DiseaseDiagnose
)
Sub_Class_name_diagnose
=
Class_name
+
"Diagnose"
SuperClasses
=
[
onto
.
DiseaseDiagnose
]
ClassDiagnose
=
types
.
new_class
(
Sub_Class_name_diagnose
,
tuple
(
SuperClasses
))
listOfClasses
.
append
(
ClassDiagnose
)
individualDiagnose
=
ClassDiagnose
()
# diseaseDiagnoseClass = onto.DiseaseDiagnose(DiseaseDiagnose)
if
DiseaseDiagnoseDescription
:
if
DiseaseDiagnoseDescription
:
diseaseDiagnoseClass
.
hasDiagnoseDescription
.
append
(
DiseaseDiagnoseDescription
)
individualDiagnose
.
hasDiagnoseDescription
.
append
(
DiseaseDiagnoseDescription
)
individual
.
hasDiagnose
.
append
(
diseaseDiagnoseClass
)
# individualDiagnose.hasDiagnose.append(ClassDiagnose
)
if
DiseasePrevention
:
if
DiseasePrevention
:
diseasePreventionClass
=
onto
.
DiseasePrevention
(
DiseasePrevention
)
Sub_Class_name_prevention
=
Class_name
+
"Prevention"
SuperClasses
=
[
onto
.
DiseasePrevention
]
ClassPrevention
=
types
.
new_class
(
Sub_Class_name_prevention
,
tuple
(
SuperClasses
))
listOfClasses
.
append
(
ClassPrevention
)
individualPrevention
=
ClassPrevention
()
# diseasePreventionClass = onto.DiseasePrevention(DiseasePrevention)
if
DiseasePreventionDescription
:
if
DiseasePreventionDescription
:
diseasePreventionClass
.
hasPreventionDescription
.
append
(
DiseasePreventionDescription
)
individualPrevention
.
hasPreventionDescription
.
append
(
DiseasePreventionDescription
)
individual
.
hasPrevention
.
append
(
diseasePreventionClass
)
# individualPrevention.hasPrevention.append(ClassPrevention
)
if
DiseaseSymptoms
:
if
DiseaseSymptoms
:
diseaseSymptomClass
=
onto
.
DiseaseSymptom
(
DiseaseSymptoms
)
Sub_Class_name_symptom
=
Class_name
+
"Symptom"
SuperClasses
=
[
onto
.
DiseaseSymptom
]
ClassSymptom
=
types
.
new_class
(
Sub_Class_name_symptom
,
tuple
(
SuperClasses
))
listOfClasses
.
append
(
ClassSymptom
)
individualSymptom
=
ClassSymptom
()
# diseaseSymptomClass = onto.DiseaseSymptom(DiseaseSymptoms)
if
DiseaseSymptomsDescription
:
if
DiseaseSymptomsDescription
:
diseaseSymptomClass
.
hasSymptomDescription
.
append
(
DiseaseSymptomsDescription
)
individualSymptom
.
hasSymptomDescription
.
append
(
DiseaseSymptomsDescription
)
individual
.
hasSymptom
.
append
(
diseaseSymptomClass
)
# individualSymptom.hasSymptom.append(ClassSymptom
)
if
DiseaseTreatment
:
if
DiseaseTreatment
:
diseaseTreatmentClass
=
onto
.
DiseaseTreatment
(
DiseaseTreatment
)
Sub_Class_name_treatment
=
Class_name
+
"Treatment"
SuperClasses
=
[
onto
.
DiseaseTreatment
]
ClassTreatment
=
types
.
new_class
(
Sub_Class_name_treatment
,
tuple
(
SuperClasses
))
listOfClasses
.
append
(
ClassTreatment
)
# diseaseTreatmentClass = onto.DiseaseTreatment(DiseaseTreatment)
individualTreatment
=
ClassTreatment
()
if
DiseaseTreatmentDescription
:
if
DiseaseTreatmentDescription
:
diseaseTreatmentClass
.
hasTreatmentDescription
.
append
(
DiseaseTreatmentDescription
)
individualTreatment
.
hasTreatmentDescription
.
append
(
DiseaseTreatmentDescription
)
individual
.
hasTreatment
.
append
(
diseaseTreatmentClass
)
# individualTreatment.hasTreatment.append(ClassTreatment)
print
(
listOfClasses
)
AllDisjoint
(
listOfClasses
)
onto_individuals
.
save
(
"dogDisease.owl"
)
onto_individuals
.
save
(
"dogDisease.owl"
)
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