Commit 6f7c3ac3 authored by Wickramasinghe R.J.P's avatar Wickramasinghe R.J.P

ontology generator updated

parent 1caf9779
...@@ -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("dogSkinDisease.owl").load() onto = get_ontology("dd.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")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment