There are a lot of dictionaries on the Web that offer APIs that can be used to get a machine-readable definition of words. Let us use one of the APIs and see how to write a define script.
We are going to use curl
, sed
, and grep
to write the define utility. There are a lot of dictionary websites, where you can register and use their APIs for personal use for free. In this example, we are using Merriam-Webster's dictionary API. Please perform the following steps:
Go to http://www.dictionaryapi.com/register/index.htm, and register an account for yourself. Select Collegiate Dictionary and Learner's Dictionary:
Log in using the newly created account and go to My Keys to access the keys. Note down the key for the learner's dictionary: