Commit 1caf9779 authored by Wickramasinghe R.J.P's avatar Wickramasinghe R.J.P

ontology generation script added

parent 3c8e482f
from owlready2 import *
import csv, types
if __name__ == '__main__':
onto = get_ontology("dogSkinDisease.owl").load()
onto_individuals = get_ontology("http://www.semanticweb.org/dogdisease/ontologies/2022/4/dogDisease.owl")
onto_individuals.imported_ontologies.append(onto)
f = open("dogDisease.csv", encoding='utf-8')
reader = csv.reader(f)
next(reader)
with onto_individuals:
for row in reader:
Disease, DiseaseDescription, DiseaseCause, DiseaseCauseDescription, DiseaseDiagnose, DiseaseDiagnoseDescription, DiseasePrevention, DiseasePreventionDescription, DiseaseSymptoms, DiseaseSymptomsDescription, DiseaseTreatment, DiseaseTreatmentDescription = row
individual = onto.Disease(Disease)
if DiseaseDescription:
individual.hasDescription.append(DiseaseDescription)
if DiseaseCause:
diseaseCauseClass = onto.DiseaseCause(DiseaseCause)
if DiseaseCauseDescription:
diseaseCauseClass.hasCasueDescription.append(DiseaseCauseDescription)
individual.hasCause.append(diseaseCauseClass)
if DiseaseDiagnose:
diseaseDiagnoseClass = onto.DiseaseDiagnose(DiseaseDiagnose)
if DiseaseDiagnoseDescription:
diseaseDiagnoseClass.hasDiagnoseDescription.append(DiseaseDiagnoseDescription)
individual.hasDiagnose.append(diseaseDiagnoseClass)
if DiseasePrevention:
diseasePreventionClass = onto.DiseasePrevention(DiseasePrevention)
if DiseasePreventionDescription:
diseasePreventionClass.hasPreventionDescription.append(DiseasePreventionDescription)
individual.hasPrevention.append(diseasePreventionClass)
if DiseaseSymptoms:
diseaseSymptomClass = onto.DiseaseSymptom(DiseaseSymptoms)
if DiseaseSymptomsDescription:
diseaseSymptomClass.hasSymptomDescription.append(DiseaseSymptomsDescription)
individual.hasSymptom.append(diseaseSymptomClass)
if DiseaseTreatment:
diseaseTreatmentClass = onto.DiseaseTreatment(DiseaseTreatment)
if DiseaseTreatmentDescription:
diseaseTreatmentClass.hasTreatmentDescription.append(DiseaseTreatmentDescription)
individual.hasTreatment.append(diseaseTreatmentClass)
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