I'm trying to build a spell checking system in PHP.
I already have a lexicon / corpus of many of the words in the English language. Each word on a new line.
What I'm trying to do is once given a string, let's call it $string1, open the text file and search it for the string most like $string1 and return that string.
For the searching the text file, my idea is to import the contents into an array and then use in_array(). If there is a better way to search the text file without importing all the words into the memory, please let me know.
I don't know how to compare the two strings for similarities. How would I do that?
In my mind, all the same letters but in a different order would rank higher than different letters. But what would rank higher than both would be a partial match +/- a character or two.
I would greatly appreciate any help with opening the text file and searching it and comparing the strings.