Thread: Small Chatbot problem

  1. #1
    Registered User
    Join Date
    Dec 2012

    Small Chatbot problem

    Hi there. I wish to create a simple chatbot program, and I got the jist of making a VERY simple one, however, I would like the bot to spit back the input for a few set input when answering, and I am a little unsure how to make that happen.

    For example, when the sentence starts with "Do you like"
    in: "Do you like (text) ?
    out: "No, I do not like (text).

    A little help would be very much appreciated. Thank you.

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Toronto, ON
    I would create a map of sentence fragments where the keys/values are input/output text. You might want this map to be read from a file so you can add/change the responses easily without recompiling the program.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  3. #3
    Registered User
    Join Date
    Apr 2006
    You need a regular expression, that pattern matches on the whole string, with grabbing parenthesis on what you want grabbed and repeated. Something like this:
    /^Do you like (.*)?$/

    A function that matches on that should return the part that matches the parenthesis. The details of how to write the call depend on the regular expression tool or library used. You should find one for a project like this.

    I would also discourage the use of C++ for this. A scripting language like python is more suitable, and has a standard regular expression library. You can also use an existing engine, and just write the AI rules. For example, Pandorabots provides web hostring for such chatbots written using AIML.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  4. #4
    Join Date
    Oct 2007
    Inside my computer
    Also, C++11 have support for regular expressions just fine: <regex> - C++ Reference.
    Dunno about the other bits.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Designing a chatbot
    By Neo1 in forum Tech Board
    Replies: 1
    Last Post: 01-10-2012, 12:11 PM
  2. Interface with a ChatBot
    By adr in forum General AI Programming
    Replies: 0
    Last Post: 12-07-2011, 03:34 PM
  3. simple chatbot problems
    By Whyrusleeping in forum C++ Programming
    Replies: 2
    Last Post: 06-09-2011, 01:04 PM
  4. small problem but....
    By new.c in forum C Programming
    Replies: 5
    Last Post: 12-10-2004, 01:49 AM
  5. A small problem with a small program
    By Wetling in forum C Programming
    Replies: 7
    Last Post: 03-25-2002, 09:45 PM