Wikidata on Leaflet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%capture | |
!pip install gradio transformers sentencepiece | |
import gradio as gr | |
from transformers import pipeline | |
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es") | |
def predict(text): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- # Config file for Wiki API Connector. Make sure there are no TAB characters in this YAML file! | |
units: | |
- unit: | |
name: Smithsonian American Art Museum | |
api: | |
api_url: https://api.si.edu/openaccess/api/v1.0/content/edanmdm:{}?api_key={} | |
api_key: true | |
api_key_info: https://api.data.gov/signup/ | |
api_key_string: TKTKTKTK # This needs to be filled in or brought in as a secret | |
fields: [identifier, api_key_string] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"status": 200, | |
"responseCode": 1, | |
"response": { | |
"id": "edanmdm-nmaahc_2018.59.3", | |
"title": "M1917 Revolver issued by US Army during WWI to Charles H. Houston", | |
"unitCode": "NMAAHC", | |
"type": "edanmdm", | |
"url": "edanmdm:nmaahc_2018.59.3", | |
"content": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First, you should install flickrapi | |
# pip install flickrapi | |
import flickrapi | |
import urllib | |
from PIL import Image | |
# Flickr api access key | |
flickr=flickrapi.FlickrAPI('c6a2c45591d4973ff525042472446ca2', '202ffe6f387ce29b', cache=True) |
A previous post How to Add Museum IDs to Wikidata explained how to use SPARQL to find missing data on Wikidata (Getty Museum IDs), how to create such values (from museum webpage URLs) and how to format them properly for QuickStatements.
Here I explain how to use Google sheets to manage a more advanced task. The sheet AAT-Wikidata matches about 3k AAT concepts to Wikipedia, WordNet30 and BabelNet (it restored an old mapping to Wordnet, retrieved it from BabelNet, mapped to Wikipedia).
- For each row, it uses the following Google sheet formula (column C) to query the Wikipedia API and get the corresponding Wikidata ID (wikibase_item); split on two lines for readability:
=ImportXml(concat("https://en.wikipedia.o
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.