Skip to content
This repository was archived by the owner on Feb 18, 2020. It is now read-only.

Fetch treaties#5

Merged
amaury1093 merged 3 commits intomasterfrom
wh-treaties
Jan 20, 2019
Merged

Fetch treaties#5
amaury1093 merged 3 commits intomasterfrom
wh-treaties

Conversation

@quorth0n
Copy link
Member

Depends on #1

?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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay. Yeah adding to wikidata is definitely a better way to go.

@quorth0n quorth0n requested a review from amaury1093 January 19, 2019 19:45
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@amaury1093 amaury1093 merged commit b66455b into master Jan 20, 2019
@amaury1093 amaury1093 deleted the wh-treaties branch January 20, 2019 19:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants