Assignment 2: Text Processing
Introduction
Text is a very important part of the data that computers deal with. In this assignment you are going to learn two things: how to process text (the first step in understanding language) and how to write code in small, bite-size portions: functions!
Functionality
Once again you will write your programs in increasingly more powerful pieces. But unlike the first assignment you will only produce two main programs and a number of functions. The number of functions that you write correctly will determine your grade.
Remember the wcount.c program in the textbook and in class. You will find a related program in the file textRW.c. In the original program, the text was read in a character at a time. The program textRW.c reads in text, one line at a time. The program assumes that no line contains more than 500 characters. Your code will not be tested on text that violates this constraint.
To test out textRW do the following:
$ make textRW
$ cat verneTest.txt | ./textRW
Produce the following functions that will work on a single line of text:
int chop ( char *line )
Remove the ‘\n’ from the end of the line.
Returns 0 if successful and -1 on
int convertLowerCase ( char *line )
Convert all alphabetic characters to lower case (do not use the tolower()
function in the string library for C or your grade will be zero for this function).
Returns the number of characters converted from upper case to lower
int replaceDigits ( char *line )
Replace the all numbers/digits (0-9) with
Returns the number of digits replaced with
int replacePunc ( char *line )
Replace all punctuation and symbols with blanks. A list of all punctuation and symbols appears in the Information section of this
Returns the number of punctuation and symbols replaced with
int reduceSpace ( char *line )
Reduce all white space (blank characters and tabs to a single blank space).
Returns the number of white spaces
int trim ( char *line )
Trim all white space from the beginning and from the end of each
Returns 0 on success and -1 on
Now compile the program findWords.c with your functions using Makefile and run this against the test file called verneTest.txt.
$ make findWords
$ cat verneTest.txt | ./findWords
Your output should look like the output in file resultsVerne.txt.
The findWords program has found all the words in the file that are greater than 5 characters in length.
Now run the following pipeline:
$ cat verneTest.txt | ./findWords | sort
The output should look like the output in file sortedResultsVerne.txt.
Your last task is to write a program called wordBag.c that prints out all the unique words produced by the previous pipeline with their counts (number of times that they occur). The output will look like the output in file countsResultsVerne.txt.
Now run the following pipelines:
$ cat verneTest.txt | ./findWords | sort | ./wordBag
$ cat verneTest.txt | ./findWords | sort | ./wordBag | sort - gk1,1r -gk2,2
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of