Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Keyword Out of Context Program (KWOC) Goal is to find all locations of where the word appears. The concordance we want will relate words to

Keyword Out of Context Program (KWOC)

Goal is to find all locations of where the word appears. The concordance we want will relate words to the lines in which they appear in a text file being processed.

For example an input file contains:

the fish a dog cat dog rabbit

the fish and cat

a rabbit or elephant

The desired output is:

CAT the fish a dog cat dog rabbit (1)

CAT the fish and cat (2)

DOG the fish a dog cat dog rabbit (1*)

ELEPHANT a rabbit or elephant (3)

FISH the fish a dog cat dog rabbit (1)

FISH the fish and cat (2)

RABBIT the fish a dog cat dog rabbit (1)

RABBIT a rabbit or elephant (3)

Where the keyword appears in all uppercase followed by the line it was in and the line number in parentheses. The star next to the one on line 3 represents that the words occurs more than once in that line. Note: the longest keyword determines how input lines are indented (length of longest keyword + two spaces).

Some words are not included as keywords. A file with exclusion words is given on the command line via the -e argument. You must read the contents of the input file for which an index is needed then determine the unique words in that file and finally read the words in the exclusion file to remove those words from the set discovered previously.

Input files are all lower-case and all words on a line are separated by a single space (no other punctuation). Each input file will have at most 100 lines, input lines at most 80 characters long (including spaces and newline character), no words longer than 20 characters, no more than 500 unique keywords (a specific keyword may appear many times).

Notes: Use -std=c99 when compiling. The order that the files will be typed on command line is not fixed (the input file could be first or the exception file), but the exception file will always be preceded by '-e'.

Exclusion-word files will have one word per line, and lines will be in alphabetical order. Files with exception words will have no more than 100 lines (one word per line).

Output is to standard output (command line screen). Program must be written in C without the use of dynamic memory.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions