![]() ![]() Although it seems like a waste to find all possible words just to return the first one. I changed the code to just return the first word in the array and it did start to work. Perhaps yours had duplicate words such as Miro and miro. I didn't see anywhere in the program where data was ever incremented, except if you had a duplicate word in the dictionary. I suspect the problem was in the function max: if (e & ((int) e->data > max_size)) check mirorįirst off, I ran your program but it didn't ever find any word. ![]() The runtime speeds are faster than the original Python program in the post above, but I feel could still be improved upon. If (!readFile(dictionary, dict)) return -1 Ĭhar *corrected_word = correct(argv) Īs you can see, the accuracy is somewhat low. Void array_cleanup(char **array, int rows) If (fd str_size) || ((offset + limit) > str_size) || (str_size data > max_size)) Int readFile(const char* fileName, ENTRY dict) Refinement: In what ways could I shorten my code down a bit?Ĭhar *dictionary = "/usr/share/dict/words" Ĭonst char alphabet = "abcdefghijklmnopqrstuvwxyz0123456789" įor (char *s = word *s ++s) *s = tolower(*s) Speed: Are there any improvements that could be made to improve runtime speeds? I recently stumbled across this article on how to write a spelling corrector, and figured I'd try to have a go at it in C (mainly because the link at the end of the page for the C code is broken).Īccuracy: What can I do to make the program output a more accurate prediction of what it thinks the correct word should be? ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |