Skip to content

onTaggerLevel

The onTaggerLevel handling function is similar to onTagger, with the difference that it's called each time the evaluation of tagging rules for a given level is over.

The function must be defined like this:

function onTaggerLevel(level) {
  ...
}

where level is the level specified in tagging rules.

For example, consider this declaration:

TAGS
{
    @COLOR,
    @RAINBOW
}

If you apply these tagging rules:

SCOPE SENTENCE
{
    TAGGER(10)
    {
        @RAINBOW[LEMMA("red", "orange", "yellow", "green", "blue", "indigo", "violet")]
    }

    TAGGER()
    {    
        @COLOR[LEMMA("black", "brown", "turquoise", "pink", "gray")]
        OR
        @COLOR[TAG(RAINBOW)]
    }
}

to this text:

The colors of the rainbow are: red, orange, yellow, green, blue, indigo and violet. Brown, gray and black are not in the rainbow.

onTaggerLevel will be invoked two times: one after the evaluation of the level 10 rule and another time after the evaluation of the second rule, which implicitly has level 10000.
Parameter level will have value 10 the first time and value 10000 the second time, you can organize your code to take the level into account, like this:

function onTaggerLevel(level) {
    if (level==10) {
        // Things to do during the first invocation. Note: level 10000 tag instances do not exist yet.
        ...
    } else if (level==10000) {
        // Things to do during the second invocation.
        ...
    }
}

Note

The second tagging rule above exemplifies that use of the TAG attribute and tag levels to perform "tag based tagging" and so avoid the repetition of the rainbow colors in the condition.

Together with onTagger, onTaggerLevel is the right place to use the tagging management methods of the pre-defined DIS object. When using these methods in the onTaggerLevelfunction—in combination with tagging rules—the tag instances created by the methods have the same level for which the onTaggerLevel function is called.