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..

Triggers and an object for sentence splitting
 
 

This not going to cover lots of situations, but assuming we could predict a sentence split based on words, the following code may work.

For example, “Hello how are you? What is your name?” could have a trigger of ‘+ hello how are you what is your name’, where the ‘what’ tells us where the sentence splits.

The example triggers below use ‘what’ as the split word, so we pass this word to the object to tell it where to split the sentence.

this is sentence one what is sentence two
- <call>splitsentence what <input1></call>

this is sentence one
Sentence one reply.

what is sentence two
Now we have sentence two reply
object splitsentence perl
    my 
($obj,$method,@args) = @_;
    
my $msg join(" ",@args);
 
 
my @arraymsg split($method,$msg);
 @
arraymsg[1] $method.@arraymsg[1];
 
 
my $rtnvalue "{@".@arraymsg[0]."} "."{@".@arraymsg[1]."}";
 
 return 
$rtnvalue;
object 

Of course, this will be redundant if RS gets an intergrated way to do this. But for now I thought it might help out a little. And was an interesting experiement with objects and return values.

 

 
  [ # 1 ]

I would be wary of using “what” as a sentence splitter.

Do you know what I saw?
He was what I call stupid
Can you see what I can?

and so on

 

 
  [ # 2 ]

Yes, absolutely.

The ‘what’ only came from that particular trigger, not as a general thing. This mini-solution is, of course limited as it only works when a particular type of input could identify a word as starting a new sentence. There wil be much better ways of doing this (much better being the capture of the actual input and finding the ‘.’).

The word passed to the perl object can be any word that works for that input.

It was only in my partciular example, and the original example of ‘hi how are you what is your name’ where the ‘what’ could be seen as the start of the sentence.

 

 
  [ # 3 ]

While I agree with Steve about using the word “what”, it may be possible to use the following phrases:

What is
what are
what was
what if
etc..

Those are more likely to start new sentences than just the bare “what” alone. The same could apply to “when”, “how”, “where”, and a myriad other similar sentence fragments, as well. smile

Of course, it could make for some humorous results if the input comes from an individual who’s grammar skills sink even lower than missing punctuation. Example:

I went to talk to them what was in charge of the students and said I need you to learn me to talk good.

wink

 

 
  [ # 4 ]

Yes, well, I personally have never cared about a bot understanding bad grammar. Mainly because if the human language intelligence is not good, then it wouldn’t be test for the AI anyway.

I think I should explain better this ‘what’ aspect. It wasn’t anything to do with the meaning of the word. It was just taken from the one input example.

Using my idea, the botmaster would have to have an input trigger where the new sentence starting point was clear, and taking that word. Obviously this is limited to the use of very precise input triggers.

Another example could be:

how are you do you remember my name 

And then the word sent to the object would be ‘do’.

 

 
  [ # 5 ]

In cases where the user actually used punctuation in their message, this problem could be solved by doing the sentence-splitting in your code before giving each one to RiveScript. wink

my @reply;
for 
my $sentence (split(/[.!?;]/, $message)) {
   push 
@reply$rs->reply($user$sentence);
}
$reply 
join " ", @reply

RiveScript (currently) doesn’t do sentence-splitting in-house because I like to follow the Unix Philosophy (keep the library small and have it do one thing really well), and I wouldn’t want to presuppose what the sentence-splitting characters are for every spoken language and use case. wink

 

 
  [ # 6 ]

Hi, Just jumping into this thread.. after a long time!

Sentence splitting is a hard task, even for humans, there are a lot of AI based sentence splitters, and why not give them a try?

Normally the splitting is made with a high-dimensional trained classifier, based upon some ‘hints’ like punctuation, surrounding words, sentence length, POS of the words (if they have been tagged).

I have been using a simple MaxEntropy trained system, for english, there are already trained data out there, just pick a lib include it into the bots, and make the code shine! good luck!

Another hint, sentence splitting is hardly dependent upon the ‘base’ position on the talk, its also called grounding, and this is rather hard to determine (even for humans) but there are many shallow algorithms to use for a rubbish chat-bot.

best wink

 

 
  [ # 7 ]
Noah Petherbridge - Jun 13, 2013:

In cases where the user actually used punctuation in their message, this problem could be solved by doing the sentence-splitting in your code before giving each one to RiveScript. wink

my @reply;
for 
my $sentence (split(/[.!?;]/, $message)) {
   push 
@reply$rs->reply($user$sentence);
}
$reply 
join " ", @reply

Ah yes, this is much better.

I had no intention of wanting to do this when the user didn’t use puncuation (personally, I have no interest in a bot correcting human’s mistakes to interpret input).

The usage of a splitting word was simply because I didn’t know how to do this above. Thanks Noah.

Noah Petherbridge - Jun 13, 2013:

RiveScript (currently) doesn’t do sentence-splitting in-house because I like to follow the Unix Philosophy (keep the library small and have it do one thing really well), and I wouldn’t want to presuppose what the sentence-splitting characters are for every spoken language and use case. wink

Right. As I think I mentioned before, 100% support from me on this approach. I witnessed the bloating and feature-creeping of a few open-source web based content management systems, and it usually led to more problems that the new features solved.

 

 
  [ # 8 ]
Steve Worswick - Jun 12, 2013:

I would be wary of using “what” as a sentence splitter.

Do you know what I saw?
He was what I call stupid
Can you see what I can?

Personally I do use question words as sentence splitters and it’s working adequately for me. Many sentence structures are, as I perceive, multiple clauses. e.g. “Do you know? - What I saw?” could basically be taken as separate questions. While “What I saw?” is no longer correct grammar when split, that is a technicality. It says “What (did) I see?” in past tense without the redundant “did”. “Do you know/remember/see (something)?” may not represent literal meaning as a sentence, but its meaning is separatable, almost ignorable even. Investigating the main question “What did I see?” would automatically cover the question of whether you knew/saw/heard it.
“He was -what I call- stupid”, is an interjected clause (or some such term), and then there are relative clauses like “I know the guy - who said that.” that start with question words, etc.
Granted though, this path is a rocky one.

 

 
  login or register to react