Kwic implemtation...help

This is a discussion on Kwic implemtation...help within the C Programming forums, part of the General Programming Boards category; Hi folks one of the dreaded newbies. I have checked the faq's, and searched all over the place, so hope ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    1

    Unhappy Kwic implemtation...help

    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

    1
    ::
    ignore
    words
    ::
    look in these sentences for ignore words
    another sentence

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

    I need to read the number in..store 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..

    Tia
    Ironbru

    Ach, I am nott that stuupit!

  2. #2
    Rez
    Rez is offline
    Registered User
    Join Date
    Nov 2002
    Posts
    82
    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
    Posts
    1,916
    You're going to love this. It isn't as hard as you're expecting.

    First, check out fscanf here: http://msdn.microsoft.com/library/de...nf_fwscanf.asp

    Then check here:
    http://msdn.microsoft.com/library/de..._functions.asp

    after that, here:
    http://msdn.microsoft.com/library/de..._functions.asp

    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.
    Away.

  4. #4
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,157
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21