Sponsored Content
Full Discussion: Help With spell checking
Homework and Emergencies Homework & Coursework Questions Help With spell checking Post 302508174 by disaster on Saturday 26th of March 2011 10:10:20 AM
Old 03-26-2011
First of all, you make a common mistake: getchar() returns an int and not a char. This may cause errors in the != EOF condition
Ok, so here's my short approach I would be taken, no guarantuee that it works though Smilie

Code:
int c;
int iscorrect = 1;
int inword  = 0;
int lastvowel = 0; // if it is 1, the previously read char was a vowel
while((c = getchar()) != EOF) {
        if(delimitp((char) c)) {
                if(inword) { // end of word reached
                        (iscorrect == 1 && lastvowel == 1) ? printf(" correct word\n"); : printf(" wrong word\n"); // word had to be correct and the char in front of the delimit had to be vowel
                        inword = 0;
                        iscorrect = 1; //reset
                } else // two or more delimiters, ignore them
                        continue;
        }
        if(!letterp((char) c)) { //word is def wrong
                inword = 1;
                iscorrect = 0;
                putchar(c);
                continue;
        }
        if(!inword) { //first char of word, so we don't check adjacent consonsants here
                inword = 1;
                iscorrect = 1; //we accecpt consonants and vowels here. all other got kicked of in the if before - prob obsolute because we reset it at the delimiters
                if(vowelp((char) c))
                        lastvowel = 1;
                else
                        lastvowel = 0;
                putchat(c);
        } else {
                if(!vowelp((char) c) && lastvowel = 0) //adjacent consonants
                        iscorrect = 0;
                putchar(c);
        }
}

So, I hope this gets the job done Smilie Just a quick summary: First we check for delimiters. If it is the first delimiter and the last char was a vowel (and the word was correct to this point) it is correct. More limiters get ignored.
Then we check what else is there: If it is not a letter, the word is def wrong. But still we put it out.
If it is the first char of a word, we don't care it it is a vowel or consonant, both is ok. But we still need to check so we are able to check for adjacent consonants. This is done via lastvowel.
This User Gave Thanks to disaster For This Post:
 

6 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Spell Check

Administrator/Moderators, I would like to put forth a request rather a suggestion in other words. How about the inclusion of 'SPELL CHECK' tool along with existing submit reply and preview post tools? I believe that would be very much helpful in understanding questions clearly deprived of... (2 Replies)
Discussion started by: matrixmadhan
2 Replies

2. UNIX for Advanced & Expert Users

spell

Hi, I found the following line in a shell script. $spell -a < $filename | \ grep -v '@(#)' | sed "s/\'//g" | \ awk '{ if (length($0) > 15 && length($2) > 2) print $2 }' | \ grep -vif $okaywords | \ grep ']' | grep -v ']' | sort -u | \ sed 's/^/ /' > $tempout can... (2 Replies)
Discussion started by: ravi raj kumar
2 Replies

3. UNIX for Dummies Questions & Answers

spell check

# cat wrong.txt thiis is going to be wrong words containing file # aspell list < wrong.txt thiis I want to check only one word and see the first suggestions ("this" in this case). something like... aspell list --one-word thiis --suggest (5 Replies)
Discussion started by: shantanuo
5 Replies

4. Shell Programming and Scripting

spell check program

hi, i need to write a spell check program in bash to find all possible spelling errors in a file or a number of files taken as input using usr/dict/words. whenever the program encounters a spelling error, it must state the line number at which the incorrect spelling has occured and... (1 Reply)
Discussion started by: kratos.
1 Replies

5. Shell Programming and Scripting

Spell Check

I have this assignment and I am not sure how to start it, I am new any help will be appreciated.... (BASH) Let us say a test is conducted to assess the typing speed for applicants. We need to count # of correctly spelled words and penalize for incorrectly spelled words. score = (# of... (1 Reply)
Discussion started by: shilling
1 Replies

6. Debian

Getting a better spell checker

Guys I am new to Linux in general and want to know what is the use of the following files-: /usr/share/dict/words /usr/share/dict/words.pre-dictionaries-common Are they used by the spell checker to find potential typos ? If so are there any better larger word lists out there ? I am sure... (2 Replies)
Discussion started by: sreyan32
2 Replies
thai/thwctype.h(3)						      libthai							thai/thwctype.h(3)

NAME
thai/thwctype.h - Thai wide-char character classifications. SYNOPSIS
Functions int th_wcistis (thwchar_t wc) Is the wide character convertible to a valid TIS-620 code? int th_wcisthai (thwchar_t wc) Is the wide character a Thai character? int th_wciseng (thwchar_t wc) Is the wide character an English character? int th_wcisthcons (thwchar_t wc) Is the wide character a Thai consonant? int th_wcisthvowel (thwchar_t wc) Is the wide character a Thai vowel? int th_wcisthtone (thwchar_t wc) Is the wide character a Thai tone mark? int th_wcisthdiac (thwchar_t wc) Is the wide character a Thai diacritic? int th_wcisthdigit (thwchar_t wc) Is the character a Thai digit? int th_wcisthpunct (thwchar_t wc) Is the character a Thai punctuation? int th_wcistaillesscons (thwchar_t wc) Is the wide character a Thai consonant that fits the x-height? int th_wcisovershootcons (thwchar_t wc) Is the wide character a Thai consonant with stem above ascender? int th_wcisundershootcons (thwchar_t wc) Is the wide character a Thai consonant with stem below baseline? int th_wcisundersplitcons (thwchar_t wc) Is the wide character a Thai consonant with split part below baseline? int th_wcisldvowel (thwchar_t wc) Is the wide character a Thai leading vowel? int th_wcisflvowel (thwchar_t wc) Is the wide character a Thai following vowel? int th_wcisupvowel (thwchar_t wc) Is the wide character a Thai upper vowel? int th_wcisblvowel (thwchar_t wc) Is the wide character a Thai below vowel? int th_wcchlevel (thwchar_t wc) Position for rendering: Detailed Description Thai wide-char character classifications. Function Documentation int th_wcchlevel (thwchar_twc) Position for rendering: o 3 = above/top o 2 = top o 1 = above o 0 = base o -1 = below int th_wcistis (thwchar_twc) Is the wide character convertible to a valid TIS-620 code? TIS-620 here means US-ASCII plus TIS-620 extension. Author Generated automatically by Doxygen for libthai from the source code. Version 0.1.14 Tue Jun 17 2014 thai/thwctype.h(3)
All times are GMT -4. The time now is 04:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy