Skip to content

Instantly share code, notes, and snippets.

@paregorios
Last active April 3, 2017 11:48
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save paregorios/64873fabf30e49e2827508c337431f3f to your computer and use it in GitHub Desktop.
How to find all Pleiades URIs that correspond to a Trismegistos place URI
# read in the json and get the graph of places
import json
with open('pleiades-places-latest.json', 'r', encoding='utf-8') as f:
pj = json.load(f)
graph = pj['@graph']
# iterate through the graph and test each place for a TM reference
for place in graph:
references = place['references']
tm_geoids = [r['accessURI'] for r in references if 'trismegistos' in r['accessURI']]
if len(tm_geoids) == 1:
print('{} = {}'.format(place['uri'], tm_geoids[0]))
@paregorios
Copy link
Author

Python 3.6. This code assumes that you have already downloaded the Pleiades comprehensive nightly JSON export from http://atlantides.org/downloads/pleiades/json/pleiades-places-latest.json.gz and un-gzipped it in your working directory.

@paregorios
Copy link
Author

Output will look like:

https://pleiades.stoa.org/places/265876 = http://www.trismegistos.org/place/27183
https://pleiades.stoa.org/places/265880 = http://www.trismegistos.org/place/27402
https://pleiades.stoa.org/places/265886 = http://www.trismegistos.org/place/27107
https://pleiades.stoa.org/places/265887 = http://www.trismegistos.org/place/27479
https://pleiades.stoa.org/places/265891 = http://www.trismegistos.org/place/27788

@fosco13
Copy link

fosco13 commented Apr 2, 2017

missing parenthesis on line 12 to close the print command

    print('{} = {}'.format(place['uri'], tm_geoids[0]))

@paregorios
Copy link
Author

Thanks @fosco13! I've updated the gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment