Skip to content

Instantly share code, notes, and snippets.

@atomotic
Last active December 26, 2015 23:18
Show Gist options
  • Save atomotic/7229203 to your computer and use it in GitHub Desktop.
Save atomotic/7229203 to your computer and use it in GitHub Desktop.
resolve sbn authority id to wikipedia.it

resolve SBN authority id to wikipedia.it

(requires jq and gnu parallel)

  • get all Q ids with P396 property > ids.txt

~ make get

~ make resolv

  • configure the apache virtualhost to use the rewrite map (now allowed in .htaccess)
RewriteEngine on
RewriteMap iccu txt:/{FULL_PATH}/resolv.map
RewriteRule ^/r/(.*)$ ${iccu:$1} [R]
RewriteEngine on
RewriteMap iccu txt:/{FULL_PATH}/resolv.map
RewriteRule ^/r/(.*)$ ${iccu:$1} [R]
#!/usr/bin/env python
import sys
import pywikibot
q = "Q{}".format(sys.argv[1])
site = pywikibot.Site('it','wikipedia')
repo = site.data_repository()
item = pywikibot.ItemPage(repo, q)
data = item.get()
iccu = item.claims['P396'][0].getTarget()
title = "http://it.wikipedia.org/wiki/{}".format(data['sitelinks']['itwiki'].replace (" ", "_"))
print iccu, title
get:
curl -s "http://208.80.153.172/api?q=claim\[396\]" | jq ".items[]" > ids.txt
resolve:
parallel -j4 ./make-resolver-map.py {} :::: ids.txt > resolv.map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment