Skip to content

Instantly share code, notes, and snippets.

@dsager
dsager / wb_themes.rb
Created October 25, 2016 12:24
world-bank theme classifier
#
# script to load project data from the world bank and generate a training set
# for a classifier
#
# Get a list of projects from the world bank and filter out projects w/o abstracts & themes
#
# curl -s 'http://search.worldbank.org/api/v2/projects?format=json&fl=project_name,project_abstract,theme_namecode&source=IBRD&rows=50000'
# | jq '[.projects[] | select(.project_abstract? and .theme_namecode?)] | map({"text": [.project_name, .project_abstract.cdata] | join(" - "), "themes": .theme_namecode | map(.code)})'
# > wb-projects.json
#
@dsager
dsager / look_at_images.rb
Created February 6, 2017 11:14
Google Cloud Vision: Devex Article Images 2016
# Script to get Google CLoud Vision annotations for a bunch of images
# Images in /images are expected to be also present in the specified GCS bucket
#
# setup:
# gem install google-cloud-vision
# export GOOGLE_CLOUD_PROJECT="XX-XX"
# export GOOGLE_CLOUD_KEYFILE="~/path/to/XX-XX.json"
#
require 'google/cloud/vision'