Starting from:

$30

Assignment 1 HAIKU-IZE

Assignment 1
HAIKU-IZE
"Haiku" is a traditional form of Japanese poetry. Haiku poems consist of 3 lines. The first and
last lines of a Haiku have 5 syllables and the middle line has 7 syllables.
Here are three examples of haiku poems from Matsuo Basho (1644-1694), considered the
greatest haiku poet:
An old silent pond...
A frog jumps into the pond,
splash! Silence again.
Autumn moonlighta worm digs silently
into the chestnut.
In the twilight rain
these brilliant-hued hibiscus -
A lovely sunset.
PART A:
In this assignment, you will write a program (suggested name haikuize.cpp) to examine a line of
English text and attempt to “haiku-ize” it. As mentioned above, haiku relies heavily on the
number of syllables of a given English sentence. The following are guidelines to determine the
number of syllables of a given word:
a. A word consists of a maximal string of alphabetic characters (upper and/or lower-case),
followed by zero or more non-blank, non-alphabetic characters. NOTE: Upper/lower case
distinctions and non-alphabetic characters are ignored for the purpose of counting
syllables, but must be retained in the final output.
b. The characters ‘A’, ‘E’, ‘I’, ‘O’, ‘U’, ‘Y’ are vowels. Other alphabetic characters are
consonants. EXCEPT: ‘QU’ is a single consonants and ‘Y’ is a consonants if
immediately followed by one of the other vowels.
c. Every word has at least one syllable.
d. Each word of one or more consonants with at least one vowel to either side indicates a
division into separate syllables. EXCEPT:
i. An “E” appearing as the last alphabetic character in a word is silent and should be
ignored unless the next-to-last alphabetic character is an “L” and the character
immediately before that is another consonant. For example, “ale” and “pale” have one
syllable. “able” has two.
ii. An “ES” sequence at the end of the alphabetic sequence in a word does not add a
syllable unless preceded by two or more consonants. For example, “ales” and “pales”
have one syllable. “witches” and “verses” have two.
Input
You will create an input file named sentences.txt. Input to your program will consist of a series
of lines of text consisting of a sequence of one or more words (as defined above) separated by
single spaces. The total line length will not exceed 200 characters.
Output format
You will create an output file named haiku.txt.
If the words in a given input line can be divided into a haiku, then print the haiku as three lines of
output.
• Each line should be left-justified.
• A single space should separate each pair of words within a line.
• Each word should appear exactly as it does in the input, preserving case and any terminal
non-alphabetic characters.
• Do not split a word across multiple lines.
If the words in the input cannot be divided into a haiku, print the line of input with no changes.
Sample Input
An old silent pond … A frog jumps into the pond, splash! Silence again.
Programming is fun!
Sample Output
An old silent pond...
A frog jumps into the pond,
splash! Silence again.
Programming is fun!
PART B:
Use the given file word.txt (61000 words).
Write a program (suggested name haikugenerator.cpp) that randomly generates a “beautiful”
haiku. For example,
international
amazing printer slowly
dead ham no more wine
NOTE:
- Please include the following block at the beginning of your program
/*
Name:
Class: CECS 282
Instructor: Minhthong Nguyen
Purpose of the program:
Last updated:
*/
- Comment your code.
- Follow standard style for coding.

More products