Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
the baby chatbot
#1
hello all

here is a code of a program of what i call "a baby chat bot" the bot only knows 4 words "mom' "dad" "food" and "hi" the user is suppose to talk to the bot and teach it new words or sentences to say every time you say something new to the bot that he doesn't know yet he will say he had learned something new when you say to the bot something he already knows he will replay randomly from his own knowledge (the words or sentences he already knows)

have fun teaching your baby chat bot to talk :)

import os
import random

vocab = ["hi", "mom", "dad", "food"]


def checkInput(txt, vocab):
    if any(s in txt for s in vocab):
        print(random.choice(vocab))
    else:
        print("i've learned a new thing to say! thank you!")


def add(txt):
    vocab.append(txt)


def main():
    print("hi! i'm a baby chatbot. please teach me how to talk and what to say:")
    while True:

        txt = input("> ")
        if txt == "end":
            break
        checkInput(txt, vocab)
        # print(a)
        add(txt)


main()
Reply


Messages In This Thread
the baby chatbot - by ronblue77 - Nov-27-2019, 12:33 PM
RE: the baby chatbot - by buran - Nov-27-2019, 12:36 PM
RE: the baby chatbot - by ronblue77 - Nov-27-2019, 12:54 PM
RE: the baby chatbot - by buran - Nov-27-2019, 01:01 PM
RE: the baby chatbot - by ronblue77 - Nov-27-2019, 03:10 PM
RE: the baby chatbot - by buran - Nov-27-2019, 03:28 PM
RE: the baby chatbot - by ronblue77 - Nov-28-2019, 06:52 AM
RE: the baby chatbot - by buran - Nov-28-2019, 08:34 AM
RE: the baby chatbot - by ronblue77 - Nov-29-2019, 08:34 PM
the baby chat bot version 3 - by ronblue77 - Nov-30-2019, 07:17 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020