How would you go about making a spell checker?

Basically I want to make/learn how to make a spell checker (not for my game, just for fun), but I don’t really know how I should go about it.
Do I have to use HTTPService?
Do I have to require the whole english dictionary or something?
Is it even possible?

Thank you!

Well yeah you’d have to require the whole English dictionary, since something being “spelled right” is entirely subject to the dictionary. You could probably find some sort of Pastebin code or something that is just a table of basically every English word, and then get that with httpservice. Then if a player uses a word which isn’t found in that table, then it’s spelled wrong.

1 Like

And is there any way I would be able to return the correct word and not just tell that it’s spelled wrong?

Well yikes, you’d probably have to iterate through the whole dictionary and use multiple string functions to see how closely a word matches with the one in the dictionary, and then return the word with the closest match.

1 Like

Alright, thank you!

Also one question, sorry if this is off-topic but how would you require a pastebin script?
Like where can I find the id of it to require?

Simple, just do the following

local httpService = game:GetService("HttpService")
local Table = httpService:GetAsync("PASTEBIN URL HERE")
local Dictionary = httpService:JSONDecode(Table)

Dictioanry is your dictionary

1 Like

I think pastebin lets you use a parameter in the query to get the raw text without any of the html.

1 Like

Making an efficient/accurate spell checker isn’t the easiest thing to do. I thought of this implementation on the spot so it might be wrong. You have to first have a list of English words in the correct form. This list will be massive. Then you will have to query your input string to the entire list and find a close match. I have a module for approximate string matching: Simple Fuzzy Search, but it won’t be the most accurate/efficient in this case. The easiest way to find an approximate string is to go through the dictionary linearly (checking one by one) with the module. So the time taken will be dependent on the size of the English dictionary.

3 Likes