|
|
Experienced member
Total posts: 66
Joined: Jun 10, 2013
|
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.
|
|
|
|
|
Posted: Jun 12, 2013 |
[ # 1 ]
|
|
Administrator
Total posts: 2048
Joined: Jun 25, 2010
|
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
|
|
|
|
|
Posted: Jun 12, 2013 |
[ # 2 ]
|
|
Experienced member
Total posts: 66
Joined: Jun 10, 2013
|
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.
|
|
|
|
|
Posted: Jun 12, 2013 |
[ # 3 ]
|
|
Administrator
Total posts: 3111
Joined: Jun 14, 2010
|
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.
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.
|
|
|
|
|
Posted: Jun 12, 2013 |
[ # 4 ]
|
|
Experienced member
Total posts: 66
Joined: Jun 10, 2013
|
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’.
|
|
|
|
|
Posted: Jun 13, 2013 |
[ # 5 ]
|
|
Moderator
Total posts: 194
Joined: Sep 23, 2011
|
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.
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.
|
|
|
|
|
Posted: Jun 13, 2013 |
[ # 6 ]
|
|
Senior member
Total posts: 141
Joined: Apr 24, 2011
|
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
|
|
|
|
|
Posted: Jun 13, 2013 |
[ # 7 ]
|
|
Experienced member
Total posts: 66
Joined: Jun 10, 2013
|
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.
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.
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.
|
|
|
|
|
Posted: Jun 17, 2013 |
[ # 8 ]
|
|
Guru
Total posts: 1009
Joined: Jun 13, 2013
|
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.
|
|
|
|