Rule using inferred triples does not work

Hi all,

I’m trying to build a Stardog rule which makes use of inferred triples by another rule. Apparently the rule does not match. I know that Stardog does not materialize inferred triples but I thought that when using SWRL syntax rules using inferred triples did work.

Would you be so kind to help me out?

Kind regards,
Johan,

It should. Can you share your data, rules, ontology, query that isn’t working, what you expected, what you got, how you loaded the data, database options, and the version of Stardog you’re using?

Hi,
Thanks for your reply. Sharing my data / ontology is a litle difficult due to privacy. If we can’t find the issue with the info below I’ll have to create a testcase.

These 2 rules are working:

Rule 1:

IF {
	?o a sosa:Observation .
	?o sosa:observedProperty <http://www.mycompany.com/resources#Humidity> .
    ?o sosa:hasFeatureOfInterest ?foi .
    ?o sosa:phenomenonTime ?t .
    ?o sosa:hasResult ?r .
    ?r qudt:numericValue ?v .
    FILTER (?v > 40) .
    FILTER (?v < 70) .
}
THEN {
    ?foi resources:hasHumidity <http://www.mycompany.com/samples/weather#AverageHumidity>
}

Rule 2:

IF {
	?o a sosa:Observation .
	?o sosa:observedProperty <http://www.mycompany.com/resources#Temperature> .
    ?o sosa:hasFeatureOfInterest ?foi .
    ?o sosa:phenomenonTime ?t .
    ?o sosa:hasResult ?r .
    ?r qudt:numericValue ?v .
    FILTER (?v < 0) .
}
THEN {
    ?foi resources:hasTemperature <http://www.mycompany.com/samples/weather#Frosty>
}

Rule 3 should match in case the same ?foi hasTemperature Frosty and hasHumidity AverageHumidity or MoistHumidity or VeryMoistHumidity :

IF {
	  ?foi a sosa:FeatureOfInterest .
        ?foi resources:hasTemperature weather:Frosty .
        ?foi resources:hasHumidity ?hum .
        FILTER (?hum = weather:AverageHumidity || ?hum = weather:MoistHumidity || ?hum = weather:VeryMoistHumidity)
}
THEN {
    ?foi resources:hasPhenomenon <http://www.mycompany.com/samples/weather#PotentiallyIcy>
}

As rule 1 and rule 2 are working (I can select ?foi that have the hasTemperature and HasHumidity predicates with the correct values, the issue should be in rule 3.

Thanks for helping me out.
Johan,

This ‘combining’ rule is also working :

IF {
	  ?foi a sosa:FeatureOfInterest .
        ?foi resources:hasTemperature weather:Frosty .
        ?foi resources:hasHumidity weather:AverageHumidity .
}
THEN {
    ?foi resources:hasPhenomenon <http://www.mycompany.com/samples/weather#PotentiallyIcy>
}

So the question is how to model the weather:AverageHumidity or weather:MoistHumidity or weather:VeryMoistHumidity

Thanks again!

Johan,

I haven’t had a chance to look at what you sent yet but I forgot to ask if there were any errors or warnings in the log. I suspect that the most likely thing you’ll find are warnings about cycles in your rules but that’s a guess at this point.

Hi,

After some more testing and rewriting of my rule it finally works:

IF {
	  ?foi a sosa:FeatureOfInterest .
        ?foi resources:hasTemperature weather:Frosty .
        { ?foi resources:hasHumidity weather:MoistHumidity }
        UNION { ?foi resources:hasHumidity weather:VeryMoistHumidity }
        UNION { ?foi resources:hasHumidity weather:AverageHumidity } .
}
THEN {
    ?foi resources:hasPhenomenon <http://www.mycompany.com/samples/weather#PotentiallyIcy>
}

It had to do with the way I refer to the inferred triples and the OR constuction I tried to make.

Thanks anyway for helping me.
Johan,

Glad to hear you got it working. So what exactly was the problem with your rule construction? Was it the use of equality in the filter? Would it have worked if you had used the sameterm function?

Hi,

Yes it had to do with the way I was checking whether resources:hasHumidity is pointing to AverageHumidity, MoistHumidity or VeryMoistHumidity.

I think sameterm would work too. Currently I use UNION as follows:

IF {
?foi a sosa:FeatureOfInterest .
?foi resources:hasTemperature weather:Frosty .
{ ?foi resources:hasHumidity weather:MoistHumidity }
UNION { ?foi resources:hasHumidity weather:VeryMoistHumidity }
UNION { ?foi resources:hasHumidity weather:AverageHumidity } .
}
THEN {
?foi resources:hasPhenomenon http://www.mycompany.com/samples/weather#PotentiallyIcy
}

Would the use of sameterm be more efficient?

Johan,

Not sure. I’m just trying to understand why your first try wouldn’t work and learn from your experience. I’m not sure that using sameTerm would actually work but it might be interesting to give it a try and if it works look at any differences in the query plan. Now that I think about it I"m not sure if using sameTerm to compare a uri’s is any different from simple equality.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.