Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CHATBOT program. Could somebody help, please? Chatbots takes some conversational text from the user, identifies the most frequent term(s) used and then responds with a

CHATBOT program. Could somebody help, please? Chatbots takes some conversational text from the user, identifies the most frequent term(s) used and then responds with a poem that has the most frequent term contained in it. Note: Must not use any dictionaries, classes, counter module, sets. Only list/string/tuple functions please

Solution should do the following:

  1. Allow the user to enter any freeform text input for conversation. Analyze their text for the most frequent word(s).
  2. If the most frequent word(s) are present in at least one of the poems, use that poem as the basis for your chatbots response. Select the poem that has the highest occurrence of the word the user used most frequently. If there is more than one word with the same number of occurrences, (e.g. a frequency tie), the longest word wins use the longest word (in terms of len()). There are pre-formed responses (in the RESPONSES list) in the starter code data file. Pick a random response from this list and replace the {poet} and {poem} tags with the data from the poem list given to you in that same file
  3. If there are no words that match in any of the poems given, print a default message: Thats interesting. I dont quite know what to say
  4. Exit the chatbot when the user enters the "I'm finished talking to you commend": /quit
  5. Handle two special cases: me-or-you: If there are no other matching words from the user input, handle the special case of when the user speaks of themselves OR when the user talks about you (the chatbot).

You must also provide the following:

  1. Testing hooks: Your solution must provide two functions for us to unit test: max_word(text) and find_poem(word)
    • max_word(text) takes as input parameter the user text for 1 chat Q&A (not the entire session) and returns the homogenized word (a string) - stripped of any punctuation - that occurs most frequently in the user input
    • find_poem(word) takes as input parameter a word and returns the poem (a list with two elements: a string author and a string containing the actual poem) that has the highest occurrence of that word.

POEMS = [["Maya Angelou", "You may write me down in history with your bitter, twisted lies;", " You may trod me in the very dirt but still, like dust, I'll rise"], ["Nikki Giovanni", "I was born in the Congo. I walked to the Fertile Crescent and built" , " the Sphinx. I designed a Pyramid so tough that a star that glows"\ " every one hundred years falls into the center giving divine perfect light.", " I am bad."], ["Langston Hughes", "Hold fast to dreams. For if dreams die. life is a broken-winged bird.", " That cannot fly."], ["Ashley Odilia Armand", "Skin, I'm in love with the way you carry the blood that keeps me sane,", " and, at times, chaotic."]] RESPONSES = ["That's interesting. As {poet} has written: '{poem}'", "I was thinking something similar! In fact, I just read {poet}'s", " poem about that topic. They wrote: '{poem}'", "I'm speechless. {poet} wrote about that when they said: '{poem}'", "Do you read poetry? Did you know {poet} said the same thing: '{poem}'"]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions

Question

1 What is meant by systematic training?

Answered: 1 week ago