heap - Check Spelling program in C -
I'm beginning to c programming I want to learn how to codify a spell checker, which is all in a dictionary file Look at the words, compare them with an article, print all the words on the console that are not present in the dictionary file. Since I'm studying malloc in class, I have reduced every word, removed all punctuation in the article, and the string copies them into malloc. I do not know what the next step should be, will someone give me the signal ? Thanks
MAIN.C
#include & lt; Stdio.h & gt; # Include & lt; Stdlib.h & gt; Four dictionaries [1000000]; Four articles [100000]; Zero spell check (four [], four []); Int main (zero) {FILE * dict_file; File * article_file; Int bytes_read; Four * p; Dict_file = fopen ("American-English .txt", "r"); If (dict_file == 0) {printf ("Unable to open dictionary file" "American-English. Txt \" \ n "); return -1;} Article_file = fopen (" article.txt "," r "); P = fgets (p, 100,), (if you are unable to open the file "article.txt \" \ n "); return -1;} / * reading dictionary * / p = dictionary; Dict_file); while (p! = 0) {while (* p! = '\ 0') {p + = 1;} P = fgets (p, 100, dict_file);} / * read article * / p = article ; Bytes_read = fread (p, 1, 1000, article_file); P + = bytes_read; while (bytes_read! = 0) {bytes_read = fread (p, 1, 1000, article_file); P + = bytes_read;} * P = 0 ; Spell check (article, dictionary);}
PROJECT.C
zero spell check Article [], four dictionaries []) {int len = strlen (article) + 1; int i; char * tempArticle; TempArticle = Mallow (lane); If (tempArticle == NULL) {printf ("Spell check: (I = 0; i & lt; len; i ++) tempArticle [i] = toller (article [i]); i = 0; while (article [ I]! = '\ 0') {if (article [i] & gt; = 33 & amp; Article [i] & lt; = 64) article [i] = ''; } Printf ("% s", tempArticle); Free (tempArticle); }
How important will you organize your data structures?
You just do not want to put your dictionary in binary tree, as Zareth has mentioned, but do so with the article, so that you can remove all the fake words and sort them Are there.
In this way, when you start searching through the dictionary, you can leave if you go before words that start with your word, because the dictionary is sorted.
Comments
Post a Comment