Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 2. Develop a C program which rcads and processes an input text file like this textdata.tx. It retrieves infomation mumber of lines, umber of

image text in transcribed

Question 2. Develop a C program which rcads and processes an input text file like this textdata.tx. It retrieves infomation mumber of lines, umber of all words, mumber of distinct noa-ommon words non-common words and their frequencies. Note that common words, are also known as stop words, like words in this fils). It outputs the retrieved information to a file like this cailt.txt. Specifically, write C source programs mwordh and myword.e containing the following: 1. struchure definitions: typedef struct ard char Nord[se]; int frequney MORn typedef struct words t WORD word arry[18881 int keyaord count 2. void set stopword(char *ilename, char *stupodsL); this functious reads stop words from the coo word file by fileae ad puts thei the stop word dictionary data structure as au aTay of 26 strings, each string holds all stop words starting with the same alphabet, separated by comma"". The array of strings is passed parameter char *stopwords[], stopwords[i] holds the pointer of the i-th string. 3 nt contain ord char * topwords char * ord); thisfunction checks fthe given on 15 contain din stop ( ctiona char stop words it returns l if true otherwise O 4. int str_contain_word (char *str, char *word); this checks if the given word is contained in a given string str, returns 1 if yes and 0 otherwise. For example, if str is the,this,that", word is "this", then it returns 1 5. int process_word (char *filename, WORDSUNMARY *words, char stopwords[]); this function opens and reads text file of name passed by filename line by lie. For cach line, it gets cach word, if it is not a stop word, chock if it is already in array words-word array, if yes, increases its frequency by 1. otherwise inserts it to the end of the word_aray and set its frequency 1. Meantime, it updates the count infomation 6. int save to tile char *filename, WORDSUMMARY * ords) ; this saves the data ofwORDSUMMARY words to file ofname passed by filenan e in specified format. 7. Lise the provided main function file a4q2.c to test your programs as the following. public test iq? textdats.txt result.txt rom-elih-rdetx Question 2. Develop a C program which rcads and processes an input text file like this textdata.tx. It retrieves infomation mumber of lines, umber of all words, mumber of distinct noa-ommon words non-common words and their frequencies. Note that common words, are also known as stop words, like words in this fils). It outputs the retrieved information to a file like this cailt.txt. Specifically, write C source programs mwordh and myword.e containing the following: 1. struchure definitions: typedef struct ard char Nord[se]; int frequney MORn typedef struct words t WORD word arry[18881 int keyaord count 2. void set stopword(char *ilename, char *stupodsL); this functious reads stop words from the coo word file by fileae ad puts thei the stop word dictionary data structure as au aTay of 26 strings, each string holds all stop words starting with the same alphabet, separated by comma"". The array of strings is passed parameter char *stopwords[], stopwords[i] holds the pointer of the i-th string. 3 nt contain ord char * topwords char * ord); thisfunction checks fthe given on 15 contain din stop ( ctiona char stop words it returns l if true otherwise O 4. int str_contain_word (char *str, char *word); this checks if the given word is contained in a given string str, returns 1 if yes and 0 otherwise. For example, if str is the,this,that", word is "this", then it returns 1 5. int process_word (char *filename, WORDSUNMARY *words, char stopwords[]); this function opens and reads text file of name passed by filename line by lie. For cach line, it gets cach word, if it is not a stop word, chock if it is already in array words-word array, if yes, increases its frequency by 1. otherwise inserts it to the end of the word_aray and set its frequency 1. Meantime, it updates the count infomation 6. int save to tile char *filename, WORDSUMMARY * ords) ; this saves the data ofwORDSUMMARY words to file ofname passed by filenan e in specified format. 7. Lise the provided main function file a4q2.c to test your programs as the following. public test iq? textdats.txt result.txt rom-elih-rdetx

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

:r5y2 Problem 2. Solution. Using polar coordinates, calculate lim

Answered: 1 week ago