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

Recognize protracted words
 
 

Hey,

I want to recognize words which have some of its characters repeated to often.

E.g. recognize these words as

hello

:

helloo
heelllooooooooooo
heeelllooooooooooooooooooooooooooooooooo

Is there a way to do this?

 

 

 

 
  [ # 1 ]

chatscript automatically removes excess repeated characters, so at best you get helloo and not helloooooo… try :prepare to see

 

 
  [ # 2 ]

Is there a specific token flag needed for this?
Cause I tried :prepare and I still end up with “hellooooooooooooooooooooooo”

 

 
  [ # 3 ]

you are correct. It does not do that… I think ONCE upon a time it did, a while ago.

You CAN pattern match for extended tail characters using u: (hello* ) but that also allows any other characters even non-repeating ones.

 

 
  [ # 4 ]

I should probably add such a capability back in.

 

 
  [ # 5 ]

In the mean time, you might be able to do something along the line of this (untested):

u: ( _*)
  
$_pos = ^position(START _0)
  
$_word _0
  $_last 
= ^extract($_word -+1)
  
$_len = ^length($_word)
  
$_same 0
  
^loop()
  
{
    
if ($_len AND ^extract($_word -+1) == $_last{
      $_len 
-= 1
      $_word 
= ^extract($_word 0 $_len)
      
$_same += 1
    } 
else {
      
^end(LOOP)
    
}
  }
  
if ($_same 0{
    
^setcanon($_pos $_word)
  
}
  
^unmark(* _0)
  ^
retry(RULE

 

 

 
  login or register to react