Chat BOT

This is a discussion on Chat BOT within the C++ Programming forums, part of the General Programming Boards category; Ok heres the idea. Someone types in a comment, and the program talks back. It needs semi-random replies, but it ...

  1. #1
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331

    Chat BOT

    Ok heres the idea.

    Someone types in a comment, and the program talks back. It needs semi-random replies, but it needs to be smart and high in vovabulary.

    It needs to be able to understand what it is the user is telling them, and needs to be fully independent of the programmer while the user is runnng it.

    I don't want code, as its a project i set for myself, but, where would i start at, and i am useing console for it.

  2. #2
    UNBANNED OneStiffRod's Avatar
    Join Date
    Jan 2002
    Posts
    669
    You might have more fun getting involved in a project at this site...

    www.sourceforge.net

    Open source community
    My Avatar says: "Stay in School"

    Rocco is the Boy!
    "SHUT YOUR LIPS..."

  3. #3
    i4n
    Guest
    ...thats going to be heck of a lot of code...Good Luck!

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    and needs to be fully independent of the programmer while the user is runnng it.

    ...so no Wizard of Oz tricks, eh? Kinda rules out a lot of possibilities, but whatever

    Here are some (implausible???) suggestions:

    - Place all of the replies you think of in a single file, and place ID's next to them like so:

    1 I'm sorry %s, I can't do that...
    2 I love you %s...will you come a little closer to the monitor?
    3 Wow, that is fascinating %s - did you think of that yourself?

    - Place all of the possible input patterns you can think of in a separate file in all lowercase. Match them with the appropriate ID from the above file:

    1 will you
    2 thanks
    3 i think
    1 please

    Using this method, you can constantly add to the program without recompilation.

    - Finally, when the user types a string, convert it to lowercase, compare it to the second file data using strstr(), and if found, look up the appropriate response. If none is found, use a default like:

    "I'm sorry, my English is quite bad -can you rephrase that please?"
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #5
    Shadow12345
    Guest
    or get a girlfriend to talk to

  6. #6
    Registered User Azuth's Avatar
    Join Date
    Feb 2002
    Posts
    236
    It's difficult to tell you where to start, when we don't know how far along you are. I guess we have to assume that you know how to get use input and store it in a string. Basically I would imagine this sort of program would tokenise the string the user enters (Look at strtok). Then try to understand what the user is saying... Is the first part of the input "Who, What, Where, How, Why" etc ie, is the user asking a question.

    Some repsonses would be fixed, and I'd guess the best way for the program to appear animate would be for it to ask the questions.

    A typical conversation between User & Program might look like the following.

    U "Hello",
    P "Hi, I'm bob, what's you name?"
    U "John"
    P "Hello John, how is the weather today?"
    U "The weather is pretty cloudy"
    P (Splits string up and checks each word against a key word database, database says 'cloudy'="I wish it were fine, I like the sun" And there you have your response

    The database can be as big as you like, and the key to the program improving would be a series of questions that help the programs' database grow.

    I once saw a program that asked questions to identify animals. It started very simple and input would go like this.

    P "How many legs does the animal have?"
    U "2"
    P "Is it a Person?"
    U "No"
    P "I give up, what is it?"
    U "A bird"
    P "What does a Bird have that a Human doesn't?"
    U "Wings"
    P "Thank you"
    P "How many legs does the animal have?"
    U "2"
    P "Does the animal have Wings?"
    U "Yes"
    P "Is it a Bird?"

    You get the idea, at the time (many years ago) I found this program very impressive, but the code for it would not be too hard.

    Hope this helps
    Demonographic rhinology is not the only possible outcome, but why take the chance

  7. #7
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Yes it helps very much. Going off the ideas here i think i might try having three files:

    Questions
    Possible Answers
    Keywords

    I haven't started yet, but i'm sure this thread will continue to grow as i start!

    Thnx guys.

  8. #8
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Hmm, sounds intriguing! Keep us posted
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  9. #9
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708

    Smile

    Ok, well, I did one. I hope you don't mind Anyway, it kind of fun! But I didn't teach him much...
    Attached Files Attached Files
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  10. #10
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    I don't mind at all, having ideas to go off is awsome man!

    >>keep us posted

    no doubt!

    edit//

    Ok three questions:

    1) How would i go about reading in the files?

    2) Would there be a better way to check for comparisons then say an if statement?

    3) howd u do the cool slow print text!?
    Last edited by RoD; 10-10-2002 at 04:37 AM.

  11. #11
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    You could check out a similar project I did about 4 years back. You can download it at:

    http://www.generation5.org/projects/answer.shtml

    At the time I was dissapointed with the results of my project (I had high expectations), but when I compare it now to other chat programs such as CAlice - it aint bad.

    No source code, but I'm thinking about making everything I've ever done in this field free & available, and placing it all on my website. Will email you the source if you want.
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  12. #12
    Registered User SPiRiToFCaT's Avatar
    Join Date
    May 2002
    Posts
    35
    lol I have to make something like that in one of my comp subjects next summester, it's going to be fun! But we don't do it in C++, we use some special AI language thingy.
    However, yeah, I've spent some time investigating chatbots before, and I think your best bet is probably to have a file containing all the possible responses, and have keywords linking to them somehow then search the user's entry to find any keywords, if you find any keywords that you know, spit out one of the responses connected to that keyword.

    An interesting thing you could try, is to add the user's input to your possible responses file, so that your bot can learn new phrases.
    Then, when the user enters a phrase, search your possible replies, and find the reply that matches it best, like most matching words or something, and return that to the user as your response.

    There is quite a good chatbot I know of, a web-based one, by a company Zabaware, you can go to their website www.zabaware.com I believe it is, and get your own web based chatbot. you have control over what phrases are in it's 'brain' and what keywords they are connected to, and so on... it's really interesting to look at it and try to figure out how it works.

  13. #13
    Registered User blackwyvern's Avatar
    Join Date
    Jan 2002
    Posts
    60
    At a time I was doing a similar project and got through a large portion of it, but the AI was giving me hell, so I stuck in on the back burner. Here is a suggestion that would allow for a "greater" chat bot and more intellignt one.

    Consider this... A chatbot that sits in the background of an IRC chat room(one where people actually chat and are not there to pirate software). The chatbot follows the conversations, remembers things about the people that say them and can remember appropriate responses to common questions and possibly formulate responses based on the model others give. The sky is the limit in this very promising and exciting field of programming. I would also advise looking at some NLP programs to give you an idea of what other things you can do with a "simple" chatbot...

    I am thinking about starting my project again, this has got me excited again

  14. #14
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    howd u do the cool slow print text!?

    Code:
    void PrintMechanical(char *message, ...)
    {
     int i, len = strlen(message);
    
     char buff[len + 256];
    
     va_list ptr;
    
     va_start(ptr, message);
    
     vsprintf(buff, message, ptr);
    
     len = strlen(buff);
    
     for(i = 0; i < len; i++){
     printf("%c", buff[i]);
     Sleep(5 + (i * 10));
     }
    }

    How would i go about reading in the files?
    I just opened a file and counted the newlines, and the maximum string length of all lines. Then I declared an array like this:

    char array[count][maxlen];

    I used fgets() to read in the array...


    Would there be a better way to check for comparisons then say an if statement?

    What I did was to split each string in the "response" file, and used this simple loop:

    for(count of response strings){

    found = true;

    for(count of words in this response string)
    if one word is not found in input string:
    then set found to false;

    if found, return the index of the response string...
    }
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  15. #15
    Registered User blackwyvern's Avatar
    Join Date
    Jan 2002
    Posts
    60
    If you are going to make it have static replies, then add a feature for some sort of learning. Purely static chatbots are VERY boring and they have been around for some time now. Innovation is needed with chatbots. Fixed responses are the thing of the past. What I envision for chatbots is the next step in creating a true AI. You can create a nueral network that links words with common thoughts or even other words that relate, and connect these specific words with broader applications for these words or meanings, then using some means of English parsing your program can gain an understanding of what the user is asking and draw from itself a reply that will satisfy the user.

    A program that will also say one thing, or maybe even a couple of things, when you input a certain string is a fruitless programming venture and should be avoided.
    Last edited by blackwyvern; 10-10-2002 at 12:25 PM.

Page 1 of 6 123456 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Chat Bot Help!!
    By arealfind08 in forum C Programming
    Replies: 1
    Last Post: 03-09-2009, 07:52 AM
  2. Chat bot brain ideas
    By cogeek in forum C++ Programming
    Replies: 14
    Last Post: 10-02-2004, 01:26 AM
  3. Chat Bot: Multiple headers problem
    By RoD in forum C++ Programming
    Replies: 4
    Last Post: 03-26-2003, 06:07 PM
  4. Chat BOT Sample
    By RoD in forum C++ Programming
    Replies: 19
    Last Post: 11-04-2002, 04:51 AM
  5. Msvc Aim Chat Bot ???
    By Unregistered in forum C++ Programming
    Replies: 0
    Last Post: 09-19-2001, 09:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21