good evening everyone i have created a simple ontology with only one class (methods) and have dataproperty action_nb (integer) and type witch is (String) and can only be ( choice, rank , sort ) then use a query to searche for example: select the method WHERE action number <20 & type = " choice"
how to declare the action_nb in a intervale ex: methode1 => action_nb between [10, 30].
how to declare the type with the three values ex: methode1=> type:"choice";
this is the code that i have right now:
SELECT ?inst
WHERE {
?inst ex:action_nb ?value .
?inst es:type ?typ.
FILTER (?value < 80)
FILTER (?typ = " tri " )
}
For 1), you can use datatype property restrictions, explained here
For 2), you should use owl:oneOf
. This you can do with either enumerated class or enumerated datatype:
Enumerated Classes can only have members within a declared list of RDF resources (individuals). You can create a different individual for each choice, and then a class MethodType
with equivalent class the list {choice, rank, sort}
. Please note that the curly brackets is the way it will look in Protégé. In Turtle it will look like this:
:MethodType
rdf:type owl:Class ;
owl:equivalentClass [
rdf:type owl:Class ;
owl:oneOf (
:choice
:rank
:sort
) ;
] ;
.
Enumerated Datatypes are range restrictions consisting of lists of RDF literals, in your case the rdfs:range
will be owl:oneOf {"choice", "rank", "sort"}
. (Notes: 1. The comment for the curly brackets holds here was well; 2.This can also be achieved with owl:allValuesFrom restrictions.)
If the typeOP
and typeDP
, are espectively the object property for the first approach, and the data property for the second the queries could be:
SELECT *
WHERE {
?m a :Method;
:typeOP ?t .
FILTER EXISTS {?m :typeOP :choice}
}
and
SELECT *
WHERE {
?m a :Method;
:typeDP ?t .
FILTER EXISTS {?m :typeDP "choice"}
}
respectively.