Longest match: annotations vs language conditions

I was wondering what happens when pairing annotations with language conditions using longest match. What I hope happens, and this seems to be the case, is that the language condition takes precedence. Since it actually uses words in the input.

In this case I have an annotation that runs over the entire input, and the condition looks something like this:



And in a trigger:


This is what I used to test, and with inputs that were true for both conditions the word condition was considered longest match
If the annotation was true, but the word condition was not, the annotation was selected as longest match.

Is this behavior defined, and what happens if the annotation is on specific words?

Hi @Fred.Roberts ,
interesting question!

In your example, %$APPTAG_NETFLIX.TOP_INTENT is an annotation referring to the intent classification for the entire user input, a so called sentence annotation. This sentence annotation does not have used words. Therefore, the longest match operator in your condition (:L) leads to “netflix” as being selected for the match.

If the annotation had been on specific words (and not at sentence level), then the annotation would have also used words.

Let’s take a look at the following example:

If you have the following condition:
( (rolling / %$KNOWN_GROUP.NER )^{sUsedWords=_USED_WORDS} )

and the input “I listen to the rolling stones”, then the value of variable sUsedWords would be “rolling”. But with the longest match operator:

( (rolling / %$KNOWN_GROUP.NER )^{sUsedWords=_USED_WORDS} ):L

and the same input, sUsedWords would instead be “rolling stones”

Hope this clarifies the behaviour! :slight_smile:
If you have further questions on this, please let me know.


1 Like

Thank Benjamin! Very good to know these nuances about annotations.

1 Like