2

I want to make a textual representations of an RDF graph with Turtle. As an example the relation between Spiderman and the Green Goblin. See the reference here https://www.w3.org/TR/turtle/

@base <http://example.org/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rel: <http://www.perceive.net/schemas/relationship/> 

<#green-goblin>
    rel:enemyOf <#spiderman> ;
    a foaf:Person ;    # in the context of the Marvel universe
    foaf:name "Green Goblin" .
<#spiderman>
    rel:enemyOf <#green-goblin> ;
    a foaf:Person ;
    foaf:name "Spiderman", "Человек-паук"@ru .

What does the comma (,) mean between "Spiderman" and the Russian word?

Another more important question is: how can I do that with a city and a country over time? For example: Leipzig belonged to the DDR until 1990. Today Leipzig is a city in Germany.

unor
  • 92,415
  • 26
  • 211
  • 360
Mchoeti
  • 536
  • 1
  • 8
  • 24
  • 1
    How can you do _what_ with a city and a country over time? It's not very clear what you're after, or what your "other question" has to do with your example of Spiderman and the Green Goblin. – Jeen Broekstra Apr 03 '16 at 02:13

1 Answers1

3

Seems like two very separate questions here. One on syntax and one on modeling.

For the syntax problem I'd suggest looking at Turtle - Terse RDF Triple Language. Turtle specifies triples, which requires three entities in the specification of a triple. The . specifies the end of a triple. As a shortcut, a ; means the current subject is carried over to the next triple specification - hence only the predicate and object need to be specified. A , means the subject and object are carried over to the next triple. Therefore,

<#spiderman> foaf:name "Spiderman", "Человек-паук"@ru .

Specifies two triples:

<#spiderman> foaf:name "Spiderman" .
<#spiderman> foaf:name "Человек-паук"@ru .

One the modeling question, to specify the different nationalizations of Leipzig at different epochs of time, specify a property, such as isMemberOfCountry that has properties of fromDate and toDate. Each instance of country membership would then be populated:

@prefix ex: <http://example.org/geoex/> 
ex:Leipzig
  ex:isMemberOfCountry [
      ex:country ex:DDR ;
      ex:fromDate 1945 ;
      ex:toDate 1990 ;
    ] ;
  ex:isMemberOfCountry [
      ex:country ex:Germany ;
      ex:fromDate 1990 ;
    ] .

Bnodes are used ensure unique names across the dataset for an object whose name may not matter (if it does, then specify an object a use in place of the bnode). Then to query the current country, use:

SELECT ?country
WHERE {
   ex:Leipzig ex:isMemberOfCountry ?member .
   ?member ex:country ?country .
   FILTER NOT EXISTS {
      ?member ex:toDate ?d
   }
}

And to find the membership during a specific year, use the following:

SELECT ?country
WHERE {
 BIND("1991"^^xsd:integer AS ?date) #placeholder - ?date should be passed into the query
    ex:Leipzig ex:isMemberOfCountry ?member .
    ?member ex:country ?country .
    ?member ex:fromDate ?fdate .
    OPTIONAL {?member ex:toDate ?td}
    BIND(IF(bound(?td), ?td, year(now())) AS ?edate)
    FILTER (?date >= ?fdate && ?date <= ?edate)
}

Note that binding ?date to 1990 will result in two results, which is correct given that years are used instead of dates in this example model.

scotthenninger
  • 3,921
  • 1
  • 15
  • 24
  • Ok, that helps a lot, thank you for the detailed informations. The tags or words like isMemberOfCountry or country are free defined tags. which are should be used in a logic way or ? – Mchoeti Apr 04 '16 at 12:54
  • 2
    Those words are not "words" but URIs - objects. So given the prefix definition above, ex:isMemberOfCountry expands to . Some research into the RDF/Turtle documents we've both posted here should make this clearer. – scotthenninger Apr 04 '16 at 13:32
  • 1
    Note that Turtle is a W3C Recommendation: https://www.w3.org/TR/turtle/ (your link is to an older draft) – unor Apr 06 '16 at 14:19
  • Thanks, I had simply grabbed the wrong URL. Now corrected. – scotthenninger Apr 06 '16 at 14:24