Thread: Kwic

  1. #1
    Registered User
    Join Date
    Jun 2003

    Unhappy Kwic

    Hi folks one of the dreaded newbies. I have checked the faq's, and searched all over the place, so hope some one can help.

    I have to implement a KWIC (Keyword in Context) program in C
    I have completed this in Perl, as the first part and now have to redo in C. My input is in a file like this

    look in these sentences for ignore words
    another sentence

    This produces 3 seperate fields, divided by "::"

    I need to read the number it..easy

    I need to read in "::" and check to see if it is one..and disregard it

    1. One problem I am having is how do I check characters against others?

    2. Another, how do I get it to loop until it reaches the second set of "::" ?

    3. The trickiest stuff the kwic index... Need to split up sentences,and check against each word for existence of keywords.

    4. Also tricky, after keyword is identified, how do I replace it in the proper place in capitalized form.

    Any advice appreciated. Esp on input and array manipulation..


    Ach, I am nott that stuupit!

  2. #2
    Registered User
    Join Date
    Nov 2002
    If you can do it in Perl, then there's no reason you can do it in C Just review your Perl source and try to look into C's "string.h" library. Lots of string maniputlation functions there.

  3. #3
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    You're going to love this. It isn't as hard as you're expecting.

    First, check out fscanf here:

    Then check here:

    after that, here:

    I think that's all you really need to do the first few parts. Then you'll need some string comparision functions...look up the STL functions, run a board search for them, or I'm sure someone here will help you. I don't know them myself For #4 though... not sure what you mean, but Toupper() will capitalize a letter for you.

  4. #4
    Been here, done that.
    Join Date
    May 2003
    Originally posted by blackrat364
    You're going to love this. It isn't as hard as you're expecting.

    First, check out fscanf here: ...
    You'll probably be better off using fgets() instead. The scanf() family have trouble returning all the data if not used properly whereas fgets() will return one full line from the file.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed