Teneo Developers Community

Difference between AND operators

Hi again,

I am currently creating syntax conditions and have read the condition syntax reference. While I saw from the tutorials that the operator that seems to be most often used to express AND is &^, I saw that there are two more AND operators, & and &=. From the descriptions, I think I get the difference between &^ and &=, but I am not sure when one would have to use just &. I cannot think of a use case for that.

Can someone help me out here?

Thanks,

John

That is a very good question you asked. I like our condition syntax because you can code conditions with

  1. basic syntax that catches 90% or more of the cases ( these are + and & )
  2. extended syntax that allows you to adjust for highly specialized cases (creating exceptions, etc)

&^ as I think you saw, means different match
%CITIES.LIST &^ %COUNTRIES.LIST would be true for “Chicago, Jamaica” but false for a simple input “Jamaica”

& means the condition parts around the AND(s) could match for the same words in an input. The condition %CITIES.LIST & %COUNTRIES.LIST would be true for both “Chicago, Jamaica” and “Jamaica”. In the case of the simple input “Jamaica” - that slips through because there are also some cities called Jamaica. So &^ prevents a potential source of error where you have overlapping language objects.

So the reasons to use & are not that substantial:

  1. & means somewhat simpler looking conditions (if you know lobs are totally unique)
  2. & is more efficient for engine to evaluate (though with today’s computing power, this may be an imaginary difference).

Reason to use &^ (different match):

  1. More robust.
  2. Guarantees that the condition parts match on different words/phrases

Hi Fred,

thanks for your explanation! I think I see a little clearer now… I was just wondering whether there is a use-case where it would be advantageous to use the & operator over the &^ operator? Is there cases where you want to leave it underspecified whether you want both parts of the condition on the same words in an input or on different words?

Just being curious :slight_smile:

For my current flow, I think I know now which one to use.

Cheers,

John

Hi John, I’d recommend using &^ as it is more precise and also consistent with auto-coding, which uses different match by default.

The only use case I can think of unique to & would be: Find a sentence that has each of the following, and they can be the same or different tokens(words): a proper noun, a first name, a noun:

( %MST_PROPER.ANNOT & %NAMES.LIST & %POS_NOUN.ANNOT )

Honestly, I’ve never come across a case where you had to do this. But it doesn’t mean there aren’t any. Perhaps writing some kind of bot to analyze grammar?

Thanks for the example and your recommendation, Fred! I came indeed to the same conclusion in the end, that &^ is the safest one to use.

Cheers,

John

2 Likes

You’re very welcome!