My question may seem very dumb. I am very new to SPARQL. The thing is I have a file in turtle format like below.

@prefix geo:     <> .
@prefix owl:     <> .
@prefix rdf:     <> .
@prefix aapi:    <> .
      a       aapi:EntityOccurrences ;
      aapi:Doc "db80159fcbbc663cd43e77bfb37fd35c434b0bc6f" ;
      aapi:EntityType "Person" ;
      aapi:Name "Thomson" ;
      aapi:NumOccurs "2" ;
      aapi:Relevance "0.816705" .

I have to write two SPARQL queries.

  1. find all the entries where the attribute aapi:Name is Thomson.
  2. if aapi:Name is Thomson find the aapi:EntityType Additionally if you could tell me how I can do the same in Apache Jena, that would be useful.


asked 17 Nov '12, 09:42

shikhar's gravatar image

accept rate: 0%


What have you tried? Remember that SPARQL matches triples, and variables act as the unknown components.

eg, consider query 1s triple pattern as (any entry) (aapi:Name) ("Thomson"), and use this as a starting point to try a potential queries.

There are numerous good tutorials on SPARQL thats should help with the syntax.

Let us know how you get on (include the SPARQL query that you have tried and are having difficulty with).

(17 Nov '12, 10:11) Sweet Burlap Sweet%20Burlap's gravatar image

Write this query and you will get URIs (?unknownEntityURI and ?entityTypeURI) and Text (?entityTypeTEXT) of entity whose name is "Thomson" and has property EntityType

PREFIX aapi: <>
SELECT ?unknownEntityURI ?entityTypeURI ?entityTypeTEXT {
# find all the entries where the attribute aapi:Name is Thomson, with this:
?unknownEntityURI aapi:Name ?Name.
?Name aapi:label „Thomson“.
# this finds type of entity:
?unknownEntityURI aapi:EntityType ?entityTypeURI.
?entityTypeURI aapi:label ?entityTypeTEXT.
permanent link

answered 17 Nov '12, 16:54

Tom%C3%A1%C5%A1%20%C5%98eho%C5%99ek's gravatar image

Tomáš Řehořek
accept rate: 50%

Thanks! :) I will check it up and mark it as accepted

(17 Nov '12, 18:35) shikhar shikhar's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 17 Nov '12, 09:42

question was seen: 1,461 times

last updated: 17 Nov '12, 18:35