Dave is absolutely right! According to the grammar of the Jena rules [1], which among others define nodes as
/node/:= /uri-ref/// e.g. http://foo.com/eg or prefix:localname // e.g. rdf:type or </uri-ref/> // e.g. <myscheme:myuri> or ?/varname /// variable or 'a literal' // a plain string literal or 'lex'^^typeURI // a typed literal, xsd:* type names supported or number // e.g. 42 or 25.5 you have to use 'false'^^xsd:boolean, i.e. the rule would be [rule4: (?p rdf:type enviot:Phenomenon), (?p enviot:hasField enviot:FieldWithSheep), (?p enviot:hasRainfall enviot:HighIntensiveRain), (?p enviot:hasSoilMoistureCondition enviot:SaturatedSoil), (?p enviot:hasRiparianZone 'false'^^xsd:boolean) -> (?p rdf:type enviot:RiskOfPollution)] Cheers, Lorenz [1] https://jena.apache.org/documentation/inference/#rules > Hi Izhar, > > Not sure I would call that a minimal example. > > Without working through any details the first thing I noticed is that > you are testing for enviot:hasRiparianZone with string "false", > whereas your sample data has a boolean false, different things. > > That may or may not be the only issue. It would not explain why the > rule would work after OWL inference. > > Dave > > On 21/07/17 12:48, Ullah, Izhar wrote: >> Dear Lorenz, Adrian and Dave, >> >> Many thanks for your replies. Actually, the data is so scattered in >> the ontology file I thought it would be really hard for you to >> understand it if I took a sample of it and put it here. Let me try to >> do so. Please have a look at the relevant data related to the rule >> given below: >> >> <!-- >> http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#RiskOfPollution >> --> >> >> <owl:Class >> rdf:about="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#RiskOfPollution"> >> <owl:equivalentClass> >> <owl:Class> >> <owl:intersectionOf rdf:parseType="Collection"> >> <rdf:Description >> rdf:about="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#Phenomenon"/> >> <owl:Restriction> >> <owl:onProperty >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#hasField"/> >> <owl:someValuesFrom >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#FieldWithSheep"/> >> </owl:Restriction> >> <owl:Restriction> >> <owl:onProperty >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#hasRainfall"/> >> <owl:someValuesFrom >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#HighIntensiveRain"/> >> </owl:Restriction> >> <owl:Restriction> >> <owl:onProperty >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#hasSoilMoistureCondition"/> >> <owl:someValuesFrom >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#SaturatedSoil"/> >> </owl:Restriction> >> <owl:Restriction> >> <owl:onProperty >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#hasRiparianZone"/> >> <owl:hasValue >> rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</owl:hasValue> >> </owl:Restriction> >> </owl:intersectionOf> >> </owl:Class> >> </owl:equivalentClass> >> </owl:Class> >> >> >> <!-- >> http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#PhenomenonPollution >> --> >> >> <owl:NamedIndividual >> rdf:about="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#PhenomenonPollution"> >> <rdf:type >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#Phenomenon"/> >> <hasField >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#FieldWithSheep1"/> >> <hasRainfall >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#HighIntensiveRain1"/> >> <hasSoilMoistureCondition >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#SaturatedSoil1"/> >> <hasRiparianZone >> rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasRiparianZone> >> </owl:NamedIndividual> >> >> <!-- >> http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#FieldWithSheep1 >> --> >> >> <owl:NamedIndividual >> rdf:about="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#FieldWithSheep1"> >> <rdf:type >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#FieldWithSheep"/> >> <hasSheep >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#SheepDolly2"/> >> </owl:NamedIndividual> >> >> <!-- >> http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#HighIntensiveRain1 >> --> >> >> <owl:NamedIndividual >> rdf:about="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#HighIntensiveRain1"> >> <rdf:type >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#HighIntensiveRain"/> >> <hasRainfallValue >> rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">60.0</hasRainfallValue> >> </owl:NamedIndividual> >> >> <!-- >> http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#SaturatedSoil1 >> --> >> >> <owl:NamedIndividual >> rdf:about="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#SaturatedSoil1"> >> <rdf:type >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#SaturatedSoil"/> >> <hasSoilMoistureValue >> rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">650</hasSoilMoistureValue> >> </owl:NamedIndividual> >> >> <!-- >> http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#hasRiparianZone >> --> >> >> <owl:DatatypeProperty >> rdf:about="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#hasRiparianZone"> >> <rdf:type >> rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/> >> <rdfs:range >> rdf:resource="http://www.w3.org/2001/XMLSchema#boolean"/> >> </owl:DatatypeProperty> >> >> <owl:Restriction> >> <owl:onProperty >> rdf:resource="http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#hasRiparianZone"/> >> <owl:hasValue >> rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</owl:hasValue> >> </owl:Restriction> >> >> The rule from the rule file (along with all prefixes) is given below: >> >> @prefix enviot: >> <http://www.environmental-iot.com/enviot_ontology/IotSemanticModel#>. >> @prefix foaf: <http://xmlns.com/foaf/0.1/>. >> @prefix time: <http://www.w3.org/2006/time#>. >> @prefix owl: <http://www.w3.org/2002/07/owl#>. >> @prefix sf: <http://www.opengis.net/ont/sf#>. >> @prefix dc: <http://purl.org/dc/elements/1.1/>. >> @prefix xsd: <http://www.w3.org/2001/XMLSchema#>. >> @prefix muo: <http://purl.oclc.org/NET/muo/muo#>. >> @prefix ssn: <http://purl.oclc.org/NET/ssnx/ssn#>. >> @prefix DUL: <http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#>. >> @prefix skos: <http://www.w3.org/2004/02/skos/core#>. >> @prefix geosparql: <http://www.opengis.net/ont/geosparql#>. >> @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. >> @prefix wgs84_pos: <http://www.w3.org/2003/01/geo/wgs84_pos#>. >> @prefix geof: <http://www.opengis.net/def/function/geosparql/>. >> >> [rule4: (?p rdf:type enviot:Phenomenon), (?p enviot:hasField >> enviot:FieldWithSheep), (?p enviot:hasRainfall >> enviot:HighIntensiveRain), (?p enviot:hasSoilMoistureCondition >> enviot:SaturatedSoil), (?p enviot:hasRiparianZone “false”) -> >> (?p rdf:type enviot:RiskOfPollution)] >> >> If you need further information or chuck of the data regarding the >> rule please let me know. >> >> I would really appreciate your effort, time and help. >> >> Best regards, >> >> Izhar >> >> >> ________________________________________ >> From: Lorenz Buehmann [buehm...@informatik.uni-leipzig.de] >> Sent: 21 July 2017 09:59 >> To: users@jena.apache.org >> Subject: Re: Generic Rule Reasoning over Data using Jena Framework 3.1 >> >> Exactly, and this should be quite obvious. >> >> How can we explain why _your rule_ doesn't fire on _your data_ >> without seing >> >> * the rule and >> >> * sample data >> >> >> At least the rule should be shown here. And if you're not allowed to >> publish the data you should make an anonymized, minimal sample (it's >> usually enough to replace the URIs by some simply URIs) and post it here >> as well. >> >> >> On 20.07.2017 22:28, Dave Reynolds wrote: >>> Don't see any way anyone can help without at least seeing the rule >>> that doesn't fire! >>> >>> [And I'm not offering off-list consultancy, please do not send me any >>> confidential data!] >>> >>> However, if it runs after you've done a full inference closure then >>> presumably that's the issue. It suggests that your rule is relying on >>> some OWL inference and won't fire on the raw data. In which case you >>> either need to modify your rule to not require that inference or >>> extend your rule set to perform the required OWL inference (if >>> possible, and bearing in mind that forward rules won't see the results >>> of backward inference). >>> >>> If that doesn't help then I suggest you cut both your data and rule >>> down a complete minimal example that is sufficiently abstract you can >>> post it. >>> >>> Dave >>> >>> On 20/07/17 21:07, Ullah, Izhar wrote: >>>> Hi all, >>>> >>>> I am trying to reason over data using Jena rules (a separate txt >>>> file) and a data file (which is an ontology file having instances). >>>> Just to give an idea of how my simple code looks like, have a look at >>>> the piece of code given below: >>>> >>>> >>>> public static void main(String[] args) throws MalformedURLException { >>>> >>>> >>>> >>>> Model instances = ModelFactory.createDefaultModel(); >>>> >>>> >>>> >>>> instances.read >>>> ("/Users/Desktop/Ontology/IoT-Ontology-file.owl", "TURTLE"); >>>> >>>> >>>> >>>> Reasoner reasoner = new >>>> >>>> >>>> GenericRuleReasoner(Rule.rulesFromURL("/Users/Desktop/rules_iot.txt")); >>>> >>>> >>>> >>>> >>>> reasoner.setDerivationLogging(true); >>>> >>>> >>>> >>>> InfModel inf = ModelFactory.createInfModel(reasoner, instances); >>>> >>>> >>>> >>>> Let me clearly say that the above code is not complete. I have run my >>>> code over three Jena rules successfully and derived/inferred new >>>> facts from the data file (ontology file) but it does not work for one >>>> rule. It does not give any error but the rule seems to be not firing. >>>> Though, when I run the Ontology reasoner (Pellet reasoner) over my >>>> ontology, it successfully fires and infers a new fact. >>>> >>>> >>>> Can someone please help me out? I can't send my data file (ontology >>>> file) to the group because of confidentiality and privacy issues but >>>> I can send it to a particular individual at his/her email address who >>>> could help. >>>> >>>> >>>> Should you require any further information please let me know. >>>> >>>> >>>> Many thanks in advance. >>>> >>>> >>>> Best regards, >>>> >>>> >>>> Izhar >>>> >>>> >>>> >>>> >>> >> > > -- Lorenz Bühmann AKSW group, University of Leipzig Group: http://aksw.org - semantic web research center