All Downloads are FREE. Search and download functionalities are using the official Maven repository.

webapp.data.tutorial.query.ttl Maven / Gradle / Ivy

Go to download

Corese is a Semantic Web Factory (triple store and SPARQL endpoint) implementing RDF, RDFS, SPARQL 1.1 Query and Update.

The newest version!
#
# Query definitions for a SPARQL tutorial based on a transformation
#
# Olivier Corby - Wimmics Inria I3S - 2015
#
#@base 
@base 
st:tutorial2 a st:Server ;
  st:data     [ st:uri   ; st:name st:data ] ;
  st:schema   [ st:uri  ; st:name st:schema ] ;
  st:context  [ st:uri   ; st:name st:context ] .


[] a st:Query ;
st:name st:all ;
rdfs:label "Triple Pattern" ;
rdfs:comment "Retourne tout le graphe"@fr ;
rdfs:comment "Return the whole graph"@en ;
st:query 
"""
select * where { 
  ?x ?p ?y 
}""" 
.


[] a st:Query ;
st:name st:type ;
rdfs:label "Type" ;
rdfs:comment "Retourne les instances du type personne."@fr ;
rdfs:comment "Return instances of type person."@en ;
st:query 
"""
prefix h: 
select * where { 
  ?x a h:Person 
}""" 
.


[] a st:Query ;
st:name st:bnode ;
rdfs:label "Blank Node" ;
rdfs:comment "Les blank nodes sont des variables anonymes qui ne sont pas retournées dans le résultat."@fr ;
rdfs:comment "Blank nodes are anonymous variables that are not returned in the result."@en ;
st:reference  ;
st:query 
"""
prefix h: 
select * where { 
  ?x a h:Person ;
  h:hasFriend []
}""" 
.


[] a st:Query ;
st:name st:list ;
rdfs:label "List" ;
rdfs:comment """Enumère les éléments d'une liste."""@fr ;
rdfs:comment """Enumerate list elements."""@en ;
#st:reference  ;
st:query 
"""prefix h: 
select * where {
  ?x h:list (?a ?b ?c)
}
""" 
.

[] a st:Query ;
st:name st:bgp ;
rdfs:label "BGP" ;
rdfs:comment "Retourne les instances de personne ayant un nom."@fr ;
rdfs:comment "Return instances of person having a name."@en ;
st:reference  ;
st:query 
"""
prefix h: 
select * where { 
  ?x a h:Person ;
    h:name ?n
}""" 
.

[] a st:Query ;
st:name st:count ;
rdfs:label "Count" ;
rdfs:comment """Compte le nombre de solution avec un opérateur d'aggrégation."""@fr ;
rdfs:comment """Count the number of results using an aggregate operator."""@en ;
st:reference  ;
st:query 
"""
prefix h: 
select (count(*) as ?c) where { 
  ?x ?p ?y 
}""" 
.

[] a st:Query ;
st:name st:group ;
rdfs:label "Group By" ;
rdfs:comment """Compte le nombre de solutions. Retourne un  résultat pour chaque valeur de ?x."""@fr ;
rdfs:comment """Count the number of solutions. Return one result for each value of ?x."""@en ;
st:reference  ;
st:query 
"""
prefix h: 
select ?x (count(*) as ?c) where { 
   ?x h:hasChild ?y 
} 
group by ?x
""" 
.


[] a st:Query ;
st:name st:gconcat ;
rdfs:label "Group concat" ;
rdfs:comment """Concatène la liste des amis."""@fr ;
rdfs:comment """Concatenate the list of friends."""@en ;
st:reference  ;
st:query 
"""
prefix h: 
select ?x (group_concat(?n) as ?l) where { 
   ?x h:hasChild ?y 
   ?y h:name ?n
} 
group by ?x
""" 
.


[] a st:Query ;
st:name st:having ;
rdfs:label "Having" ;
rdfs:comment """Compte le nombre de solution. Retourne un  résultat pour chaque valeur de ?x dont le compteur est > 1."""@fr ;
rdfs:comment """Count the number of solutions, return  results where value of counter > 1."""@en ;
st:reference  ;
st:query 
"""
prefix h: 
select ?x (count(*) as ?c) where { 
   ?x h:hasChild ?y 
} 
group by ?x
having (count(*) > 1)
""" 
.



[] a st:Query ;
st:name st:order ;
rdfs:label "Order" ;
rdfs:comment "Retourne les ressources instance de type personne, triées par ordre alphabétique."@fr ;
rdfs:comment "Return instances of person in alphabetical order."@en ;
st:reference  ;
st:query 
"""
prefix h: 
select * where { 
  ?x a h:Person ;
  h:name ?n
}
order by ?n""" 
.


[] a st:Query ;
st:name st:distinct ;
rdfs:label "Distinct" ;
rdfs:comment "Retourne des résultats distincts."@fr ;
rdfs:comment "Return distinct results."@en ;
st:reference  ;
st:query 
"""
prefix h: 
select distinct ?x ?y where { 
  ?x ?p ?v .
  ?y ?p ?v
  values ?p {  h:shoesize h:shirtsize }
}
order by ?x ?y""" 
.



[] a st:Query ;
st:name st:filter ;
rdfs:label "Filter" ;
rdfs:comment """Retourne les ressources  ayant un nom  qui contient la lettre 'l'."""@fr ;
rdfs:comment """Return resources with name containing letter 'l'."""@en ;
st:reference  ;
st:query 
"""
prefix h: 
select * where { 
  ?x h:name ?n
    filter(strcontains(?n, "l"))
}
""" 
.


[] a st:Query ;
st:name st:lang ;
rdfs:label "Language" ;
rdfs:comment """Retourne les ressources  ayant un nom  taggé en français."""@fr ;
rdfs:comment """Return resources with name tagged in french."""@en ;
st:reference  ;
st:query 
"""
prefix h: 
select * where { 
  ?x h:name ?n
  filter(lang(?n) = "fr")
}
""" 
.

[] a st:Query ;
st:name st:datatype ;
rdfs:label "Datatype" ;
rdfs:comment """Retourne les ressources  ayant une valeur datatype."""@fr ;
rdfs:comment """Return resources with a datatype value."""@en ;
st:reference  ;
st:query 
"""
prefix h: 
select * (datatype(?v) as ?d) where { 
  ?x ?p ?v
  filter (strstarts(?p, h:))
  filter (isLiteral(?v))
}
""" 
.


[] a st:Query ;
st:name st:date ;
rdfs:label "Date" ;
rdfs:comment """Retourne la date."""@fr ;
rdfs:comment """Return the date."""@en ;
st:reference  ;
st:query 
"""
prefix h: 
select (now() as ?n)
  (year(?n) 	as ?y)
  (month(?n) 	as ?m)
  (day(?n) 	as ?d)
  (hours(?n) 	as ?hr)
  (minutes(?n) 	as ?mn)
  (seconds(?n) 	as ?sc)
where { 
 
}
""" 
.


[] a st:Query ;
st:name st:regex ;
rdfs:label "Regex" ;
rdfs:comment """Retourne les URI qui matchent une expression régulière."""@fr ;
rdfs:comment """Return URI that match a regular expression."""@en ;
st:reference  ;
st:query 
"""
prefix h: 
select *
where { 
  ?x a ?t 
  filter regex(str(?x), "inria.fr")
}
""" 
.




[] a st:Query ;
st:name st:if ;
rdfs:label "If Then Else" ;
rdfs:comment """Si alors sinon."""@fr ;
rdfs:comment """If then else."""@en ;
st:reference  ;
st:query 
"""
prefix h: 
select * (if (?a >= 18, "majeur", "mineur") as ?s) where { 
  ?x h:age ?a
}
""" 
.



[] a st:Query ;
st:name st:union ;
rdfs:label "Union" ;
rdfs:comment """Retourne les  instances de Man ou Woman."""@fr ;
rdfs:comment """Return instances of Man or Woman."""@en ;
st:reference  ;
st:query 
"""
prefix h: 
select * where { 
  { ?x a h:Man } union { ?x a h:Woman }
}
""" 
.



[] a st:Query ;
st:name st:optional ;
rdfs:label "Optional" ;
rdfs:comment """Retourne les ressources ?x instance de Man ayant éventuellement un conjoint. """@fr ;
rdfs:comment """Return instances of Man possibly having a spouse."""@en ;
st:reference  ;

st:query 
"""prefix h: 
select * where { 
  ?x a h:Man  
  ?x h:hasSpouse ?s 
}
""" ;

st:solution 
"""prefix h: 
select * where { 
  ?x a h:Man  
  optional { ?x h:hasSpouse ?s }
}
""" 
.


[] a st:Query ;
st:name st:exists ;
rdfs:label "Exists" ;
rdfs:comment """Retourne les ressources ?x instance de Man ayant  un conjoint. """@fr ;
rdfs:comment """Return instances of Man having a spouse. """@en ;
st:reference  ;
st:query 
"""prefix h: 
select * where { 
  ?x a h:Man  
  filter exists { ?x h:hasSpouse ?s }
}
""" 
.

[] a st:Query ;
st:name st:notexists ;
rdfs:label "Not Exists" ;
rdfs:comment """Retourne les  instances de Man n'ayant  pas de conjoint. """@fr ;
rdfs:comment """Return instances of Man not having a spouse. """@en ;
st:reference  ;
st:query 
"""prefix h: 
select * where { 
  ?x a h:Man  
  filter not exists { ?x h:hasSpouse ?s }
}
""" 
.


[] a st:Query ;
st:name st:minus ;
rdfs:label "Minus" ;
rdfs:comment """Retourne les ressources ?x instance de Woman n'ayant pas de conjoint. """@fr ;
rdfs:comment """Return instances of Man not having a spouse. """@en ;
st:reference  ;
st:query 
"""prefix h: 
select * where { 
  ?x a h:Woman  
  minus { ?x h:hasSpouse ?s }
}
""" 
.




[] a st:Query ;
st:name st:graph ;
rdfs:label "Named Graph" ;
rdfs:comment """Retourne le (ou les) graphe nommé dans lequel se trouvent des solutions."""@fr ;
rdfs:comment """Return  named graph(s) where there are solutions."""@en ;
st:query 
"""prefix h: 
select * where { 
graph ?g {
  ?x a h:Woman  
  minus { ?x h:hasSpouse ?s }
  }
}
""" 
.


[] a st:Query ;
st:name st:from ;
rdfs:label "From" ;
rdfs:comment """Spécifie le (ou les) graphe nommé utilisé pour constituer le graphe par défaut. """@fr ;
rdfs:comment """Specify the named graph(s) used to form the default graph. """@en ;
st:reference  ;
st:query 
"""prefix h: 
prefix st: 
select * 
from st:data
where { 
   ?x ?p ?y
}
""" 
.

[] a st:Query ;
st:name st:from-named ;
rdfs:label "From Named" ;
rdfs:comment """Spécifie le (ou les) graphe nommé sur lesquel l'énoncé graph ?g est évalué """@fr ;
rdfs:comment """Specify the named graphs where the named graph pattern is evaluated."""@en ;
st:reference  ;
st:query 
"""prefix h: 
prefix st: 
select * 
from named st:data
where { 
   graph ?g { ?x ?p ?y }
}
""" 
.


[] a st:Query ;
st:name st:subquery ;
rdfs:label "Subquery" ;
rdfs:comment """Exécute une partie de la requête dans une sous-requête emboîtée."""@fr ;
rdfs:comment """Execute part of the query in a nested subquery."""@en ;
st:reference  ;
st:query 
"""prefix h: 
select * where { 

  {select (max(?age) as ?max) (min(?age) as ?min) where {
    ?x a h:Person ;
      h:age ?age 
  }}
  
  ?x h:age ?age 
  filter(?age in (?min, ?max))
}
""" 
.


[] a st:Query ;
st:name st:bind ;
rdfs:label "Bind" ;
rdfs:comment """Crée une variable pour le résultat d'un calcul."""@fr ;
rdfs:comment """Create a variable for the result of a computation."""@en ;
st:reference  ;
st:query 
"""prefix h: 
select * where { 
  ?x a h:Person ;
    h:name ?n .
    bind (ucase(?n) as ?u)
}
""" 
.


[] a st:Query ;
st:name st:values ;
rdfs:label "Values" ;
rdfs:comment """Fixe les valeurs de certaines variables."""@fr ;
rdfs:comment """Set values of some variables."""@en ;
st:reference  ;
st:query 
"""prefix h: 
select * where { 
    ?x h:name ?n ;
    optional { ?x h:age  ?a } 
    values ?n { "John" "Alice" "Lucas" }
}
""" 
.


[] a st:Query ;
st:name st:path ;
rdfs:label "Property Path" ;
rdfs:comment """Retourne des ressources reliées par un chemin de propriétés. """@fr ;
rdfs:comment """Return resources related by a property path. """@en ;
st:reference  ;
st:query 
"""prefix h: 
select * where { 
  ?x a h:Person .
  ?x h:hasFriend+ ?y
}
""" 
.


[] a st:Query ;
st:name st:dbpedia ;
rdfs:label "Service" ;
rdfs:comment """Interroge le SPARQL endpoint fr.dbpedia.org."""@fr ;
rdfs:comment """Query fr.dbpedia.org SPARQL endpoint."""@en ;
st:reference  ;
st:query 
"""select * where { 
     service  {
      select * where {
	 ?p ?y 
      }
      limit 20 
      offset 20
      }
   }
""" 
.


[] a st:Query ;
st:name st:construct ;
rdfs:label "Construct" ;
rdfs:comment """Construit un graphe résultat."""@fr ;
rdfs:comment """Create a result graph."""@en ;
st:reference  ;
st:query 
"""prefix h: 
construct {
  ?x h:hasFriend ?y
}
where { 
  ?x a h:Person .
  ?x h:hasFriend+ ?y .
}
""" 
.


[] a st:Query ;
st:name st:describe ;
rdfs:label "Describe" ;
rdfs:comment """Décrit une ressource."""@fr ;
rdfs:comment """Describe a resource."""@en ;
st:reference  ;
st:query 
"""prefix h: 
describe ?x where {
  ?x h:age 12 .
}
""" 
.


[] a st:Query ;
st:name st:ask ;
rdfs:label "Ask" ;
rdfs:comment """Répond par vrai ou faux."""@fr ;
rdfs:comment """Answer true of false."""@en ;
st:reference  ;
st:query 
"""prefix h: 
ask  {
  ?x h:age 12 .
}
""" 
.



#######################################################




[] a st:Query ;
st:name st:listpp ;
rdfs:label "List Path" ;
rdfs:comment """Enumère les éléments d'une liste avec un chemin."""@fr ;
rdfs:comment """Enumerate list elements using a path."""@en ;
st:reference  ;
st:query 
"""prefix h: 
select ?x ?e where {
  ?x h:list ?l
  ?l rdf:rest*/rdf:first ?e
}
""" 
.


[] a st:Query ;
st:name st:position ;
rdfs:label "List Position" ;
rdfs:comment """Enumère les éléments d'une liste en donnant leur position."""@fr ;
rdfs:comment """Enumerate list elements using a path with the elements position."""@en ;
st:reference  ;
st:query 
"""prefix h: 
select ?x ?e (count(?mid) as ?pos) where {
  ?x h:list ?l
  ?l rdf:rest* ?mid 
  ?mid rdf:rest* ?node
  ?node rdf:first ?e
}
group by ?node
order by ?pos
""" 
.

[] a st:Query ;
st:name st:subsume ;
rdfs:label "Subsumption" ;
rdfs:comment """Retourne les instances d'une classe avec un chemin."""@fr ;
rdfs:comment """Return class instances using a path."""@en ;
st:reference  ;
st:query 
"""prefix h: 
select ?x where {
  ?x rdf:type/rdfs:subClassOf* h:Person
}
""" 
.


[] a st:Query ;
st:name st:rdfs ;
rdfs:label "RDFS Entailments" ;
rdfs:comment """Enumère les déductions RDFS."""@fr ;
rdfs:comment """Enumerate RDFS entailments."""@en ;
#st:reference  ;
st:query 
"""prefix h: 
select * 
from kg:entailment
where {
  ?x ?p ?y 
}
""" 
.







[] a st:Query ;
st:name st:queries ;
rdfs:label "Queries" ;
rdfs:comment """Enumère les requêtes."""@fr ;
rdfs:comment """Enumerate queries."""@en ;
#st:reference  ;
st:query 
"""
select ?q  
where {
  graph st:context { ?x st:query ?q }
}
""" 
.


























© 2015 - 2025 Weber Informatics LLC | Privacy Policy