Haiku generating app in Python

// I’ll increase budget upon requestWrite a program that generates simple haiku poems according to these rules.• Each line of the poem is a single sentence.The first line and the third line will each be 5 syllables.The second line will be 7 syllables.Each line relates to the indicated theme.Modify a copy of the file linuxwords.txt as follows:ª Choose at least 100 words of the file, including several words in each of these parts of speech: article (a, an, the), adjective other than article, noun, verb, an article. (It’s ok to include conjustions, prepositions, and pronouns, but that willl make your grammar larger.* Choose at least 3 themes (ex. autumn, food, weather).For each word other than an article (or conjunction or prepositon or prounoun), add to the entry in your modified linuxwords.txt the number of syllables, a “part of speech,” and one of the three themes.For example, you might have these entries:tree, 1, noun, autumntrees, 1, noun, autumnleaf, 1, noun, autumnleaves, 1, noun, autumnbonfire, 2, noun, autumnHalloween, 3, noun, autumnHalloween, 3, adjective, autumnsee, 1, verb, autumnI, 1, article, autumnred, 1, adjective, autummorange, 2, adjective, autumnFrom these words your program might generate the sentence:I see orange leaves.* Write at least three rules for sentences.For example, your rules might include: ::= ::=

* Your program should input a theme (“august” in this example) and generate at least five random hiakus.what I have so far for the app is attached in a pdf file the implementation has to be in Python

Don't use plagiarized sources. Get Your Custom Essay on
Haiku generating app in Python
Just from $13/Page
Order Essay

Unformatted Attachment Preview

import nltk
from nltk.corpus import cmudict
from nltk.corpus import wordnet
from random import randint
proDict = cmudict.dict()
#Abbreviation to full form, for the POS determined by “synsets”
posDict = {‘n’: ‘NOUN’,’v’: ‘VERB’, ‘a’: ‘ADJECTIVE’, ‘s’: ‘ADJECTIVE’, ‘r’: ‘ADVERB’}
#The theme for which words are generated
#This method counts the number of Syllables in a word
#It uses cmudict.dict(), which is a pronounciation dictionary
def countSyllables(word):
global posDict
return max([len([y for y in x if y[-1].isdigit()]) for x in proDict[word]])
#It creates a record for given word and theme
#Just like what is mentioned in the question
#e.g “Halloween, 3, noun, autumn”
def getRecordFor(word,theme):
global posDict
themeNet = wordnet.synsets(theme)[0]
maxMatch = -1
#Using synsets to compare all the word POS forms,
#And to choose the one with best match with the theme
for candidate in wordnet.synsets(word.lower()):
matchP = candidate.wup_similarity(themeNet)
#Sometimes wup_similarity() can return “None”
#Hence needed to be checked for type
if isinstance(matchP,float):
if matchP > maxMatch:
finalToken = candidate
maxMatch = matchP
#Extracting POS abbreviation
temp = finalToken.name().split(‘.’)
#Getting the full name of that abbreviation
pos = posDict[temp[1]]
#Creation of record
result = []
return result
#Begins here
#Extract all words from file, remove any newline or feed characters
with open(“linuxwords.txt”) as file:
for word in file:
#From the list of words, extract random 150 words
#Just for testing purposes, reducing the value to 10
while len(randomWordsList) < 10: index = randint(0,len(allWordsFromFile)) word = allWordsFromFile[index] #These words must be in the dictionary, so as to be helpful if word in proDict: randomWordsList.append(word) del allWordsFromFile[index] #All records go here wordListFormatted=[] #Generating all records for word in randomWordsList: wordListFormatted.append(getRecordFor(word,inputTheme)) print(wordListFormatted) ... Purchase answer to see full attachment

Order a unique copy of this paper
(550 words)

Approximate price: $22

Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
The price is based on these factors:
Academic level
Number of pages

Order your essay today and save 15% with the discount code ESSAYHELP