2015-03-12 2 views
0

Я очень новичок в программировании на семантическом веб-сайте. У меня есть файл OWL, который я загрузил на сервер Virtuoso в URI http://myexample.com. Теперь, когда я открываю редактор запросов Виртуоз SPARQL (http://localhost:8890/sparql) и запустить следующий запрос, я не получаю никаких результатов:SPARQL запрос не отображает результаты

SELECT ?class FROM <myexample.com> WHERE{?class a owl:class} Order By ?class 

Может кто-то помочь мне решить эту проблему? Вот мой файл OWL:

<?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 owl2xml "http://www.w3.org/2006/12/owl2-xml#" > 
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" > 
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" > 
<!ENTITY Antibiotics "http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#" > 
<!ENTITY Antibiotics2 "http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#2" > 
<!ENTITY Antibiotics3 "http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#1" > 
<!ENTITY Antibiotics4 "http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#3" > 
<!ENTITY Traveler "http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Traveler&#39;" > 
]> 


<rdf:RDF xmlns="http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#" 
    xml:base="http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl" 
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
    xmlns:owl2xml="http://www.w3.org/2006/12/owl2-xml#" 
    xmlns:Antibiotics2="&Antibiotics;2" 
    xmlns:Traveler="&Antibiotics;Traveler&#39;" 
    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#" 
      xmlns:Antibiotics="http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#" 
    xmlns:Antibiotics3="&Antibiotics;1" 
    xmlns:Antibiotics4="&Antibiotics;3"> 
    <owl:Ontology rdf:about=""/> 



    <!-- 
      /////////////////////////////////////////////////////////////////////////////////////// 
    // 
    // Object Properties 
    // 
    /////////////////////////////////////////////////////////////////////////////////////// 
    --> 




    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#cures_disease --> 

    <owl:ObjectProperty rdf:about="#cures_disease"> 
     <rdfs:label>cures_disease</rdfs:label> 
     <rdfs:domain rdf:resource="#Antibiotics"/> 
     <rdfs:range rdf:resource="#Diseases"/> 
    </owl:ObjectProperty> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#has_SideEffects --> 

    <owl:ObjectProperty rdf:about="#has_SideEffects"> 
     <rdfs:label>has_SideEffects</rdfs:label> 
     <rdfs:domain rdf:resource="#Antibiotics"/> 
     <rdfs:range rdf:resource="#SideEffects"/> 
    </owl:ObjectProperty> 



    <!-- 
    /////////////////////////////////////////////////////////////////////////////////////// 
    // 
    // Classes 
    // 
    /////////////////////////////////////////////////////////////////////////////////////// 
    --> 




    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#1st_Generation --> 

    <owl:Class rdf:about="#1st_Generation"> 
     <rdfs:label>1st_Generation</rdfs:label> 
     <rdfs:subClassOf rdf:resource="#Antibiotics"/> 
    </owl:Class> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#2nd_Generation --> 

    <owl:Class rdf:about="#2nd_Generation"> 
     <rdfs:label>2nd_Generation</rdfs:label> 
     <rdfs:subClassOf rdf:resource="#Antibiotics"/> 
    </owl:Class> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#3rd_Generation --> 

    <owl:Class rdf:about="#3rd_Generation"> 
     <rdfs:label>3rd_Generation</rdfs:label> 
     <rdfs:subClassOf rdf:resource="#Antibiotics"/> 
    </owl:Class> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Aminopenicillins --> 

    <owl:Class rdf:about="#Aminopenicillins"> 
     <rdfs:label 
      >Aminopenicillins</rdfs:label> 
     <rdfs:subClassOf rdf:resource="#Antibiotics"/> 
    </owl:Class> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Antibiotics --> 

    <owl:Class rdf:about="#Antibiotics"> 
     <rdfs:label>Antibiotics</rdfs:label> 
     <rdfs:subClassOf rdf:resource="&owl;Thing"/> 
    </owl:Class> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Diseases --> 

    <owl:Class rdf:about="#Diseases"> 
     <rdfs:label>Diseases</rdfs:label> 
     <rdfs:subClassOf rdf:resource="&owl;Thing"/> 
    </owl:Class> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Lincosamide --> 

    <owl:Class rdf:about="#Lincosamide"> 
     <rdfs:label>Lincosamide</rdfs:label> 
     <rdfs:subClassOf rdf:resource="#Antibiotics"/> 
    </owl:Class> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#SideEffects --> 

    <owl:Class rdf:about="#SideEffects"> 
     <rdfs:label>SideEffects</rdfs:label> 
     <rdfs:subClassOf rdf:resource="&owl;Thing"/> 
    </owl:Class> 



    <!-- http://www.w3.org/2002/07/owl#Thing --> 

    <owl:Class rdf:about="&owl;Thing"/> 



    <!-- 
    /////////////////////////////////////////////////////////////////////////////////////// 
    // 
    // Individuals 
    // 
    /////////////////////////////////////////////////////////////////////////////////////// 
    --> 




    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Acne --> 

    <Diseases rdf:about="#Acne"> 
     <rdf:type rdf:resource="&owl;Thing"/> 
     <rdfs:label>Acne</rdfs:label> 
    </Diseases> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Allergic_Reactions --> 

    <owl:Thing rdf:about="#Allergic_Reactions"> 
     <rdf:type rdf:resource="#SideEffects"/> 
     <rdfs:label 
      >Allergic_Reactions</rdfs:label> 
    </owl:Thing> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Amoxicillin --> 

    <owl:Thing rdf:about="#Amoxicillin"> 
     <rdf:type rdf:resource="#Aminopenicillins"/> 
     <rdfs:label>Amoxicillin</rdfs:label> 
     <has_SideEffects rdf:resource="#Diarrhea"/> 
     <cures_disease rdf:resource="#Wide_Range_Of_Infections"/> 
    </owl:Thing> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Cefalexin --> 

    <owl:Thing rdf:about="#Cefalexin"> 
     <rdf:type rdf:resource="#1st_Generation"/> 
     <rdfs:label>Cephalexin</rdfs:label> 
     <cures_disease rdf:resource="#Gram_positive_infections"/> 
     <has_SideEffects rdf:resource="#Nausea"/> 
    </owl:Thing> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Cefazolin --> 

    <Antibiotics3:st_Generation rdf:about="#Cefazolin"> 
     <rdf:type rdf:resource="&owl;Thing"/> 
     <rdfs:label>Cefazolin</rdfs:label> 
     <has_SideEffects rdf:resource="#Allergic_Reactions"/> 
     <cures_disease rdf:resource="#Gram_positive_infections"/> 
    </Antibiotics3:st_Generation> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Cefepime --> 

    <owl:Thing rdf:about="#Cefepime"> 
     <rdf:type rdf:resource="#3rd_Generation"/> 
     <rdfs:label>Cefepime</rdfs:label> 
     <has_SideEffects rdf:resource="#Nausea"/> 
     <cures_disease rdf:resource="#Pseudomonal_Infections"/> 
    </owl:Thing> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Cefoxitin --> 

    <Antibiotics2:nd_Generation rdf:about="#Cefoxitin"> 
     <rdf:type rdf:resource="&owl;Thing"/> 
     <rdfs:label>Cefoxitin</rdfs:label> 
     <has_SideEffects rdf:resource="#Allergic_Reactions"/> 
     <cures_disease rdf:resource="#Gram_negative_cover"/> 
    </Antibiotics2:nd_Generation> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Clindamycin --> 

    <owl:Thing rdf:about="#Clindamycin"> 
     <rdf:type rdf:resource="#Lincosamide"/> 
     <rdfs:label>Clindamycin</rdfs:label> 
     <cures_disease rdf:resource="#Acne"/> 
     <has_SideEffects rdf:resource="#Diarrhea"/> 
    </owl:Thing> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Diarrhea --> 

    <owl:Thing rdf:about="#Diarrhea"> 
     <rdf:type rdf:resource="#SideEffects"/> 
     <rdfs:label>Diarrhea</rdfs:label> 
    </owl:Thing> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Gastrointestinal_Upset --> 

    <SideEffects rdf:about="#Gastrointestinal_Upset"> 
     <rdf:type rdf:resource="&owl;Thing"/> 
     <rdfs:label 
      >Gastrointestinal_Upset</rdfs:label> 
    </SideEffects> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Gram_negative_cover --> 

    <owl:Thing rdf:about="#Gram_negative_cover"> 
     <rdf:type rdf:resource="#Diseases"/> 
     <rdfs:label 
      >Gram_negative_cover</rdfs:label> 
    </owl:Thing> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Gram_positive_infections --> 

    <owl:Thing rdf:about="#Gram_positive_infections"> 
     <rdf:type rdf:resource="#Diseases"/> 
     <rdfs:label 
      >Gram_positive_infections</rdfs:label> 
     <cures_disease rdf:resource="#Gram_positive_infections"/> 
     <has_SideEffects rdf:resource="#Nausea"/> 
    </owl:Thing> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Nausea --> 

    <owl:Thing rdf:about="#Nausea"> 
     <rdf:type rdf:resource="#SideEffects"/> 
     <rdfs:label>Nausea</rdfs:label> 
    </owl:Thing> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Pseudomonal_Infections --> 

    <Diseases rdf:about="#Pseudomonal_Infections"> 
     <rdf:type rdf:resource="&owl;Thing"/> 
     <rdfs:label 
      >Pseudomonal_Infections</rdfs:label> 
    </Diseases> 



    <!-- http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Wide_Range_Of_Infections --> 

    <owl:Thing rdf:about="#Wide_Range_Of_Infections"> 
     <rdf:type rdf:resource="#Diseases"/> 
     <rdfs:label 
      >Wide_Range_Of_Infections</rdfs:label> 
    </owl:Thing> 



    <!-- 
    /////////////////////////////////////////////////////////////////////////////////////// 
    // 
    // General axioms 
    // 
    /////////////////////////////////////////////////////////////////////////////////////// 
    --> 

    <rdf:Description> 
     <rdf:type rdf:resource="&owl;AllDisjointClasses"/> 
     <owl:members rdf:parseType="Collection"> 
      <rdf:Description rdf:about="#Antibiotics"/> 
      <rdf:Description rdf:about="#Diseases"/> 
      <rdf:Description rdf:about="#SideEffects"/> 
     </owl:members> 
    </rdf:Description> 
    <rdf:Description> 
     <rdf:type rdf:resource="&owl;AllDisjointClasses"/> 
     <owl:members rdf:parseType="Collection"> 
      <rdf:Description rdf:about="#1st_Generation"/> 
      <rdf:Description rdf:about="#2nd_Generation"/> 
      <rdf:Description rdf:about="#3rd_Generation"/> 
      <rdf:Description rdf:about="#Aminopenicillins"/> 
      <rdf:Description rdf:about="#Lincosamide"/> 
     </owl:members> 
    </rdf:Description> 
</rdf:RDF> 



<!-- Generated by the OWL API (version 2.2.1.1138) http://owlapi.sourceforge.net --> 

ответ

2

IRI чувствительны к регистру. Обратите внимание на то, что в вашей онтологии совы: Класс использует Majuscule C:

<owl:Class rdf:about="#1st_Generation"> 
    <rdfs:label>1st_Generation</rdfs:label> 
    <rdfs:subClassOf rdf:resource="#Antibiotics"/> 
</owl:Class> 

, что должно быть в случае запроса SPARQL, а также. И, если вы не в другом месте, вам нужно определить префикс. Если вы сохранили данные на графике с именем http://myexample.com, то вам может потребоваться выбрать именно это с помощью от < http://myexample.com>. Не роняйте префикс http: //. Я скачал ваши данные, и этот запрос дает следующие результаты:

prefix owl: <http://www.w3.org/2002/07/owl#> 

select ?class where { 
    ?class a owl:Class 
} 
--------------------------------------------------------------------------------------------- 
| class                      | 
============================================================================================= 
| owl:Thing                     | 
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#SideEffects>  | 
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Lincosamide>  | 
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Diseases>   | 
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Antibiotics>  | 
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#Aminopenicillins> | 
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#3rd_Generation> | 
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#2nd_Generation> | 
| <http://www.semanticweb.org/uthejsree/ontologies/2014/8/Antibiotics.owl#1st_Generation> | 
--------------------------------------------------------------------------------------------- 
+0

Он по-прежнему не дает мне никаких результатов. – user2201650

+1

Я сохранил ваши данные и запросил этот запрос SPARQL и получил результаты, которые я показал. 'FROM ' в вашем запросе является подозрительным. Если у вас есть график с именем 'http: // myexample.com', вы должны использовать' FROM '. Не отбрасывайте префикс http: // '. –

+0

Большое вам спасибо. Он работает сейчас. Есть ли причина, по которой я не должен отказываться от префикса 'http: //'? Я новичок в программировании Semantic Web. И я хотел бы знать причину этого. – user2201650

Смежные вопросы