owl - How to extract related nodes with object property using Protege SPARQL plugin 1.0? -


i made simple ontology protege 4.3. has 3 object properties (padre_de, hijo_de, hermano_de) , 1 annotation property named ‘tiene_sinonimo’. ontology:

        <?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 ontopizza "http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#" >         ]>          <rdf:rdf xmlns="http://www.w3.org/2002/07/owl#"              xml:base="http://www.w3.org/2002/07/owl"              xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"              xmlns:ontopizza="http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#"              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#">             <ontology rdf:about="http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza"/>              <!--              ///////////////////////////////////////////////////////////////////////////////////////             //             // annotation properties             //             ///////////////////////////////////////////////////////////////////////////////////////              -->                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#tiene_sinonimo -->             <annotationproperty rdf:about="&ontopizza;tiene_sinonimo"/>              <!--              ///////////////////////////////////////////////////////////////////////////////////////             //             // object properties             //             ///////////////////////////////////////////////////////////////////////////////////////              -->                 <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#hermano_de -->              <objectproperty rdf:about="&ontopizza;hermano_de">                 <rdf:type rdf:resource="&owl;transitiveproperty"/>             </objectproperty>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#hijo_de -->              <objectproperty rdf:about="&ontopizza;hijo_de">                 <rdf:type rdf:resource="&owl;transitiveproperty"/>                 <rdfs:subpropertyof rdf:resource="&owl;topobjectproperty"/>             </objectproperty>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#padre_de -->              <objectproperty rdf:about="&ontopizza;padre_de">                 <rdf:type rdf:resource="&owl;transitiveproperty"/>                 <inverseof rdf:resource="&ontopizza;hijo_de"/>             </objectproperty>                <!--              ///////////////////////////////////////////////////////////////////////////////////////             //             // classes             //             ///////////////////////////////////////////////////////////////////////////////////////              -->              <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#azul -->             <class rdf:about="&ontopizza;azul">                 <rdfs:subclassof rdf:resource="&ontopizza;pizza_francesa"/>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;pizza_francesa"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hermano_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;roja"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hermano_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;verde"/>                     </restriction>                 </rdfs:subclassof>                 <ontopizza:tiene_sinonimo xml:lang="es">sinonimo_de_azul</ontopizza:tiene_sinonimo>             </class>              <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#con_mayonesa -->             <class rdf:about="&ontopizza;con_mayonesa">                 <rdfs:subclassof rdf:resource="&ontopizza;pizza_americana"/>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hermano_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;con_queso"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hermano_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;con_pimientos"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;pizza_americana"/>                     </restriction>                 </rdfs:subclassof>                 <ontopizza:tiene_sinonimo xml:lang="es">sinonimo_de_con_mayonesa</ontopizza:tiene_sinonimo>             </class>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#con_pimientos -->             <class rdf:about="&ontopizza;con_pimientos">                 <rdfs:subclassof rdf:resource="&ontopizza;pizza_americana"/>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;pizza_americana"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hermano_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;con_mayonesa"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hermano_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;con_queso"/>                     </restriction>                 </rdfs:subclassof>                 <ontopizza:tiene_sinonimo xml:lang="es">sinonimo_de_con_pimientos</ontopizza:tiene_sinonimo>             </class>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#con_queso -->             <class rdf:about="&ontopizza;con_queso">                 <rdfs:subclassof rdf:resource="&ontopizza;pizza_americana"/>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hermano_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;con_pimientos"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;pizza_americana"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hermano_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;con_mayonesa"/>                     </restriction>                 </rdfs:subclassof>                 <ontopizza:tiene_sinonimo xml:lang="es">sinonimo_de_con_queso</ontopizza:tiene_sinonimo>             </class>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#pizza -->             <class rdf:about="&ontopizza;pizza">                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;padre_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;pizza_francesa"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;padre_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;pizza_americana"/>                     </restriction>                 </rdfs:subclassof>                 <ontopizza:tiene_sinonimo xml:lang="es">sinonimo_de_pizza</ontopizza:tiene_sinonimo>             </class>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#pizza_americana -->             <class rdf:about="&ontopizza;pizza_americana">                 <rdfs:subclassof rdf:resource="&ontopizza;pizza"/>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;padre_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;con_mayonesa"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;pizza"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;padre_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;con_pimientos"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;padre_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;con_queso"/>                     </restriction>                 </rdfs:subclassof>                 <disjointwith rdf:resource="&ontopizza;pizza_francesa"/>                 <ontopizza:tiene_sinonimo xml:lang="es">sinonimo_de_pizza_americana</ontopizza:tiene_sinonimo>             </class>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#pizza_francesa -->             <class rdf:about="&ontopizza;pizza_francesa">                 <rdfs:subclassof rdf:resource="&ontopizza;pizza"/>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;pizza"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;padre_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;verde"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;padre_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;roja"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hermano_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;pizza_americana"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;padre_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;azul"/>                     </restriction>                 </rdfs:subclassof>                 <ontopizza:tiene_sinonimo xml:lang="es">sinonimo_de_pizza_francesa</ontopizza:tiene_sinonimo>             </class>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#roja -->             <class rdf:about="&ontopizza;roja">                 <rdfs:subclassof rdf:resource="&ontopizza;pizza_francesa"/>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hermano_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;azul"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hermano_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;verde"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;pizza_francesa"/>                     </restriction>                 </rdfs:subclassof>                 <ontopizza:tiene_sinonimo xml:lang="es">sinonimo_de_roja</ontopizza:tiene_sinonimo>             </class>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#verde -->             <class rdf:about="&ontopizza;verde">                 <rdfs:subclassof rdf:resource="&ontopizza;pizza_francesa"/>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;pizza_francesa"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hermano_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;azul"/>                     </restriction>                 </rdfs:subclassof>                 <rdfs:subclassof>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hermano_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;roja"/>                     </restriction>                 </rdfs:subclassof>                 <ontopizza:tiene_sinonimo xml:lang="es">sinonimo_de_verde</ontopizza:tiene_sinonimo>             </class>                <!--              ///////////////////////////////////////////////////////////////////////////////////////             //             // individuals             //             ///////////////////////////////////////////////////////////////////////////////////////              -->              <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#azul_1 -->              <namedindividual rdf:about="&ontopizza;azul_1">                 <rdf:type rdf:resource="&ontopizza;azul"/>                 <rdf:type>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;azul"/>                     </restriction>                 </rdf:type>             </namedindividual>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#azul_2 -->              <namedindividual rdf:about="&ontopizza;azul_2">                 <rdf:type rdf:resource="&ontopizza;azul"/>                 <rdf:type>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;azul"/>                     </restriction>                 </rdf:type>             </namedindividual>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#con_mayonesa_1 -->              <namedindividual rdf:about="&ontopizza;con_mayonesa_1">                 <rdf:type rdf:resource="&ontopizza;con_mayonesa"/>                 <rdf:type>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;con_mayonesa"/>                     </restriction>                 </rdf:type>                 <ontopizza:tiene_sinonimo xml:lang="es">sinonimo_de_con_mayonesa_1</ontopizza:tiene_sinonimo>             </namedindividual>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#con_mayonesa_2 -->              <namedindividual rdf:about="&ontopizza;con_mayonesa_2">                 <rdf:type rdf:resource="&ontopizza;con_mayonesa"/>                 <rdf:type>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;con_mayonesa"/>                     </restriction>                 </rdf:type>                 <ontopizza:tiene_sinonimo xml:lang="es">sinonimo_de_con_mayonesa_2</ontopizza:tiene_sinonimo>             </namedindividual>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#con_pimientos_1 -->              <namedindividual rdf:about="&ontopizza;con_pimientos_1">                 <rdf:type rdf:resource="&ontopizza;con_pimientos"/>                 <rdf:type>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;con_pimientos"/>                     </restriction>                 </rdf:type>             </namedindividual>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#con_pimientos_2 -->              <namedindividual rdf:about="&ontopizza;con_pimientos_2">                 <rdf:type rdf:resource="&ontopizza;con_pimientos"/>                 <rdf:type>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;con_pimientos"/>                     </restriction>                 </rdf:type>             </namedindividual>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#con_queso_1 -->              <namedindividual rdf:about="&ontopizza;con_queso_1">                 <rdf:type rdf:resource="&ontopizza;con_queso"/>                 <rdf:type>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;con_queso"/>                     </restriction>                 </rdf:type>             </namedindividual>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#con_queso_2 -->              <namedindividual rdf:about="&ontopizza;con_queso_2">                 <rdf:type rdf:resource="&ontopizza;con_queso"/>             </namedindividual>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#roja_1 -->              <namedindividual rdf:about="&ontopizza;roja_1">                 <rdf:type rdf:resource="&ontopizza;roja"/>                 <rdf:type>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;roja"/>                     </restriction>                 </rdf:type>             </namedindividual>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#roja_2 -->              <namedindividual rdf:about="&ontopizza;roja_2">                 <rdf:type rdf:resource="&ontopizza;roja"/>                 <rdf:type>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;roja"/>                     </restriction>                 </rdf:type>             </namedindividual>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#verde_1 -->              <namedindividual rdf:about="&ontopizza;verde_1">                 <rdf:type rdf:resource="&ontopizza;verde"/>                 <rdf:type>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;verde"/>                     </restriction>                 </rdf:type>             </namedindividual>                <!-- http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#verde_2 -->              <namedindividual rdf:about="&ontopizza;verde_2">                 <rdf:type rdf:resource="&ontopizza;verde"/>                 <rdf:type>                     <restriction>                         <onproperty rdf:resource="&ontopizza;hijo_de"/>                         <somevaluesfrom rdf:resource="&ontopizza;verde"/>                     </restriction>                 </rdf:type>             </namedindividual>         </rdf:rdf>            <!-- generated owl api (version 3.4.2) http://owlapi.sourceforge.net --> 

i’m using protege sparql plugin extract nodes related annotation property query:

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix owl: <http://www.w3.org/2002/07/owl#> prefix xsd: <http://www.w3.org/2001/xmlschema#> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix pi: <http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#> select   ?sinonimo  {      pi:pizza_americana pi:tiene_sinonimo ?sinonimo                 } 

obtaining:

------------------------------------ | sinonimo                         | ==================================== | "sinonimo_de_pizza_americana"@es | ------------------------------------ 

but don’t know how extract nodes related object property padre_de. reading in: how query classes object property in sparql , wrote following query:

select ?hijo {pi:pizza pi:padre_de ?hijo   } 

if run query result empty, need result like:

----------------------- | hijo                |  ======================= | pizza_americana     | | pizza_francesa      | -----------------------  

or ‘hijo_de’ of pizza_americana:

----------------------- | hijo                |  ======================= | con_mayonesa        | | con_pimientos       | | con_queso           | ----------------------- 

to find of restrictions given property involved in, can query rdf structures make owl restrictions. example:

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix owl: <http://www.w3.org/2002/07/owl#> prefix xsd: <http://www.w3.org/2001/xmlschema#> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix pi: <http://www.semanticweb.org/silvana/ontologies/2015/7/ontopizza#>  select distinct ?hijo {    ?s owl:restriction .    ?s owl:onproperty pi:padre_de .    ?s owl:somevaluesfrom | owl:allvaluesfrom ?hijo . } 

and same can done pi:hijo_de.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -