Question: Question 2 My word processor Develop a C program which reads and processes an input text file like this textdata.txt. It retrieves the following information


Question 2 My word processor Develop a C program which reads and processes an input text file like this textdata.txt. It retrieves the following information I number of lines number of words number of distinct non-common words non-common words and their frequencies Note that common words, also known as stop words, are words like in this file. The program outputs the retrieved information to a file like this result.txt. Specifically, write C programs myword.h containing the following structure definitions and function headers, and myword.c containing the implementations of the functions. It is required to use your trim() and lower_case() functions from Q1, and it is allowed to use other string functions such as strcpyo. strcat() and strstr() from string library string.h 1. structure definitions: typedef atruct word char word[ 301; int frequency: WORD; typedef struet words WORD word_array(1000); int line_count) int word_count: int keyword_count: 1/ represent the number of distinct non-common words ) WORDSUMMARY, 2. void set_stopword(char *filename, char *stopwords (1) reads stop words from the common word file by filename, and puts them in the stop word dictionary data structure as an array 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. int contain_word (char astr, char *word) checks if the given *word is contained in a given string str, returns 1 if yes and otherwise. For example, if str is "the, this, that", word is "this", then it returns 1. int la stommardi har tomondan char word checks if the given word is contained in 4. int is_stopword (char *stopwords[], char *word) checks if the given word is contained in stop word dictionary char stopwords[], it returns 1 if true otherwise 0. 5. int process_word (char *filename, WORDSUMMARY *words, char *stopwords[]) opens and reads text file of name passed by *filename line by line. For each line, it gets each word, if it is not a stop word, check 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_array and set its frequency 1. Meantime, it updates the count information. 6. int save_to_file(char *filename, WORDSUMMARY *words) saves the data of WORDSUMMARY words to file of name passed by filename in specified format. Use the provided main function file myword_main.c to test your programs as the following. If common-english-words.txt and textdata.txt are used, then output file is like this result.txt Question 2 My word processor Develop a C program which reads and processes an input text file like this textdata.txt. It retrieves the following information I number of lines number of words number of distinct non-common words non-common words and their frequencies Note that common words, also known as stop words, are words like in this file. The program outputs the retrieved information to a file like this result.txt. Specifically, write C programs myword.h containing the following structure definitions and function headers, and myword.c containing the implementations of the functions. It is required to use your trim() and lower_case() functions from Q1, and it is allowed to use other string functions such as strcpyo. strcat() and strstr() from string library string.h 1. structure definitions: typedef atruct word char word[ 301; int frequency: WORD; typedef struet words WORD word_array(1000); int line_count) int word_count: int keyword_count: 1/ represent the number of distinct non-common words ) WORDSUMMARY, 2. void set_stopword(char *filename, char *stopwords (1) reads stop words from the common word file by filename, and puts them in the stop word dictionary data structure as an array 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. int contain_word (char astr, char *word) checks if the given *word is contained in a given string str, returns 1 if yes and otherwise. For example, if str is "the, this, that", word is "this", then it returns 1. int la stommardi har tomondan char word checks if the given word is contained in 4. int is_stopword (char *stopwords[], char *word) checks if the given word is contained in stop word dictionary char stopwords[], it returns 1 if true otherwise 0. 5. int process_word (char *filename, WORDSUMMARY *words, char *stopwords[]) opens and reads text file of name passed by *filename line by line. For each line, it gets each word, if it is not a stop word, check 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_array and set its frequency 1. Meantime, it updates the count information. 6. int save_to_file(char *filename, WORDSUMMARY *words) saves the data of WORDSUMMARY words to file of name passed by filename in specified format. Use the provided main function file myword_main.c to test your programs as the following. If common-english-words.txt and textdata.txt are used, then output file is like this result.txt
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
