On 17/11/12 14:27, Marco Knietzsch wrote:
Hi, I am trying to get Jena.NET up and running but I got stuck trying to build a custom
reasoner.I have the following rules-File:@prefix this: <URI:/TRPG-Ontology#>.@include
<RDFS>.@include <OWL>.
[OwnsContainerOwnsInsides: (?owner this:owns ?container), (?item this:insideOf
?container) -> (?owner this:owns ?item)]
I try to extend the standard OWL-reasoner like this:
//first create a default model from my ontologyInputStream inputStream = FileManager.get ().open
(inputFileName);if (inputStream == null) { throw new ArgumentException ("File: " + inputFileName +
" not found");}Model read = ModelFactory.createDefaultModel ();read.read (new InputStreamReader
(inputStream), "");
//read the rules fileStringReader f = new StringReader(ruleFile);BufferedReader
b = new BufferedReader(f);Rule.Parser p =
Rule.rulesParserFromReader(b);java.util.List rules = Rule.parseRules(p); //this
throws ParserExceptionReasoner reasoner = new GenericRuleReasoner
(rules);OntModelSpec s = new OntModelSpec (OntModelSpec.OWL_MEM);s.setReasoner
(reasoner);model = ModelFactory.createOntologyModel (s, read);
When I run the code I get the following exception:ParserException: Expected '('
at start of clause, found Projects/TRPG/Assets/rules.txtAt
'C:/Users/shiroto/Documents/Unity Projects/TRPG/Assets/rules.txt
'com.hp.hpl.jena.reasoner.rulesys.Rule+Parser.parseNodeList
()com.hp.hpl.jena.reasoner.rulesys.Rule+Parser.parseClause
()com.hp.hpl.jena.reasoner.rulesys.Rule+Parser.doParseRule (Boolean
)com.hp.hpl.jena.reasoner.rulesys.Rule+Parser.parseRule
()com.hp.hpl.jena.reasoner.rulesys.Rule.parseRules
(com.hp.hpl.jena.reasoner.rulesys.Parser parser)BaseModel.GetModel () (at
Assets/Scripts/Components/BaseModel.cs:86)BaseModel.Awake () (at
Assets/Scripts/Components/BaseModel.cs:26)
I spent hours searching for a solution but found nothing that helped. If noone
here can help me Im afraid I have to look for another framework :/So, any ideas?
Regards,Marco
You don't show enough of your code, in particular the value you assign
"ruleFile". That name makes it sound like to mean it to be a file name
but your code is reading the string itself not the file.
If I put your rule text into a file and read it with a FileReader
instead of StringReader the code runs fine.
Note that you don't need to @include both RDFS and OWL rules, just one.
Dave