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

Pattern match error
 
 

I have the following patterns as a catch all for basic sentences.
Currently the first matches “His father has been eating cake” but not “His father has been eating a cake”. In fact, it works for all pronoun/possessive forms until I add the determiner. I don’t know why.

u: (_{~determiner_bits} _{[~pronoun_bits ~possessive_bits]} _[~verb_bits ~noun_bits] {~aux_verb} {~aux_verb} _[~verb_bits ~noun_bits !~pronoun_bits] {~determiner_bits} _[~verb_bits ~noun_bits ~adjective ~pronoun_bits]) PRONOUN _1 SUBJECT _2 VERB _3 OBJECT _4

u: (<‘_~pronoun_bits {~aux_verb} {~aux_verb} _[~verb_bits ~noun_bits] {~determiner_bits} _{[~verb_bits ~noun_bits ~pronoun_bits ~adjective]}) PRONOUN _0 VERB _1 OBJECT _2

Here is the trace for the failing input. As you can see, it is incorrectly matching the variables. Not sure why.

. . . . , . . Topic: ~pos linear Statements:
. . . . , . . try 0.0:
. . . . , . . try 0.0 START:
. . . . , . . . ( $undef
. . . . , . . . if $undef (null) !=  null
. . . . , . . try 1.0:
. . . . , . . try 1.0:
. . . . , . . . ( _
. . . . , . . . . { ~determiner_bits
. . . . , . . . . } ... + 6:6 _0=a/a _
. . . . , . . . . {
. . . . , . . . . , [ ~pronoun_bits ~possessive_bits ]
. . . . , . . . . } _
. . . . , . . . . [ ~verb_bits ~noun_bits
. . . . , . . . . ] ... + 7:7 _2=cake/cake
. . . . , . . . . { ~aux_verb }
. . . . , . . . . { ~aux_verb } _
. . . . , . . . . [ ~verb_bits ~noun_bits ! ~pronoun_bits
. . . . , . . . . ] ... + 7:7 _3=cake/cake
. . . . , . . . . { ~determiner_bits } _
. . . . , . . . . [ ~verb_bits ~noun_bits ~adjective ~pronoun_bits ]
. . . . , . . . retry past 6—————- _
. . . . , . . . . { ~determiner_bits } _
. . . . , . . . . {
. . . . , . . . . , [ ~pronoun_bits ~possessive_bits ]
. . . . , . . . . } _
. . . . , . . . . [ ~verb_bits ~noun_bits
. . . . , . . . . ] ... + 7:7 _2=cake/cake
. . . . , . . . . { ~aux_verb }
. . . . , . . . . { ~aux_verb } _
. . . . , . . . . [ ~verb_bits ~noun_bits ! ~pronoun_bits
. . . . , . . . . ] ... + 7:7 _3=cake/cake
. . . . , . . . . { ~determiner_bits } _
. . . . , . . . . [ ~verb_bits ~noun_bits ~adjective ~pronoun_bits ]
. . . . , . . . retry past 7—————- _
. . . . , . . . . { ~determiner_bits } _
. . . . , . . . . {
. . . . , . . . . , [ ~pronoun_bits ~possessive_bits ]
. . . . , . . . . } _
. . . . , . . . . [ ~verb_bits ~noun_bits ]
. . . . , . . try 2.0:
. . . . , . . try 2.0:
. . . . , . . . ( < _ ~pronoun_bits
. . . . , . . Result: NOPROBLEM Topic: ~pos
. . . . , NOPROBLEM (^respond) =>
. . . . NOPROBLEM (^nofail) =>

 

 

 
  [ # 1 ]

“his”  is not considered a determiner. It’s a possessive. So when you try to match “his father has been eating a cake”, the initial {~determiner_bits}  matches “a”, as can be seen from the trace.  The pattern matcher binds “a” and tries the rest and fails.  There is no later determiner it can bind to, so that’s the end of the match. Failure.

 

 
  [ # 2 ]

Not sure I understand. Shouldn’t the first optional {[~pronoun_bits ~possessive_bits] match "his" and work from there instead of immediately jumping to the "a" before cake? After all, the starting {~determiner_bits} is optional too right?

 

 
  [ # 3 ]

The fact that something is optional only means that if it cant be found, it can be ignored. A rule is always processed in order.
u: (_{~determiner_bits} _{[~pronoun_bits ~possessive_bits]}
your rule says: 
FIRST: try to find determinere bits.
SECOND, if you find it search for pronoun/possessive after
          if you dont find it, search for pronoun/possessive

FIRST matches at “a”, so that’s what happens. the rest of the pattern does not match after.

 

 
  [ # 4 ]

Then I had some confusion about how optional patterns worked. I thought it was at that position, before a non-optional pattern, an optional value could be used. Wasn’t thinking about the order of consecutive optional patterns.

Thanks for clearing that up.

 

 
  login or register to react