Thread: Reading and correcting.

  1. #1
    Registered User
    Join Date
    Feb 2008

    Reading and correcting.

    Hi somewhat of a beginner to c so forgive me if my questions seem basic.

    I want to write a program to read in text from a file and correct it according to certain rules. Ive got a file containing alot of text and id like to write code which can correct simple things like first letters in sentences should begin with capital letters and end with full stops etc.

    Then output the corrected text.

    Can anyone shed some light on how to construct this?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Step 1 would appear to be to teach your program how to read <<language of your choice>>. For instance, how would the program know where an English sentence ends, if it doesn't end in a full stop or similar already? (You wouldn't want your program to put a period before "English" in the sentence above.)

  3. #3
    Registered User
    Join Date
    Feb 2008
    I know what you mean. The text is english, and contains fullstops after most sentences, but contains alot of other characters like ')* etc which need to be removed aswell.

    I was thinking down the lines getting the program to read in a character at a time and change them accordingly (If anything needed to be changed of course). But im not sure where to start.

  4. #4
    uint64_t...think positive xuftugulus's Avatar
    Join Date
    Feb 2008
    It appearss you will have to be able to track state of reading to perform your requested feat.
    For example, when you read a '.' character, any number of whitespace is permitted to be there for a sentence to be proper.
    The quick brown fox.
    jumped the fence.
    It most certainly is valid for a sentence to end on a new line character no? And a paragraph begins below.
    I won't go in more detail, but your assignment might not be as easy as it might have sounded.
    Parsing text for "features" and "correcting" unwanted ones, is not so trivial a task.
        goto johny_walker_red_label;
    johny_walker_blue_label: exit(-149$);
    johny_walker_red_label : exit( -22$);
    A typical example of programming practices.

Popular pages Recent additions subscribe to a feed