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

Question on ^substitute with string from ^nth
 
 

When ^nth is used to retrieve a member from a set, it tends to insert an extra space in front of punctuation marks like apostrophe and period in the text.

I’m trying to use ^substitute to avoid it, but found that ^substitute doesn’t seem to work with strings supplied by ^nth… Please refer to the screen shot.

Any way out? Many thanks.

Image Attachments
cs_extra_space.png
 

 
  [ # 1 ]

Your set membership element probably DOES NOT contain a space. It contains an underscore (default representation), hence your substitution match would fail.

 

 
  [ # 2 ]

The 1st element in the set (I use quotes instead of underscores):
  “I’m going to the party.”

Output by ^nth(~test_sets 0), a space gets inserted before apostrophe: (I need to use ^nth to get the elements in my processing)
  “I ‘m going to the party.”

It is the inserted space that I need to remove using ^substitute, which normally works for any string literals or simple variables.

But in the test above, ^substitute does not work if the string is retrieved from the set by ^nth.

Wired to be. Any advice?

 

 
  [ # 3 ]

When you use quotes in a concept like ā€œIā€™m going to the party.ā€, the system maps that to using underscores by default. It is possible to build things using spaces instead, but that is not the default.  The system on output by default converts underscores back to spaces.  Hence you would not normally notice it. But substitute would fail if it is represented as underscores.

Furthermore, using quotes in particular tells chatscript to convert internal punctuation into the way it would tokenize user input for matching purposes. Hence it changes your I’m to I ‘m because tokenizing input would.  But you are not making your concept for use by matching. So you don’t want internal conversion of punctuation. The way to build up sets that do not do this would be to use a table:  and create facts (xxx member ~test_sets) from the table macro. That way you can annotate the tablemacro args with notes about how you want quoted items processed.

 

 
  [ # 4 ]

Thanks for the insight. With that I just change to substitute underscore_apostrophe instead of space_apostrophe in my code and that fixed the issue.

Thanks again.

 

 
  login or register to react