Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ontology = '/full/path/ontology.owl'
- world = default_world
- fileno, filename = tempfile.mkstemp()
- world.set_backend(filename = filename)
- onto = world.get_ontology(ontology).load()
- with onto:
- patient = onto.search_one(label='Patient')
- fev = onto.search_one(label='FEV')
- has_value = onto.search_one(label='hasValue')
- has_assessment = onto.search_one(label='hasAssessment')
- has_gold_stage = onto.search_one(label='hasGOLDStage')
- gold_rules = [
- f"""{patient.iri}(?p), {fev.iri}(?f), {has_assessment.iri}(?p, ?f), {has_value.iri}(?f, ?v),
- greaterThanOrEqual(?v, 80) -> {has_gold_stage.iri}(?p, 1)""",
- f"""{patient.iri}(?p), {fev.iri}(?f), {has_assessment.iri}(?p, ?f), {has_value.iri}(?f, ?v),
- greaterThanOrEqual(?v, 50), lessThan(?v, 80) -> {has_gold_stage.iri}(?p, 2)""",
- f"""{patient.iri}(?p), {fev.iri}(?f), {has_assessment.iri}(?p, ?f), {has_value.iri}(?f, ?v),
- greaterThanOrEqual(?v, 30), lessThan(?v, 50) -> {has_gold_stage.iri}(?p, 3)""",
- f"""{patient.iri}(?p), {fev.iri}(?f), {has_assessment.iri}(?p, ?f), {has_value.iri}(?f, ?v),
- lessThan(?v, 30) -> {has_gold_stage.iri}(?p, 4)"""
- ]
- for rule in rules:
- Imp().set_as_rule(rule)
- patient_one = patient()
- high_fev = fev()
- high_fev.hasValue = 85
- patient_one.hasAssessment = high_fev
- patient_two = patient()
- low_fev = fev()
- low_fev.hasValue = 43
- patient_two.hasAssessment = low_fev
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement