AI AISLE

WORDLE Assistant — Vocabulary no bar, anymore!

Nazia Nafis
Nerd For Tech
Published in
4 min readJul 14, 2022

--

A limited vocabulary should be the last thing holding you back from maintaining a Wordle streak.

Wordle is a popular game that got viral in a short amount of time, and you’ve probably already tried it out (if not, check it here). It might however be disheartening sometimes to not be able to guess a word correctly just because you’re not aware of an English-language word that can be formed with the already-guessed letters.

📷 — A little humor from Bill Watterson

But of course, a limited vocab shouldn’t be holding you back from hopping onto the Wordle train that has already taken the world by storm!

So, I made 🔗 this Streamlit app.

How to use it?

The big assumption here is that you’ve already unveiled at least a few letters, which you know would/would not be in the final five-letter word.

The app is up and running on HuggingFace Spaces. After you’ve made a couple of guesses on Wordle, and let’s say are stuck, you just need to enter the inclusion letters (the letters in green/yellow) and exclusion letters (the letters in grey) in their designated input points on the app, and hit Enter.

You’ll get a list of five letter words that do contain your inclusion letters and do not contain your exclusion letters.

Now, all you have to do is to match whichever word suits your situation on Wordle the best! There you have it!

What goes on under the hood?

We make use of NLTK’s English-language corpus.

NLTK is a leading platform for building Python programs to work with human language data. It provides easy-to-use interfaces to over 50 corpora and lexical resources, along with a suite of text-processing libraries for classification, tokenization, stemming, tagging, parsing, and semantic reasoning.

We obtain all valid five-letter English words from the corpus using the words() method.

from nltk.corpus import words
five_letters = [word for word in words.words() if len(word)==5]

As long as we provide at least one inclusion/exclusion letter, the app will return an output.

for word in five_letters:        if all(c in word for c in inclusions and
not any(c in word for c in exclusions):
clue_result.append(word) st.write(clue_result)

Yep, the logic really takes up only these many lines of code!

How about a quick Demo?

After three guesses, let’s say you’re at this stage:

You’re not sure what words begin with an ‘R’, end with an ‘S’, and contain an ‘E’ and a ‘U’ in between.

Just enter this information in the assistant.

Note: The sequence in which you input the letters does not make a difference in the output. The case does not matter too.

Finally, from the possible list of words, select the one that fulfills your requirements.

In this particular case, the word needs to begin with an ‘R’ and end with an ‘S’ (as noted previously). This directs us to exactly one match: ‘rebus’

That’s it!

That’s your Wordle word of the day solution!

PS. I acknowledge that finding the word that suits your requirements, out of the list of words this app generates, could be a bit of a hassle.

So why not add some more code that will take into account the position of letters in the required word too?

Well, I did not include that functionality because sometimes, you might not have even a single letter in green (a letter whose position in the word is confirmed to be correct). This might have restricted the usage of this app.

So for now, the app seems pretty inclusive of all the use cases! 😊

Happy Wordling!

Streamlit is an open-source Python library using which, in just a few minutes, you can build and deploy your own app. Try for yourself!

You can find the code for this app in my GitHub repo. Feel free to fork it if you have ideas on how it can be improved upon. Connect with me over LinkedIn, or you can also follow my writings here.

Until next time! (∗ ・‿・)ノ

--

--