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 *
import csv, types
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.imported_ontologies.append(onto)
listOfClasses = []
f = open("dogDisease.csv", encoding='utf-8')
reader = csv.reader(f)
next(reader)
......@@ -14,39 +16,71 @@ if __name__ == '__main__':
with onto_individuals:
for row in reader:
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:
individual.hasDescription.append(DiseaseDescription)
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:
diseaseCauseClass.hasCasueDescription.append(DiseaseCauseDescription)
individual.hasCause.append(diseaseCauseClass)
individualCause.hasCasueDescription.append(DiseaseCauseDescription)
# individualCause.hasCause.append(ClassCause)
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:
diseaseDiagnoseClass.hasDiagnoseDescription.append(DiseaseDiagnoseDescription)
individual.hasDiagnose.append(diseaseDiagnoseClass)
individualDiagnose.hasDiagnoseDescription.append(DiseaseDiagnoseDescription)
# individualDiagnose.hasDiagnose.append(ClassDiagnose)
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:
diseasePreventionClass.hasPreventionDescription.append(DiseasePreventionDescription)
individual.hasPrevention.append(diseasePreventionClass)
individualPrevention.hasPreventionDescription.append(DiseasePreventionDescription)
# individualPrevention.hasPrevention.append(ClassPrevention)
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:
diseaseSymptomClass.hasSymptomDescription.append(DiseaseSymptomsDescription)
individual.hasSymptom.append(diseaseSymptomClass)
individualSymptom.hasSymptomDescription.append(DiseaseSymptomsDescription)
# individualSymptom.hasSymptom.append(ClassSymptom)
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:
diseaseTreatmentClass.hasTreatmentDescription.append(DiseaseTreatmentDescription)
individual.hasTreatment.append(diseaseTreatmentClass)
individualTreatment.hasTreatmentDescription.append(DiseaseTreatmentDescription)
# individualTreatment.hasTreatment.append(ClassTreatment)
print(listOfClasses)
AllDisjoint(listOfClasses)
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