ontology - Executing a SPARQL query -


i have created small ontology. has 1 class called methods , datatype property action_nb (integer).

then created 2 individuals :

ahp => action_nb = 20

electre => action_nb = 50

i want execute simple query . select method nb_action < 40 , results should give me el1.

<?xml version="1.0"?>      <!doctype rdf:rdf [      <!entity owl "http://www.w3.org/2002/07/owl#" >      <!entity xsd "http://www.w3.org/2001/xmlschema#" >      <!entity rdfs "http://www.w3.org/2000/01/rdf-schema#" >      <!entity rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >      <!entity untitled-ontology-77 "http://www.semanticweb.org/diabolico/ontologies/2016/3/untitled-ontology-77#" >  ]>      <rdf:rdf xmlns="http://www.semanticweb.org/diabolico/ontologies/2016/3/untitled-ontology-77#"       xml:base="http://www.semanticweb.org/diabolico/ontologies/2016/3/untitled-ontology-77"       xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"       xmlns:untitled-ontology-77="http://www.semanticweb.org/diabolico/ontologies/2016/3/untitled-ontology-77#"       xmlns:owl="http://www.w3.org/2002/07/owl#"       xmlns:xsd="http://www.w3.org/2001/xmlschema#"       xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">      <owl:ontology rdf:about="http://www.semanticweb.org/diabolico/ontologies/2016/3/untitled-ontology-77"/>                <!--       ///////////////////////////////////////////////////////////////////////////////////////      //      // data properties      //      ///////////////////////////////////////////////////////////////////////////////////////       -->                  <!-- http://www.semanticweb.org/diabolico/ontologies/2016/3/untitled-ontology-77#action_nb -->        <owl:datatypeproperty rdf:about="&untitled-ontology-77;action_nb">          <rdfs:domain rdf:resource="&untitled-ontology-77;methods"/>          <rdfs:range rdf:resource="&xsd;integer"/>      </owl:datatypeproperty>                <!--       ///////////////////////////////////////////////////////////////////////////////////////      //      // classes      //      ///////////////////////////////////////////////////////////////////////////////////////       -->                  <!-- http://www.semanticweb.org/diabolico/ontologies/2016/3/untitled-ontology-77#methods -->        <owl:class rdf:about="&untitled-ontology-77;methods"/>                <!--       ///////////////////////////////////////////////////////////////////////////////////////      //      // individuals      //      ///////////////////////////////////////////////////////////////////////////////////////       -->                  <!-- http://www.semanticweb.org/diabolico/ontologies/2016/3/untitled-ontology-77#ahp -->        <owl:namedindividual rdf:about="&untitled-ontology-77;ahp">          <rdf:type rdf:resource="&untitled-ontology-77;methods"/>          <action_nb rdf:datatype="&xsd;integer">20</action_nb>      </owl:namedindividual>                <!-- http://www.semanticweb.org/diabolico/ontologies/2016/3/untitled-ontology-77#electre -->        <owl:namedindividual rdf:about="&untitled-ontology-77;electre">          <rdf:type rdf:resource="&untitled-ontology-77;methods"/>          <action_nb rdf:datatype="&xsd;integer">50</action_nb>      </owl:namedindividual>  </rdf:rdf>        <!-- generated owl api (version 3.4.2) http://owlapi.sourceforge.net -->

prefix ex: <http://example.org/so#>  select ?methods  {     ?inst rdf:type ex:methods .     ?inst ex:action_nb ?value .  filter (?value < 40)  }

this code have been manipulating: gave me empty row when filtering 40 & 2 rows when using 60

the key understanding how approach understand how rdf triples defined. you've stated action_nb property values integers want compare. therefore create query using property:

prefix untitled-ontology-77: <http://www.semanticweb.org/diabolico/ontologies/2016/3/untitled-ontology-77#> select ?inst {     ?inst untitled-ontology-77:action_nb ?value .     filter (?value < 40) } 

...where filter clause allows values of action_nb less 40.

if property used in other classes, , want make sure members of methods found, need query instances of class:

prefix untitled-ontology-77: <http://www.semanticweb.org/diabolico/ontologies/2016/3/untitled-ontology-77#> select ?inst {    ?inst rdf:type untitled-ontology-77:methods .    ?inst untitled-ontology-77:action_nb ?value .    filter (?value < 40) } 

i doubt you'll need distinct in case, , aware finding distinct values performed after query, applied pairwise selected values. i.e. may not perform large result sets. therefore, use distinct when necessary.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -