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 to identify a word with multiple / two concepts
 
 

Hi,
I had the idea to combine different concepts to recognize a word in a pattern.


E.g. I want to determine if the user dislikes something.
Any word which is member of the concept ~opinion AND(!) the concept ~badness should fill my needs.

Is this doable?

 

 
  [ # 1 ]

not doable by concept declaration. You can write a pattern like this
u: (_~opinion _0?~badness)

 

 
  [ # 2 ]

Thank you.

Is there a way to write a patternmacro based on this, cause it makes the pattern hard to read in my opinion.

The problem I see is that it uses up _0 and you may forget that when hiding behind a macro

 

 
  [ # 3 ]

You can hide it behind a macro, and that macro COULD protect _0 as follows
outputmacro: ^badopinion()
_19 = _0
^if (pattern _~opinion _0?~badwords) { ^mark(_0 ~badopinion)}
_0 = _19

~badopinion should have been defined as a concept, or you can just mark “badopinion” and use that in your patterns

 

 
  [ # 4 ]

Is it possible to write a patternmacro which describes just the matching of one word?
The most flexible would be if I could write patternmacro used like this:

u: (I ^bothConcepts(~badwords ~opinion) apple)

 

 
  [ # 5 ]

forget the question of a pattern macro. Can one write such a pattern? We already did that, so one would presume the macro is the same, roughly

patternmacro: ^both(^concept1 ^concept2)
  ^concept1 _0?^concept2

I have not tested this, but it seems plausible.

 

 
  [ # 6 ]

It works like a charm, thank you very much.
Is there a possibility to solve the problem that _0 is used up in the patternmacro? As far as I know I can not assign variables there.

 

 
  [ # 7 ]

You cannot call a user function or assign a variable from a pattern macro but you can call a system function. So you have a wide open cheat available, use ^eval.
_^concept1 _0?^concept2
^eval($hold = _0)

 

 
  [ # 8 ]

Ah, thank you, that’s awesome!

Two more questions to improve this:

1. If I use the pattern macro in a pattern where I want to save something before the pattern:

u: (a example pattern _~fruit ^both(~opinion ~badwords

Here I wouldn’t use _0, but _1 than.

Is there a clever way to determine the first free save variable without testing every one manually?
So that the pattern macro works, no matter how many values I save in the pattern before it?


2. Is there a hack to use a variable number of arguments without combining them with “” and splitting them again afterwards?

Thank you again! smile

 

 
  login or register to react