Conversation
fetch_treaties.py
Outdated
| ?treaty wdt:P585 ?time. | ||
| ?treaty wdt:P276 ?location. | ||
| FILTER (?time > "1789-01-01T00:00:00Z"^^xsd:dateTime) | ||
| FILTER (?time < "1815-01-01T00:00:00Z"^^xsd:dateTime) |
There was a problem hiding this comment.
Since we go until 1815, I think here it should be 1816
| R_TREATIES = requests.get(URL, params={"format": "json", "query": QUERY}) | ||
| TREATIES = R_TREATIES.json() | ||
|
|
||
| for treaty in TREATIES["results"]["bindings"]: |
There was a problem hiding this comment.
Instead of doing n more requests, you could actually do one sparql request to get location + coords:
SELECT ?treaty ?treatyLabel ?time ?location ?coors
WHERE
{
?treaty wdt:P31 wd:Q625298.
?treaty wdt:P585 ?time.
?treaty wdt:P276 ?location.
?location wdt:P625 ?coors
FILTER (?time > "1789-01-01T00:00:00Z"^^xsd:dateTime)
FILTER (?time < "1816-01-01T00:00:00Z"^^xsd:dateTime)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
sorry, my fault, should have put this version in the excel file.
There was a problem hiding this comment.
Thanks, I was experimenting with this but when I tried to return P625 only one or two had a value for it, which is why I did the second query based on P276. It seems like most of them have a P625 though now that I look
There was a problem hiding this comment.
When I do OPTIONAL {?treaty wdt:P276 ?location }., I get 28 results, which means some treaties don't have location at all. I was planning to add them manually on wikidata.
There was a problem hiding this comment.
Ah, okay. Yeah adding to wikidata is definitely a better way to go.
Depends on #1