Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Base on the code in the picture. Pick any Poem or song lyrics and using the code in the picture as your input. Make sure
Base on the code in the picture. Pick any Poem or song lyrics and using the code in the picture as your input. Make sure it running in the end. The language is python. Thank you.
strHoracePoem = ""Much to his Mum and Dad's dismay, 2 Horace ate himself one day. He didn't stop to say his grace, He just sat down and ate his face. 5 "We can't have this!" His Dad declared, "If that lad's ate, he should be shared." 7 But even as they spoke they saw, 8 Horace eating more and more: 9 First his legs and then his thighs, 10 His arms, his nose, his hair, his eyes... 11 "Stop him someone!" Mother cried, "Those eyeballs would be better fried!" But all to late, for they were gone, 14 And he had started on his dong... 15 "Oh! foolish child!" the father mourns, 16 "You could have deep fried that with prawns, 17 Some parsely and some tarter sauce..." 18 But H. was on his second course: 19 His liver and his lights and lung, 20 His ears, his neck, his chin, his tongue; "To think I raised him from the cot, And now he's going to scoff the lot!" 23 His Mother cried: "What shall we do? 24 What's left won't even make a stew..." 25 And as she wept her son was seen, 26 To eat his head, his heart, his spleen. 27 And there he lay, a boy no more, Just a stomache, on the floor... 29 None the less, since it was his, 30 They ate it - that's what haggis is."" 31 37 strHoracePoemWIP = strHoracePoem.replace 38 strHoracePoemWIP = strHoracePoemWIP.replace("Dad's", "Dad") 39 strHoracePoemWIP = strHoracePoemWIP.replace("didn't","did not").replace("m"," am").replace("'s'," is").replace("d"," would").replace("won't","would not") 40 strHorace PoemWIP strHoracePoemWIP.replace(","," ").replace("?","").replace("!","") 41 strHoracePoemWIP = strHorace PoemWIP.replace(":","").replace(";","") 42 strHoracePoemWIP = strHoracePoemWIP.replace(".","").replace("...","").replace(" - "," ") 43 strHoracePoemWIP = strHoracePoemWIP.lower) 44 45 listHoracePoem = strHorace PoemWIP.split() 46 setHoracePoem = set(lstHorace Poem) 47 48 # Demo Stopwords 49 #1stHoracePoem.remove("to") 50 #lstHoracePoem.remove("and") 51 52 #Demo Sets and Stopwords 53 #1stHoracePoem = strHoracePoemWIP.split() # Reset 54 #setHoracePoem = set(1stHoracePoem) 55 #setStopwofds = ("to", "and") 56 #setHorace Poem = setHoracePoem.difference(setStopWords) 57 58 # Demo one proper way 59 from gensim.parsing.preprocessing import remove_stopwords 60 strHoracePoemClean = remove_stopwords (strHoracePoemWIP) 61 IstHoracePoemClean = strHoracePoemClean.split() 62 setHoracePoemClean = set(lstHoracePoemClean) 63 64 intMaxCount 0 65 66 for word in setHoracePoemClean: 67 intHowMany = lstHoracePoemClean.count(word) 68 print(word, intHowMany) 69 if intHowMany > intMaxCount: 70 strMostUsedWord = word 71 intMaxCount = intHowMany I 72 73 print("Winner is", str MostUsedWord, intMaxCount) 74Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started