CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2011
    Posts
    33

    Finding keywords in Cin and Cout

    Hello, I am writing an AI program similar to a chatterbot. I want it to be able to detect user inputted words. The user will input messages through 'cin' statements where they will then be interpreted. For example, if I inputted the message "I like waffles", I would want the program to search and detect the strings "like" and "waffles" and make a meaningful response. I originally intended to use the find() function to detect strings inside user inputted statements but I am not sure how to do this. Can anyone help me with this?

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Finding keywords in Cin and Cout

    If you plan to allow the input to something complicated consider using something like flex http://flex.sourceforge.net/ for the parsing.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Jun 2011
    Posts
    33

    Re: Finding keywords in Cin and Cout

    I don't need something that complicated at the moment although it will be useful in the future. What I want right now is for the computer to search for strings found within user inputted cin statements.

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Finding keywords in Cin and Cout

    Or, if you want a more hands-on or classical/vintage approach as a starting point, you may want to have a look at ELIZA.

    However, I remember claimed quotes from Weizenbaum that, while most people perceived ELIZA as a startling example of AI, he actually wrote it to disprove the possibility of AI. There's no reference to that in the Wikipedia article, though, but there may be one behind the citation links (didn't check them). ... or it's just one more of these funny urban legends...
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Finding keywords in Cin and Cout

    You can use strtok to break a NULL terminated string into individual words, but then what? Have you thought your approach out yet? Getting individual words in strings is the easiest part of the problem.

  6. #6
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Finding keywords in Cin and Cout

    With all do respect, but if you don't know how to manipulate a string, then don't try to make something hard. Instead, start learning how to code.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured