Text prediction REST API, v2.1


https://api.imagineville.org/word/random

Returns random words drawn from the vocabulary.

Parameter Required/optional Description Valid values Default
num
Optional Number of results 1- 5
vocab
Optional Vocabulary size to draw words from 1k, 5k, 10k, 20k, 40k, 100k, 500k 100k
sort
Optional Sorting of result words alpha = sort alphabetically A-Z
rev-alpha = sort reverse alphabetically Z-A
(none)
safe
Optional Safe mode, filters obscene words. on off
prefix
Optional Prefix of random words Sequence of one or more characters (none)
suffix
Optional Suffix of random words Sequence of one or more characters (none)
substring
Optional Substring that must occur in random words Sequence of one or more characters (none)

Example:
https://api.imagineville.org/word/random?num=10&sort=alpha&vocab=500k&safe=on&prefix=un&suffix=ly


https://api.imagineville.org/word/predict

Predict the most likely words based on what is to the left, right, and/or the prefix of the current word.

Parameter Required/optional Description Valid values Default
left
Optional Left text context One or more words separated by spaces (none)
right
Optional Right text context One or more words separated by spaces (none)
prefix
Optional Prefix of current word Sequence of one or more characters (none)
num
Optional Number of results 1- 5
vocab
Optional Filter to words in this vocabulary size 1k, 5k, 10k, 20k, 40k, 100k, 500k 100k
sort
Optional Sorting of result words alpha = alphabetically A-Z
rev-alpha = reverse alphabetically Z-A
logprob = log probability, largest first
rev-logprob = log probability, smallest first
logprob
safe
Optional Safe mode, filters obscene words. on off

Example:
https://api.imagineville.org/word/predict?left=this is a&prefix=t&right=message


https://api.imagineville.org/word/predict/future

Predict the most likely words based on all possible future characters and what is to the left, right, and/or the prefix of the current word. This is useful for interfaces that want to cache future predictions in order to hide API latency.

Parameter Required/optional Description Valid values Default
left
Optional Left text context One or more words separated by spaces (none)
right
Optional Right text context One or more words separated by spaces (none)
prefix
Optional Prefix of current word Sequence of one or more characters (none)
num
Optional Number of results 1- 5
vocab
Optional Filter to words in this vocabulary size 1k, 5k, 10k, 20k, 40k, 100k, 500k 100k
sort
Optional Sorting of result words alpha = alphabetically A-Z
rev-alpha = reverse alphabetically Z-A
logprob = log probability of next character, largest first
rev-logprob = log probability of next character, smallest first
logprob-next = word set max log probability, largest first
rev-logprob-next = word set max log probability, smallest first
logprob
safe
Optional Safe mode, filters obscene words. on off

Example:
https://api.imagineville.org/word/predict/future?left=this is a&prefix=t&right=message


https://api.imagineville.org/word/predict/next/future

Predict the most likely words based on the words predictions based on a given left context, prefix, and right context. This is useful for interfaces that want to cache future predictions in order to hide API latency.

Parameter Required/optional Description Valid values Default
left
Optional Left text context One or more words separated by spaces (none)
right
Optional Right text context One or more words separated by spaces (none)
prefix
Optional Prefix of current word Sequence of one or more characters (none)
num
Optional Number of results 1- 5
vocab
Optional Filter to words in this vocabulary size 1k, 5k, 10k, 20k, 40k, 100k, 500k 100k
sort
Optional Sorting of result words alpha = alphabetically A-Z
rev-alpha = reverse alphabetically Z-A
logprob = log probability of next character, largest first
rev-logprob = log probability of next character, smallest first
logprob-next = word set max log probability, largest first
rev-logprob-next = word set max log probability, smallest first
logprob
safe
Optional Safe mode, filters obscene words. on off

Example:
https://api.imagineville.org/word/predict/next/future?left=this is a&prefix=t


https://api.imagineville.org/character/predict

Get the probability of all next characters given the left text context.

Parameter Required/optional Description Valid values Default
left
Optional Left text context A sequence of characters (none)
sort
Optional Sorting of result words alpha = alphabetically A-Z
rev-alpha = reverse alphabetically Z-A
logprob = log probability of next character, largest first
rev-logprob = log probability of next character, smallest first
logprob-next = character set max log probability, largest first
rev-logprob-next = character set log probability, smallest first
alpha

Example:
https://api.imagineville.org/character/predict?left=what is y&sort=logprob


https://api.imagineville.org/character/predict/future

Get the probability of all next characters given all possible next characters and the current left text context. This is useful for interfaces that want to cache future predictions in order to hide API latency.

Parameter Required/optional Description Valid values Default
left
Optional Left text context A sequence of characters (none)
sort
Optional Sorting of result words alpha = alphabetically A-Z
rev-alpha = reverse alphabetically Z-A
logprob = log probability, largest first
rev-logprob = log probability, smallest first
alpha

Example:
https://api.imagineville.org/character/predict/future?left=what is y&sort=logprob


https://api.imagineville.org/character/predict/next/future

Get the probability of all next characters given all word predictions based on a given left context, prefix, and right context. This is useful for interfaces that want to cache future predictions in order to hide API latency.

Parameter Required/optional Description Valid values Default
left
Optional Left text context One or more words separated by spaces (none)
right
Optional Right text context One or more words separated by spaces (none)
prefix
Optional Prefix of current word Sequence of one or more characters (none)
num
Optional Number of results 1- 5
vocab
Optional Filter to words in this vocabulary size 1k, 5k, 10k, 20k, 40k, 100k, 500k 100k
sort
Optional Sorting of result words alpha = alphabetically A-Z
rev-alpha = reverse alphabetically Z-A
logprob = log probability of next character, largest first
rev-logprob = log probability of next character, smallest first
logprob-next = word set max log probability, largest first
rev-logprob-next = word set max log probability, smallest first
logprob
safe
Optional Safe mode, filters obscene words. on off

Example:
https://api.imagineville.org/character/predict/next/future?left=this is a&prefix=t


https://api.imagineville.org/sentence/likely

Returns the most likely words from a sentence. This is based on a left-to-right scoring of each word under the language model.

Parameter Required/optional Description Valid values Default
text
Required Sentence text Sequence of words separated by spaces (none)
num
Optional Number of results 1- 5
vocab
Optional Filter to words in this vocabulary size 1k, 5k, 10k, 20k, 40k, 100k, 500k 100k
sort
Optional Sorting of result words alpha = alphabetically A-Z
rev-alpha = reverse alphabetically Z-A
logprob = log probability, largest first
rev-logprob = log probability, smallest first
logprob
safe
Optional Safe mode, filters obscene words. on off

Example:
https://api.imagineville.org/sentence/likely?text=i do not like neon zebras or others animals


https://api.imagineville.org/sentence/unlikely

Returns the least likely words from a sentence. This is based on a left-to-right scoring of each word under the language model.

Parameter Required/optional Description Valid values Default
text
Required Sentence text Sequence of words separated by spaces (none)
num
Optional Number of results 1- 5
vocab
Optional Filter to words in this vocabulary size 1k, 5k, 10k, 20k, 40k, 100k, 500k 100k
sort
Optional Sorting of result words alpha = alphabetically A-Z
rev-alpha = reverse alphabetically Z-A
logprob = log probability, largest first
rev-logprob = log probability, smallest first
logprob
safe
Optional Safe mode, filters obscene words. on off

Example:
https://api.imagineville.org/sentence/unlikely?text=i do not like neon zebras or others animals


https://api.imagineville.org/sentence/oov

Returns the words that are out-of-vocabulary in a sentence with respect to a given vocabulary.

Parameter Required/optional Description Valid values Default
text
Required Sentence text Sequence of words separated by spaces (none)
num
Optional Number of results 1- 5
vocab
Optional Vocabulary used to determine out-of-vocabulary words 1k, 5k, 10k, 20k, 40k, 100k, 500k 100k
sort
Optional Sorting of result words alpha = alphabetically A-Z
rev-alpha = reverse alphabetically Z-A
(none)
safe
Optional Safe mode, filters obscene words. on off

Example:
https://api.imagineville.org/sentence/oov?vocab=1k&text=it was the epoch of belief it was the epoch of incredulity


https://api.imagineville.org/sentence/word/perplexity

Returns the average per-word perplexity of a sentence under the word language model.

Parameter Required/optional Description Valid values Default
text
Required Sentence text Sequence of words separated by spaces (none)

Example:
https://api.imagineville.org/sentence/word/perplexity?text=i like neon zebras


https://api.imagineville.org/sentence/character/perplexity

Returns the average per-character perplexity of a sentence under the character language model.

Parameter Required/optional Description Valid values Default
text
Required Sentence text Sequence of characters (none)

Example:
https://api.imagineville.org/sentence/character/perplexity?text=i like neon zebras