Due by 11:59.59pm Friday March 31 2017
Note: You may work with a partner on this project. Let me know who you are working with (along with a team name and desired repository name), and I'll set up a shared private GitHub repository for this assignment. As there are a number of components to this assignment, I'd encourage you to get started before the last minute.
Also go through the interactive GitHub tutorial if you have not done so.
For this assignment create a program pig that will read in English text and translate it into Pig Latin. In particular you'll be working with strings in C.
Pig Latin is used by both adults and children to obfuscate what they are saying from the other. Some of you might have toyed around with the language yourself as a child.
For this assignment, you'll be creating two programs: pig and unpig. pig will read in English text and convert it into pig latin. unpig will do the opposite and will take in text in Pig Latin and convert it back to English.
There are a couple of varying rules to Pig Latin. For this assignment, we'll be using the following:
Rule 1:If the string begins with a vowel (that is begins with 'a', 'e', 'i', 'o', or 'u') add "yay" to the end of the string.
Rule 2:Otherwise, find the first occurance of a vowel, then move all the letters before the vowel to the end of the word and add "ay".
Note:"y" should be considered a vowel in this context.
You can consider a word to be a consecutive sequence of letters (A-Z, a-z). "y" should be treated as a consonant if it is the first letter of the word but as a vowel otherwise.
In addition to modifying the words as specified above, your program should also respect the following rules:
Some dialects of pig latin say that you should move "silent" letters to the end as well (such as in the word knife). You can ignore contraction words (don't).
In general, the words will be translated as follows: Linux -> Inuxlay yes -> esyay example -> exampleyay
Some guidelines you should follow when working on your solution:
You'll want to think about how to breaks this program into its component parts.
Additionally, I'd like you to implement a -h and -? flag that prints out a brief usage message and exits the program with a non-zero value. You should do the same if an unknown flag is passed to the program.
You should have your program's main function return 0 upon successful completion of the assigned task.
You'll also be creating a man page to accompany your tool. Man pages are simply text files that have some additional annotations with formatting instructions -- somewhat similar to LaTeX if you've encountered that as well.
Traditionally, the tool nroff was used to do typesetting of man pages. These days, many systems now have groff and just have nroff as an alias to groff. You can get more info on the various options by seeing the manpage groff_man(7).
At a minimum, you will need to know the following macros (all go at the start of the line).
.\" Sample man page for CSCI 241 .\" Roberto Hoyle - Spring 2017 .TH sample_man 1 "05 March 2017" "CSCI 241" "Oberlin College" .SH NAME .B sample_man \- an example of a sample man page .SH SYNOPSIS .B sample_man [ -o outputfile ] <filename> .SH DESCRIPTION Does everything a sample man page should do. .SH OPTIONS .IP "-o outputfile" Do things to be written to an output file. .SH AUTHOR Roberto Hoyle (Spring 2017) .SH BUGS None!
You can also see/download a longer version.
You should name your file based on the standard convention <name_of_program>.<manual_section>. So for the above page, it would be sample_man_page.1. (Recall that section 1 is user commands.)
To view the processed man page use either of the following commands:
Here is the HTML version of above:
sample_man(1) Oberlin College sample_man(1) NAME sample_man - an example of a sample man page SYNOPSIS sample_man [ -o outputfile ] <filenames> DESCRIPTION Does everything a sample man page should do. OPTIONS -o outputfile Do things to be written to an output file. AUTHOR Roberto Hoyle (Spring 2017) BUGS None! CSCI 241 05 March 2017 sample_man(1)
Create a file called README that contains
Now you should make clean to get rid of your executables and handin your folder containing your source files, Makefile, and README.
% cd ~/cs241 % handin -c 241 -a 5 hw5 % lshand
Here is what I am looking for in this assignment: