If you are into writing poems, stories or essays, or you just have a fascination for words, I encourage you to take a look at Datamuse.
Recently I was studying about the structure of various poetic forms, and in the process of browing different sites, I stumbled upon Datamuse. I found it to be pretty interesting. They have an API that one can use to take advantage of the various services, for example, finding rhyming words, synonyms, antonyms, etc.
To make my exploration easier and convenient, I wrote a Lisp program to interact with the API so that I can access the services programmatically. In this post, I am sharing what I learnt about the API.
Topics
You can ask for words from one or more topics. Here I am asking for some words from the topic movie.
In my implementation, I have default-limited the response to a maximum of 10 words. It is easy to ask for more (the max supported by the API is 1000).
The above prints 20 words (for convenience, I have used a function print-in-rows to split a list across multiple rows).
We can include up to 5 topics in the request. In the request below, I have included 3 topics.
It is not clear how many or what topics are supported, but I assume there is a wide coverage.
Words
If you just want some words (unconstrained), that is quite easy:
You can also be more specific in filtering the words. Below, I am requesting 10 words starting with t and ending with sh:
Similar Meaning
This is a great feature available in the API. You can give a word or phrase and ask for words that have similar meaning.
In the above example, I have asked for words that have a meaning similar to beautiful. In the following, I am supplying a phrase and asking for words that have similar meaning. This is like a reverse-dictionary.
It is possible to combine parameters. Below, I am listing the output for words that mean beautiful and start with the letter g.
Rhyming Words
Here is another neat feature. You can give a word and ask for others that rhyme with it. This will be useful if you are writing poetry!
One thing you might notice is that the number of syllables is not the same for all words. Whereas terrace has 2 syllables, embarrass has 3 words. I will come back to this point later.
What if we want those rhyming words to start with the letter p? As we saw earlier, that is straightforward.
There is also the notion of approximate rhyming, which includes words that rhyme reasonably close. See below.
There are other variations such as sounds-like and homophones. I will leave them to you for experimentation.
One variant I found interesting is the consonant match. See this example.
Here the match is based on the consonants in the words.
WordNet
WordNet is a hugely popular lexicon with many useful semantic relationships and is widely used in computational linguistics. Datamuse has integrated its database with WordNet and so we can make queries over WordNet relationships.
For example, we can ask for words that are more general than car. This is what we get:
Here is one more example:
How about finding the synonyms and antonyms for a word? Yes, that is possible.
Miscellaneous Things
There are some more filters/parameters that I am not going to discuss here. Feel free to visit the site for details.
One thing I want to mention is that although I have only showed the matching words as part of the result set, the API allows you to specify a few meta-data flags along with the query, in which case some extra lexical information about the matching words will also be included in the result. In my implementation, by default, I pass the flags for Part of Speech, Syllable Count and Pronunciation. These can be displayed in the result set thus:
You can see that a relative score is included for each result element, along with its part-of-speech, pronunciation and number of syllables.
I have also included a secondary filter, which you can use to constrain the result set by part-of-speech as well as number of syllables. I do this on the result fetched from the API, since this is not directly handled by the API (would have been better that way). The following are two examples of applying this filter:
I hope you are not confused by the max words limit. Since I am filtering the result obtained from the API, unless I pass a sufficiently big number to the API, the final result might turn out to be empty.
In conclusion, you can see that the Datamuse API supports rich functionality for working with words. The good news is it is absolutely free and you can make up to 100,000 calls per day! Don’t forget to check it out.
The lisp code I wrote has been tested in LispWorks 7.1 (64 bit) on Windows. You can download the code here.
Enjoy!
Interesting. I use Rhymezone extensively to discover rhyming words for my poems that rhyming. Rhymezone.COM I see uses DataMuse API!