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:     <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix aapi:    <http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#> .
<http://rdf.alchemyapi.com/rdf/v1/r/response.rdf#db80159fcbbc663cd43e77bfb37fd35c434b0bc6f-ge_1>
      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.

Thanks!

asked 17 Nov '12, 09:42

shikhar's gravatar image

shikhar
235
accept rate: 0%

1

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: <http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#>
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
462
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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×1,299
×613
×51

question asked: 17 Nov '12, 09:42

question was seen: 1,062 times

last updated: 17 Nov '12, 18:35