Search code examples
pythonsparqldata-modelingdbpediawikidata

How to convert the name of a historical time period in to a year/date in SPARQL?


I am a beginner to SPARQL and I managed to implement a query that returns the historical time period (P2348) for when an item was created, examples of this are 'Bronze age', 'Mesolithic', 'Nguyen dynasty' etc. I also have other items that return a specific year for when they were created. I was wondering if there is any way to convert the historical periods into an approximate year instead of the name of a period. It obviously doesn't have to be accurate at all just a year in that time period.


Solution

  • If you have an age you can query its start and end time. Here is an example:

    select ?age ?age_name ?start_time ?end_time {
      ?age wdt:P31 wd:Q15401699.  # age is archeological age.
      ?age rdfs:label ?age_name. filter(lang(?age_name)='en').
      ?age wdt:P580 ?start_time.
      ?age wdt:P582 ?end_time.
    }