Запрос SPARQL не отображает результаты

Я очень новичок в программировании Semantic Web. У меня есть файл OWL, который я загрузил на сервер Virtuoso по адресу URI http://myexample.com. Теперь, когда я открываю редактор запросов Virtuoso SPARQL (http://localhost:8890/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 -->

person user2201650    schedule 12.03.2015    source источник


Ответы (1)


IRI чувствительны к регистру. Обратите внимание, что в вашей онтологии owl:Class используется маюскула 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>   |
---------------------------------------------------------------------------------------------
person Joshua Taylor    schedule 12.03.2015
comment
Это все еще не дает мне никаких результатов. - person user2201650; 12.03.2015
comment
Я сохранил ваши данные и выполнил для них этот запрос SPARQL и получил результаты, которые я показал. FROM <myexample.com> в вашем запросе подозрительно. Если у вас есть график с именем http://myexample.com, вы должны использовать FROM <http://myexample.com>. Не опускайте префикс http://. - person Joshua Taylor; 12.03.2015
comment
Большое спасибо. Теперь это работает. Есть ли причина, по которой я не должен отбрасывать префикс http://? Я новичок в программировании Semantic Web. И я хотел бы знать причину этого. - person user2201650; 12.03.2015
comment
@user2201650 user2201650 Есть ли причина, по которой я не должен отбрасывать префикс http://? Да, очень важный. :) http://myexample.com — это IRI, поэтому его можно использовать для обозначения графа, к которому вы можете обратиться. myexample.com не является (или, может быть, относительным). IRI иногда начинаются с http://, но не всегда. Например, urn:ex:foo — это IRI. Как и mailto:[email protected]. Это правда, что грамматика SPARQL позволяет вам писать FROM <myexample.com> (IRIREF определяется как '<' ([^<>"{}|^`\]-[#x00-#x20])* '>'), но даже в этом случае http://myexample.com и myexample.com различны. - person Joshua Taylor; 12.03.2015
comment
@JoshuaTaylor Большое спасибо, что нашли время и объяснили мне это :) - person user2201650; 13.03.2015
comment
@JoshuaTaylor У меня есть еще один вопрос. Можно ли получить доступ к серверу онтологий из запроса SPARQL? У меня в основном тот же вопрос, что и здесь: stackoverflow.com/questions/28842339/ - person user2201650; 13.03.2015
comment
Посмотрите на ключевое слово service. Например, select * where { ... service <http://...> { ... } ... }. Обычно его называют федеративным запросом. Спецификация (w3.org/TR/sparql11-query) вполне удобочитаема; это хорошая идея, чтобы просмотреть его, чтобы получить представление о том, что на языке. Вы можете вернуться к нему позже, когда вам понадобятся конкретные детали. (В целом это хороший совет; рекомендуется просматривать руководство или документацию, когда вы начинаете использовать новый инструмент, чтобы иметь приблизительное представление о том, что доступно. Затем вы можете вернуться к подробностям, когда вам действительно нужна эта функция.) - person Joshua Taylor; 13.03.2015