Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to writing inferred result back to ontology #86

Open
OrselChiang opened this issue May 22, 2024 · 1 comment
Open

Fail to writing inferred result back to ontology #86

OrselChiang opened this issue May 22, 2024 · 1 comment

Comments

@OrselChiang
Copy link

OrselChiang commented May 22, 2024

I have written the following code to utilize the SWRLRuleEngine for executing a self-defined rule. When I output the ontology to a file and inspect it in Protege, I notice that only the rule is being recorded in the ontology, not the inferences. In contrast, when I execute the rule through the Protege plugin, the inferred results are correctly displayed.

I am puzzled by this discrepancy and would like to know what might be incorrect with my code.


 // Read an OWL ontology using the OWLAPI
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
String PathName = "src/main/java/org/swrlapi/example/exercise_based_pulmonary_rehabilitation2.0.owl";
File file = new File(PathName);
OWLOntology localEBPRont = manager.loadOntologyFromOntologyDocument(file);

SWRLRuleEngine ruleEngine = SWRLAPIFactory.createSWRLRuleEngine(localEBPRont);
SWRLAPIRule rule = ruleEngine.createSWRLRule("PatientProfile-ChestTightness",
        "PatientAssessment(?p) ^ ChestTightness(?e)-> hasPatientProfile(?p, ?e)");

ruleEngine.infer();
File folder = new File("src/main/java/org/swrlapi/example");
File filesave = new File(folder, "inferredResult_saving.owl");
manager.saveOntology(localEBPRont, IRI.create(filesave.toURI()));
@martinjoconnor
Copy link
Member

I would use a SQWRL query to verify that the rule generates a result, e.g.,

PatientAssessment(?p) ^ ChestTightness(?e)-> sqwrl:select(?p, ?e)

The rule engine also has a method called getInferredOWLAxioms that can be used to see what axioms were generated by the inference process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants