Skip to content

SCRIPT attribute

The SCRIPT attribute allows the user to integrate scripting functions into categorization and extraction rules.

A function is invoked in the attribute and its value—true or false— is the function return value.

By using SCRIPT in combination with all other standard attributes, it is possible to perform very powerful and project-oriented reasoning.

The syntax for the SCRIPT attribute is as follows:


In order to be referenced, the script function must have been defined in a script file, typically main.jr:

function function_name(token_index, params) {


  • token_index is the token ordinal number in the disambiguation output.
  • params is an optional parameter that can be passed by the attribute.

An alternative syntax for the SCRIPT attribute is:

SCRIPT("functionName[:parameter", "functionName:parameter",...])

where parameter is the function parameter and corresponds to the value of the params parameter.

In case of more functions separated by a comma—acting as an OR operator—one of the functions must return true so that the SCRIPT attribute is valid.

Being able to navigate the whole disambiguation output, the function can add very specific constraints to the attribute to which it relates.

Consider the following extraction rule:

        @NAME[TYPE(NPH) + SCRIPT("ExcludingLemma:John Smith")]

It aims to extract people's names except John Smith.
The following function cancels the extraction of the LEMMA passed as parameter.

function ExcludingLemma(token_index, params) {
    var token = DIS.getToken(token_index);
    if (token.lemma==params)
        return false;
    return true;

By leveraging the disambiguation output and being able to perform a check on the base forms, this function is able to avoid the extraction of John Smith even when an abbreviated form of the name occurs in the text.