Question: Write a C program, problem1.c, to read in a text file, called text.txt, and build a concordance file, called concordance.txt, for the file showing the

Write a C program, problem1.c, to read in a text file, called text.txt, and build a concordance file, called concordance.txt, for the file showing the number of unique words, the unique words, and the number of times each unique word occurs in the text file. A word only has alphabetic characters. Test your program with text.txt files of differing contents.

Example:

i. Text File text.txt (test empty, one word, and larger text files)

-1. A concordance of a text file is an alphabetical list of the unique words in the text file.

ii. Concordance File concordance.txt

1. There are 13 distinct words in the text file:

2. a 2

3. alphabetical 1

4. an 1

5. concordance 1

6. file 2

7. in 1

8. is 1

9. list 1

10. of 2

11. text 2

12. the 2

13. unique 1

14. words 1

b. Use an ordered linked list to store the words and keep a count of the number of times each word occurs in the text file.

i. The linked list operations, such as insert, search, and others, should be written as separate functions.

ii. The head of the list should be a pointer that points to the first node in the linked list.

iii. In the above example, head should point to the list node containing a and 2.

c. The main function should be a driver to call other functions to perform the required tasks to build a concordance and store the concordance to the file concordance.txt.

i. No global variables should be used but define macro constants and typedefs may be used.

ii. The C library files string.h and ctype.h may be used, but please use the safe string operations, such as strncmp in string.h.

d. After the linked list of words is built and concordance.txt is made, delete the stop words in the file stopwords.txt from the list one at a time. Then output a new concordance file called concordance_wo_stop_words.txt. Test your program with stopwords.txt files of differing contents and order of stop words.

i. Stop words file stopwords.txt (test empty, one word, and larger stop word files)

1. a

2. of

3. in

4. an

5. the

ii. Concordance File concordance_wo_stop_words.txt

1. There are 8 distinct words in the text file:

2. alphabetical 1

3. concordance 1

4. file 2

5. is 1

6. list 1

7. text 2

8. unique 1

9. words 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!