Note: this is no longer in production, and exists only as a module for providing an endpoint for micromaterials to consume
A REST-ful API For Words & Stuff
Read Adam's blog post here.
$ virtualenv .venv
$ source .venv/bin/activate
$ pip install -r requirements.txt$ python wsgi.py$ nosetestsNote: these tests require a running MongoDB instance.
$ behaveThe MongoDB instance defaults one running on
localhostbut you can change this in thesettings.ymlfile.
$ MONGO_URL: '<insert the URL of your MongoDB instance here>'krump:: the application source code.test:: unit tests for the above source code.cukes:: BDD tests for the application using Behave.
This next bit assumes that the DB is populated and the application is running.
To get sentences with a specific feature:
http://<SERVER_IP_ADDRESS:PORT>/api/sentence/<FEATURE>
Currently only JSON responses are supported: clients must supply an
ACCEPTheader value ofapplication/json.
If there are no sentences with the desired feature in the underlying DB, then a
204 NO CONTENT response will be returned.
FEATURE might be apostrophe -- to get sentences with apostrophes -- or one
of the features listed below.
simple_pastnon_third_person_singular_simple_presentthird_person_singular_simple_presentpresent_participlepast_participlearticlesingular_nounplural_nounwh_determinercomparative_adjectivesuperlative_adjective
curl -XGET -H 'Accept: application/json' http://localhost:9000/api/sentence/apostropheTo get sentences with a specific word (if present in the database):
http://<SERVER_IP_ADDRESS:PORT>/api/sentence/word/<WORD>
The API also supports three query parameters:
-
count: the number of sentences to be returned. (Default10.) -
max-words: the maximum number of words in sentences returned. (Default100.) -
skip: allows paging and returns the next (skip * count) sentences in the response.