AI Zone Admin Forum Add your forum

Chatbot Conference London On Oct 3th Erwin will be moderating on the Chatbots conference in London. Why don't you meet him there? As a Chatbots.org visitor, you'll get a discount as well: Why don't we meet there? get a discount

We do experience some trouble with our forms and some details page. We'll fix this ASAP. Sorry for the inconvenience!
Adding words from user responses to a concept
 
 

Hi! I’d like some feedback on this.

I am making a complicated chatbot where in some inputs I essentially just need to check if the user is keeping to the topic of the conversation. However, the topic may change from user to user (we are talking about startups, but the startup ideas will be different, of course), so I thought I could parse user input for key words and add those to a concept ~key_words.

I have a Python script that takes user response and returns a list of only important words in it. Right now it returns a string of words separated with a white space.

Now, I know I can update a concept using:

concept: ~concept_name MORE (new_word)

But I can’t seem to figure out how to loop through the list (mostly cause there are no lists in ChatScript). Should I modify my Python script to return one word at a time so that I can create facts like “key_word is WORD” and then call a query for all facts with the subject key_word? What do I do next? Can I just loop through the object that the query returns and update the concept with each element?

Maybe I am overcomplicating this and there’s an easier way to memorize key words in a conversation?

Thanks a bunch!

 

 
  [ # 1 ]

Interesting!

I’ve figured out the iteration part (just iterate over a json list), but it turns out you can’t expand concepts with any variables. It makes sense, I suppose.

So now I have an @0object that stores all my key words. Is there a way to check if a user has mentioned any of the words that are in that object?

Thanks!

 

 
  [ # 2 ]

Good evening.  You can try the following:

concept: ~mykeywords hawk robin canary )

topic: ~mytest keep repeat xxfilter add keywords)

u: ( xxfilter respond( ~mykeywordfilter )

u: ( add _to my keywords 
 ^
createfact'_0 member ~mykeywords )
        Ok. I have learned that '
_0 is a key word.
 

topic: ~mykeywordfilter keep repeat ()

u: (_*1)
 
refine()
   
a: ( '_0?~mykeywords ) _0 retry( toprule )
   a: ( * ) retry( toprule ) 


Output:
bob: > xxfilter cat hawk dog horse robin fly canary red-tailed hawk
HARRY:  Hawk Robin Canary
bob: > add red-tailed hawk to my keywords
HARRY:  Ok. I have learned that red-tailed hawk is a key word.
bob: > xxfilter cat hawk dog horse robin fly canary red-tailed hawk
HARRY:  Hawk Robin Canary Red-tailed hawk
bob: >

 

 

 
  login or register to react