AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Keyword Extraction in Chatscript
 
 

Hello!

I am new to Chatscript. I am trying to make a Chatbot that (optimally) uses an interface with Postgresql
so I can run a product recommendation.

I have a few questions:

1. Is it alright for me to jump from one top file to another by using gambit? For instance, I have the following line:

aAFFIRMATIVE (~yesIn diesem Fall kann ich dir dabei helfenwas aus dem Uni-Shop zu suchen$kundegambit(~keyEx

 
I have noticed that if I write anything at any point, it jumps to my topic “keyEx”. How do I prevent this?
 
2. How do I include an already existing database (PostgresSQL) in ChatScript? So far, we only know how to build it ourselves
but we want to use an exisiting one. 

3. This is the most complicated one I figure -
How exactly would a keyword extraction work in ChatScript? If you’ve read the other points: I want to run a query
in a database. My first idea was to find any words that appear in one of my columns (Name, Purpose, Color) and
build concepts around it.

Imagine: Say, I have a database for vehcicles called vehicle, with the following columns: Power, Color, Seats

So if my user input was: I want a red car with 2 seats and at least 250 horse power

my query in postgresql would look like this:

select *
from vehicle 
where power 
>= 250 and color 'red' and seats 

 

My approach to this would have been like this: Make a concept for every distinct entry in every column

Like so:

concept: ~colors [green red blue]
concept
: ~seats [2 4 6] 


The next step to take would be to look for said “keywords” in user input. To be more precise:
The user says what he wants, like “I want a red car with 2 seats and at least 250 horse power”.

Question 1: How do I make the bot look for matching words from the three concepts at the same time?
From one user input it would have to look for matches in both concepts ~colors and ~seats and save findings
for each concept in two different variables ($color and $seat for example, respectively - see next question)

Question 2: Assuming I get the bot to match user input with multiple concepts, what
I’d like to do next is to save said matches in words such as $color and $seats. I’ve done this
with $name before but I wonder how that’d be done.

 

 
  [ # 1 ]

#1 - Yes, you may use ^gambit to invoke a topic at any point from a topic. That’s how control scripts work. The text you have queued for output will be put in a queue to go out to the user later, and the new topic may generate new text to be added to it. It will then ultimately return the the invoking topic, which in your case will probably cease execution because it has generated output.

I dont understand: I have noticed that if I write anything at any point, it jumps to my topic “keyEx”. How do I prevent this?
You requested it to go to that topic. it should have put out what you wrote before calling it, and anything it writes out.

#2 - if you consult RAWDATA/postgres/simpletopic.top you will see it opening a database (and closing it). It can certainly be an existing one. Just use the names appropriately

#3 - you can enumerate ~seats if you want, but really that is just ~positiveinteger (albeit with limitations on max, but with buses it might be more than you think.)

Usually one writes multiple rules, one for each thing you want to match from the input
u: (_~number seat) $seat = _0
u: (_~colors) $color = _0
u: (_~number horse) $power = _0
then you can compose in a later rule your postgres query.

 

 
  [ # 2 ]

First of all, Thank you for answering!


Alright, regarding point 3 I am in the unclear.

Maybe I did not make myself clear - let’s use another example.

We have concepts

~buy [buy purchase]
~brand [Ford Chevy Chrysler]
~colors [red green blue black white]

And this is the scenario I was thinking of:

The user says they want to buy something. The bot recognizes the word buy and figures the customer wants to buy something.
The bot then has the user make an input that has keywords from multiple concepts.

The user inputs: “I want to buy something” - from my understanding, the keyword “buy” from the concept ~buy is detected.

Then we get an answer (:a) that has words from multiple concepts.

topic: ~advise keep (~buy)

u: (~buyWhat do you want to buy?
 
#! Input has keywords from multiple concepts, we need keyword from each concept seperately. 
 
a


How do I make it so ChatScript analyses user input (that’s what I think a: does) so that it checks for words from multiple concepts?
That is my first problem.

Is:

u: (_~number seat) $seat = _0
u: (_~colors) $color = _0
u: (_~number horse) $power = _0

How you store found keywords? How would I do this for multiple keywords for a single a: then?

 

 

 

 
  [ # 3 ]

Alright, so we’ve made progress.

For now, I’ll go for something like

u: (_~number seat$seat _0
u
: (_~colors$color _0
u
: (_~number horse$power _0 

as you proposed. That will at least allow us to work on. I should tackle that problem later.

I have another problem at hand:

This may not fit well with the title of this thread, but:

Imagine I have the following scenario:

Let’s keep this abstract and simple:

uQUESTION1 () ....
 
a: (~yes)
 
a: (~no)
 
uQUESTION2 () ....
 
a: (~yes)
 
a: (~no)
 
uQUESTION3 ()
 
a: (~yes)
 
a: (~no) .... ^gambitQUESTION1 #Go to QUESTION1 and repeat 

So, say I get an answer in Question 3 that corresponds with ~no. I want repeat the procedure (asking questions), starting at question 1 again. I’ve tried gambit and I’ve tried reuse. Both have failed for me. Maybe I’ve done a mistake but I haven’t found anything in the tutorial I consulted or the documentation (yet)

Is there any way to achieve this?

 

 

 
  login or register to react