DEV Community

Grant Carthew
Grant Carthew

Posted on • Updated on

define - linguistics assistant

TLDR: Use the define CLI to fix spelling mistakes and find similar words.

When I went to school, I found learning English to be hard going. Some people are blessed with all-round skills and soar ahead with seemingly little effort. Me? Not so much.

I was grateful we had computers in school. Computers just made sense. Logical machines that do exactly what you tell them to do. English?

Watch this video for a funny example of some of the stupidity in the English language.

This brings me to my current practices when it comes to writing. For as long as I can remember there have been two language-related tasks I use my browser for: spell checking, and using a thesaurus.

Browser for Spell Checking

I am not the only one who uses this technique. I now know that this pattern is extremely common within the programming community that surrounds me.

You switch to your browser, focus on the address bar, and type:

define in the address bar

And your default search engine is kind enough to give you...

definition of gobbledygook

Now this has been a fantastic tool for me over the years. My search engine, Kagi.com, has confirmed that I have spelled the word correctly or fixed my spelling for me, and given me a definition of the word I am checking.

Sweet. I Alt-Tab back to what I was doing and move on. I use this technique so often that it is probably a little embarrassing.

Thesaurus for Word Discovery

I love thesaurus websites. Chuck in any word and they give you an assortment of similar words, synonyms, and depending on the site you use, antonyms, related words, history, and more.

As you can imagine, I don't just go to thesaurus websites for the fun of it. I have a need...

There are only two hard things in Computer Science: cache invalidation and naming things.

https://martinfowler.com/bliki/TwoHardThings.html

You know how it goes, you're up to your elbows in code and you need a handle on this strange bit of data. What do you call this variable? Well, what is it? Some obscure JSON string, a list of statistics, migration data, it's hard.

A thesaurus to the rescue.

The Birth of define

Like most technical people, I'm LOVING the advent of Large Language Models. Every time I use them I am amazed that the seemingly simple task of picking the next word based on probability can write code, suggest meals, write documents, and so much more.

I'm sticking with OpenAI's ChatGPT for now, mostly because of defined rankings you find on pages like the Large Model Systems Organization Leaderboard page.

As soon as I could get an API Key for the OpenAI models, I got right in and started building myself a personal AI client. One of the most useful things about a personal AI client is that you can write your own complex chat prompts.

My prompts can be found in the prompts directory of my AI client. I suggest you don't use this client. It is not really polished yet and has gone through lots of churn already. It is not the focus of this post.

At some point after getting the AI client to a point where it was working, I had a bright idea to write a prompt I called "define". This prompt was designed to help me with spelling, definitions, and synonyms.

Using my AI client on the terminal I would type:

$ ai define "accomodate"
Enter fullscreen mode Exit fullscreen mode

My "define" prompt would be supplied to ChatGPT with my misspelled word, and I would get back the correct spelling, a definition of the word, and a list of synonyms and antonyms.

Wow, this thing was the best. I found myself using it so often I decided to separate it out to its own client. This was the birth of define.

The Project

define

Mozilla Public License Version 2.0

pipx install python-define

See the installation instructions for a little more detail.

The define project is a simple Python script of only 200 lines. It is designed to run in the terminal. It makes an asynchronous call to ChatGPT v3.5 and displays the result. There is an embedded prompt within the tool instructing ChatGPT.

The magic comes from having a custom tool to replace switching to a new browser tab and getting a search engine to help me. Not only that, I now have spelling, definition, synonyms, and antonyms all in one tool. On top of that, it is flexible. Even if you don't know what the word is, you can ask.

I suggest you make your own. Use my project as an example and build a tool that is just right for you.

Postscript

I used the define CLI 16 times to write this post.

ChatGPT v4 reviewed the text for me and fixed up a few issues.

Top comments (0)