protegeproject / swrlapi

Java API for working with the SWRL rule and SQWRL query languages
Other
99 stars 40 forks source link

Error "Object URI was invalid: _:genid" when adding rules using createSWRLRule() instead of SWRLTab #62

Closed nqduy35 closed 5 years ago

nqduy35 commented 5 years ago

Using SWRLAPI 2.0.6, OWLAPI 4.2.8 for this test. The code is simple as in this example except the ontology and the testing rule: abc:Person(?person) -> abc:hasCar(?person,def:Car_Toyota_Black).

I do three test cases:

  1. Add this rule to the Ontology using protege swrlTab. Run Drools in swrlTab: GOOD

  2. Add this rule to the Ontology using protege swrlTab. Run function ruleEngine.infer() of SWRLAPI: GOOD

  3. Add this rule to the Ontology using SWRLAPI with the function createSWRLRuleEngine(ontology) as in the example. Run function ruleEngine.Infer() of SWRLAPI: error appear: ERROR org.semanticweb.owlapi.rio.utils.RioUtils - Object URI was invalid: _:genid854 <http://www.w3.org/2003/11/swrl#argument1> <#person>.

What is the problem?

martinjoconnor commented 5 years ago

Have you defined prefix mappings for both 'abc' and 'def'?

Can you post a detailed code fragment.

nqduy35 commented 5 years ago

Thank @martinjoconnor for the answer. According to your instruction, I need to define "prefix mappings" on the code to use the my prefixes. It is not enough the declaration of the prefixes in the ontology file (.owl). I will try this solution and close the topic here.