Как применить фильтр в SPARQL Query со свойствами данных - PullRequest
0 голосов
/ 04 февраля 2020

Я новичок в онтологии и SPARQL Query. Я строю онтологию, используя python OWL API, и сейчас пытаюсь написать запрос SPARQL, чтобы получить всех людей, имеющих указанное значение свойства данных c.

В онтологии ученика - у меня есть класс ученика с несколько свойств данных и свойств объекта. Каждый учащийся будет иметь свои собственные значения свойств. Я перечислил всех людей, у которых значение возраста больше 20 ", но добавление того же с условием перехода это не работает. Пожалуйста, смотрите запрос ниже

 PREFIX ants:      <http://www.ants.com/lontology#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?name ?Branch?age?sid
WHERE { ?name  ants:Branch  ?Branch.?name  ants:age  ?age.?name  ants:sid  ?sid.FILTER( (?age > "20"^^xsd:int)&& (?Branch = "UG"^^xsd:string))}

Но пустой результат вернулся. Пожалуйста, помогите

   <rdf:RDF
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:j.0="http://www.ants.com/lontology#"
        xml:base="http://www.ants.com/lontology#"
        xmlns:owl="http://www.w3.org/2002/07/owl#"
        xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
      <owl:Ontology rdf:about="http://www.ants.com/lontology"/>
      <owl:Class rdf:about="http://www.ants.com/lontology#LOM_Characterstics"/>
      <owl:Class rdf:about="http://www.ants.com/lontology#LearningMaterial"/>
      <owl:Class rdf:about="http://www.ants.com/lontology#LearningStyle"/>
      <owl:Class rdf:about="http://www.ants.com/lontology#Learner"/>
      <owl:Class rdf:about="http://www.ants.com/lontology#Learners_Log"/>
      <owl:ObjectProperty rdf:about="http://www.ants.com/lontology#hasLearningStyle">
        <rdfs:range rdf:resource="http://www.ants.com/lontology#LearningStyle"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#Learner"/>
      </owl:ObjectProperty>
      <owl:ObjectProperty rdf:about="http://www.ants.com/lontology#hasChracter">
        <rdfs:range rdf:resource="http://www.ants.com/lontology#LOM_Characterstics"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#LearningMaterial"/>
      </owl:ObjectProperty>
      <owl:ObjectProperty rdf:about="http://www.ants.com/lontology#visited_material">
        <rdfs:range rdf:resource="http://www.ants.com/lontology#LearningMaterial"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#Learners_Log"/>
      </owl:ObjectProperty>
      <owl:ObjectProperty rdf:about="http://www.ants.com/lontology#hasSection">
        <rdfs:range rdf:resource="http://www.ants.com/lontology#Learners_Log"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#Learner"/>
      </owl:ObjectProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#gender">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#Learner"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#LearningResoursesType">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#LOM_Characterstics"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#Qualification">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#Learner"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#material_visited_time">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#Learners_Log"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#Visual_Verbal">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#LearningStyle"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#Topic">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#LearningMaterial"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#material_visted_frquency">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#Learners_Log"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#age">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#Learner"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#Difficulty">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#LOM_Characterstics"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#Background_Knowledge">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#Learner"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#Branch">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#Learner"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#Tittle">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#LOM_Characterstics"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#Format">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#LOM_Characterstics"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#Structure">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#LOM_Characterstics"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#Sensitive_Intutive">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#LearningStyle"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#id">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#LOM_Characterstics"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#Intractive_Level">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#LOM_Characterstics"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#Global_Sequential">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#LearningStyle"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#Active_Reflective">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#LearningStyle"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#Intractive_Type">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#LOM_Characterstics"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#name">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#Learner"/>
      </owl:DatatypeProperty>
      <owl:DatatypeProperty rdf:about="http://www.ants.com/lontology#sid">
        <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <rdfs:domain rdf:resource="http://www.ants.com/lontology#Learner"/>
      </owl:DatatypeProperty>
      <j.0:Learners_Log rdf:ID="Learner_Log">
        <j.0:material_visited_time>12</j.0:material_visited_time>
        <j.0:material_visted_frquency rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
        >4</j.0:material_visted_frquency>
      </j.0:Learners_Log>
      <j.0:Learner rdf:ID="Saritha_P">
        <j.0:Branch>UG</j.0:Branch>
        <j.0:Qualification>F</j.0:Qualification>
        <j.0:gender>20</j.0:gender>
        <j.0:age rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
        >20</j.0:age>
        <j.0:name>Saritha_P</j.0:name>
        <j.0:sid>16</j.0:sid>
      </j.0:Learner>
      <j.0:Learner rdf:ID="Titus_George">
        <j.0:Branch>UG</j.0:Branch>
        <j.0:Qualification>M</j.0:Qualification>
        <j.0:gender>23</j.0:gender>
        <j.0:age rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
        >23</j.0:age>
        <j.0:name>Titus_George</j.0:name>
        <j.0:sid>11</j.0:sid>
      </j.0:Learner>
      <j.0:Learner rdf:ID="Roosy_Jose">
        <j.0:Branch>UG</j.0:Branch>
        <j.0:Qualification>F</j.0:Qualification>
        <j.0:gender>23</j.0:gender>
        <j.0:age rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
        >23</j.0:age>
        <j.0:name>Roosy_Jose</j.0:name>
        <j.0:sid>10</j.0:sid>
      </j.0:Learner><j.0:Learner rdf:ID="Alance_T">
    <j.0:Branch>UG</j.0:Branch>
    <j.0:Qualification>M</j.0:Qualification>
    <j.0:gender>25</j.0:gender>
    <j.0:age rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
    >25</j.0:age>
    <j.0:name>Alance_T</j.0:name>
    <j.0:sid>13</j.0:sid>
  </j.0:Learner>
  <j.0:Learner rdf:ID="Savitha_K_K">
    <j.0:Branch>HS</j.0:Branch>
    <j.0:Qualification>F</j.0:Qualification>
    <j.0:gender>19</j.0:gender>
    <j.0:age rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
    >19</j.0:age>
    <j.0:name>Savitha_K_K</j.0:name>
    <j.0:sid>7</j.0:sid>
  </j.0:Learner>
  <j.0:Learner rdf:ID="Chanjal_R">
    <j.0:Branch>HS</j.0:Branch>
    <j.0:Qualification>F</j.0:Qualification>
    <j.0:gender>20</j.0:gender>
    <j.0:age rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
    >20</j.0:age>
    <j.0:name>Chanjal_R</j.0:name>
    <j.0:sid>20</j.0:sid>
  </j.0:Learner>
  <j.0:Learner rdf:ID="Prasanth_S">
    <j.0:Branch>UG</j.0:Branch>
    <j.0:Qualification>M</j.0:Qualification>
    <j.0:gender>22</j.0:gender>
    <j.0:age rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
    >22</j.0:age>
    <j.0:name>Prasanth_S</j.0:name>
    <j.0:sid>19</j.0:sid>
  </j.0:Learner>
  <j.0:Learner rdf:ID="Vijitha_Vijayan">
    <j.0:Branch>UG</j.0:Branch>
    <j.0:Qualification>F</j.0:Qualification>
    <j.0:gender>21</j.0:gender>
    <j.0:age rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
    >21</j.0:age>
    <j.0:name>Vijitha_Vijayan</j.0:name>
    <j.0:sid>17</j.0:sid>
  </j.0:Learner>
  <j.0:Learner rdf:ID="Nisha_S_Raj">
    <j.0:Branch>UG</j.0:Branch>
    <j.0:Qualification>F</j.0:Qualification>
    <j.0:gender>24</j.0:gender>
    <j.0:age rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
    >24</j.0:age>
    <j.0:name>Nisha_S_Raj</j.0:name>
    <j.0:sid>3</j.0:sid>
  </j.0:Learner>
  <j.0:Learner rdf:ID="Varun_Krishna">
    <j.0:Branch>UG</j.0:Branch>
    <j.0:Qualification>M</j.0:Qualification>
    <j.0:gender>21</j.0:gender>
    <j.0:age rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
    >21</j.0:age>
    <j.0:name>Varun_Krishna</j.0:name>
    <j.0:sid>9</j.0:sid>
  </j.0:Learner>
  <j.0:Learner rdf:ID="Vinu_V">
    <j.0:Branch>PG</j.0:Branch>
    <j.0:Qualification>M</j.0:Qualification>
    <j.0:gender>25</j.0:gender>
    <j.0:age rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
    >25</j.0:age>
    <j.0:name>Vinu_V</j.0:name>
    <j.0:sid>6</j.0:sid>
  </j.0:Learner>
</rdf:RDF>
...