Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Can't get context to work. Variable m_sContext doesn't appear to be used at all in the code after being declared.

Contextual reply seems to work once... appears to count entries in vector context list but if you try to do it twice by adding further context entries to the flat file database it seems to push them into the context vector list but does nothing with them and returns 'Bot doesn't understand' and goes to a random reply instead of continuing in context.

Can't quite work out what is going wrong and also why there is a prev_response or prev_input variable that could be used for context instead of adding in a special list that seems to duplicate what prev_response or prev_input does?

Am I missing something here?

Link to code:
http://www.codeproject.com/Articles/36106/Chatbot-Tutorial

Changes I made to script txt:

KWHAT IS YOUR NAME
RMY NAME IS CHATTERBOT13.
RYOU CAN CALL ME CHATTERBOT13.
RWHY DO YOU WANT TO KNOW MY NAME?
#
KSO THAT'S YOUR NAME
CMY NAME IS CHATTERBOT13.
CYOU CAN CALL ME CHATTERBOT13.
CWHY DO YOU WANT TO KNOW MY NAME?
RYES, THAT'S MY NAME
RYES IT IS.
#
KI LIKE THAT NAME
CYES IT IS
CYES, THAT'S MY NAME
RTHANKYOU FOR LIKING MY NAME
RI AM PLEASED YOU LIKE MY NAME
#
KDID YOU CHOOSE IT YOURSELF?
CTHANKYOU FOR LIKING MY NAME
CI AM PLEASED YOU LIKE MY NAME
RYES I DID CHOOSE IT MYSELF

For some reason the last block of text fails to work. I have tried other iterations but the code always fails to get context correct after working the first time.

OUTPUT:

Conversation log - Sun Jul 13 19:45:20 2014

HELLO USER, WHAT IS YOUR NAME?
>fred
CONTINUE, I'M LISTENING...
>what is your name
MY NAME IS CHATTERBOT13.
>so that's your name
YES IT IS.
>I like that name
I'M NOT SURE IF I UNDERSTAND WHAT YOU ARE TALKING ABOUT.
>I like that name
VERY GOOD CONVERSATION!
>so that's your name

Peter Davy
Posted
Updated 12-Jul-14 21:50pm
v3

1 solution

You need to post your question in the forum at the end of the article, so the author sees it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900