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
$ nosetests
Note: these tests require a running MongoDB instance.
$ behave
The MongoDB instance defaults one running on
localhost
but you can change this in thesettings.yml
file.
$ 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
ACCEPT
header 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_past
non_third_person_singular_simple_present
third_person_singular_simple_present
present_participle
past_participle
article
singular_noun
plural_noun
wh_determiner
comparative_adjective
superlative_adjective
curl -XGET -H 'Accept: application/json' http://localhost:9000/api/sentence/apostrophe
To 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.