Computer Science Homework Help

CMPSC 131 Haiku Generator Signboard Banging Python Lab Report

 

Project 3 – Haiku Generator

Introduction

Haiku is a traditional Japanese poem form consisting of three lines where the first and last lines contain five syllables and the second line has seven syllables. The subject of the poem is often nature. Here is an example of haiku by Richard Wright:

Whitecaps on the bay

A broken signboard banging

In the April wind

Problem Definition

You are asked to design, implement, debug, document, and test a Python script that inputs words from text files and “randomly” generates a haiku which conforms to this format:

five syllables

seven syllables

five syllables

There are two input text files:

1) A file that contains five-syllable lines: fivesyll.txt

2) A file that contains seven-syllable lines: sevensyll.txt

Your script should read the lines from each file into two different lists and then randomly select a five syllable line, a seven syllable line, and a five syllable line to form a haiku and display on the screen. Some of the poems may be nonsensical, but all will be interesting!

Your script should allow the user to generate as many haikus as desired. It must also give the user the option of saving a poem to an output file.

Additional notes:

Use of functions in project 3 is required.

Required deliverables for Project 3 are the Python script (.py) and a sample output file containing at least two haikus generated by your program (.txt)

Extra credit: Write an original technology-themed haiku in 5-7-5 and submit with the rest of the project deliverables by April 30 at 11:59 p.m. If approved, you will earn five bonus points on Project 3.