0

I am trying to build a Apache Jena reasoner node over the below rdf data instance. I want to write a rule such that the inference api can tell if certain sensor values were out of range. e.g. print statement whose sensor measurement (value of hasValue) was not in range 100 to 400.

How do I write a rule using Apache Jena inference api. I tried reading the docs here: https://jena.apache.org/documentation/inference/index.html but I am getting more confused with the amount of details given.

Should I use RDFS reasoner or OWL reasoner? How do I develop the code exactly for my use case?

@prefix iot-context: <http://www.example.org/iot-context#> .
@prefix iot_lite_ins: <http://purl.oclc.org/NET/UNIS/iot-lite/iot-liteInstance#> .
@prefix measurement-iri: <http://www.example.org/iot-instance#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

iot_lite_ins:temperatureSensorA iot-context:hasMeasurement measurement-iri:measurement_123 .

measurement-iri:measurement_123 a iot-context:measurement ;
    iot-context:hasTimeStamp "2022-01-28T11:50:00.352485"^^xsd:dateTime ;
    iot-context:hasValue 456 .

I have another rdf schema defining what sensor is located in what region (having lat and long values in graph). How can I write a rule which answers: Was sensor value out of range in region abc (having lat = 11 and long = 22).

Akshay Patel
  • 85
  • 10
  • 1
    if you want to write a custom rule, you have to use the generic rule reasoner and use their required syntax: https://jena.apache.org/documentation/inference/index.html#rules - the built-in primitives `lessThan` and `greaterThan` are the way to go I'd say (or `le` / `ge` if range boundaries matter) – UninformedUser Jan 29 '22 at 08:48
  • beyond rules you should also think about SHACL if your goal is more the validation of RDF data – UninformedUser Jan 29 '22 at 08:53

0 Answers0