define - linguistics assistant
Tags: openai, chatgpt, python, cli
Published: 2023-08-20 23:49:35

_TLDR: Use the [define CLI](https://github.com/grantcarthew/python-define) 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](https://www.youtube.com/shorts/WKNV3R1NhIk) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvtjojwrnrxhanplybt7.png)

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

![definition of gobbledygook](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/knbfnt305h60nz8tvb99.png)

Now this has been a fantastic tool for me over the years. My search engine, [Kagi.com](https://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](https://chat.lmsys.org/?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](https://github.com/grantcarthew/python-ai/tree/main/prompts) directory of my [AI client](https://github.com/grantcarthew/python-ai). 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:

```shell
$ ai define "accomodate"
```

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](https://github.com/grantcarthew/python-define).

## The Project

[define](https://github.com/grantcarthew/python-define)

Mozilla Public License Version 2.0

`pipx install python-define`

_See the [installation instructions](https://github.com/grantcarthew/python-define#installation) 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.