CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

1. Member
Join Date
Jan 2012
Posts
54

## Algorithm for KWIC

hello

i am trying to understand Key word in context (KWIC) algorithm with given example but i am confuse so anybody help me to understand this algorithm with below given example?

1. [Establish loop in which keyword are used as index word]
Repeat through step 5 for i=1,2.....LAST KEY

2. [Obtain index list for current keyword]
KEYSTRING <-- T_INDEX[i] concate with space

3. [Process all title indices in KEYSTRING]
Repeat through step 5 while LENGTH(KEYSTRING) >1

4. [Obtain and delete next title index]
INDEX_NO <-- SUB (KEYSTRING,1,INDEX(KEYSTRING, 'space') -1)
KEYSTRING <-- SUB (KEYSTRING , INDEX (KEYSTRING, 'space') +1)

5. [Obtain and output KWIC line]
KWIC_LINE <-- TITLE [INDEX_NO]
CURSOR < -- 1
if FIND (KWIC_LINE , KEYWORD [i], CURSOR, MATCH_STR) then
KWIC_LINE <-- KEYWORD [i] concate SUB (KWIC_LINE, CURSOR) concate 'space' concate MATCH_STR
Write (KWIC_LINE)
else
Write ('Error')

6. [Finished]
Return

in above algorithm concate means round sign in algorithmic notion n space means it concate with putting space in between sentence
In 5 th step, with if condition FIND is another algorithm...
can explain with any simple example?

2. ## Re: Algorithm for KWIC

Without analyzing too deeply, it appears this algorithm is producing a list like the one shown at: https://en.wikipedia.org/wiki/Key_Word_in_Context

3. Member
Join Date
Jan 2012
Posts
54

## Re: Algorithm for KWIC

yes it generate output like as you said but when i trace this algorithm with some example, algorithm can't trace as said in book.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•