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

^length does not like tilde characters
 
 

I have noticed the following behavior when trying to use the ^length() function:

The following code results in a FAILRULE in the trace log and we do not output the second log entry.

$$testval = ^"~fribble.3.2"
^log(FILE TMP/mylog.txt trying length of $$testval \n)
$
$length = ^length($$testval)
^
log(FILE TMP/mylog.txt length = $$length\n

This is the same even if you don’t use a variable. Trying to escape the tilde also does not help (e.g. ^”\~fribble.3.4” )

The following pieces of code work fine:

$$testval = ^"fribble"
^log(FILE TMP/mylog.txt trying length of $$testval \n)
$
$length = ^length($$testval)
^
log(FILE TMP/mylog.txt length = $$length\n)
$
$testval = ^"fribble.3.2"
^log(FILE TMP/mylog.txt trying length of $$testval \n)
$
$length = ^length($$testval)
^
log(FILE TMP/mylog.txt length = $$length\n

the tilde does not seem to cause any problems with the ^extract or ^findtext functions.

I ran into this issue while trying to work with %inputrejoinder which has a format of ~topicname.1.3

Is there a workaround for this?

 

 

 
  [ # 1 ]

^length(~concept) will give you the number of items in that concept, so I would suspect that ^length() is getting confused about whether the parameter is a concept name.

You could always use ^burst($$testval .) to create 3 facts from the rule name and then just use the first 2 of them.

 

 
  [ # 2 ]

Andy,

Thanks for the quick reply. So if the concept set doesn’t exist, then the rule just fails rather than return zero. Is that right?

Hopefully, this question and your answer will save some other folks some time. As a newbie, the similarity between rule IDs and concept names qualifies as esoteric.

I will try using the ^burst. I like that because I want to be able to reuse multiple layers of rejoinders.

Stephen G.

 

 
  [ # 3 ]

The engine code does generate a FAILRULE if you try to find the ^length() of an unknown concept, where “concept” means any argument that starts with a ~.

 

 
  login or register to react