Skip to content

Instantly share code, notes, and snippets.

@fergusq
Last active June 11, 2017 20:34
Show Gist options
  • Save fergusq/d7cd280b011b08f282311b2c9b8a741f to your computer and use it in GitHub Desktop.
Save fergusq/d7cd280b011b08f282311b2c9b8a741f to your computer and use it in GitHub Desktop.
A script for downloading category word lists from wiktionary
{ toRödaObj := require("json").jsonToRödaObj }
getadjs cat, token {
obj := toRödaObj(json([loadResourceLines("https://en.wiktionary.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:"..cat.."&cmlimit=500&format=json&cmcontinue="..token)]&" "))
for adj in obj["query"]["categorymembers"] do
STDOUT.push adj["title"], "\n"
done
return obj["continue"]["cmcontinue"] if [obj["continue"]?] else return ""
}
main cat {
token := ""
while true do
token = getadjs(cat, token)
break if [ token = "" ]
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment