Skip to content

CTX

The CTX object and its methods

The CTX predefined object returns information about the categorization and extraction processes.

The CTX object can be used in the SCRIPT attribute and also in the following functions, which are executed after disambiguation:

The CTX object functionalities are exposed through its methods:

  • getOptions
  • getTemplates

getOptions

The getOptions method returns a JSON with some of the options set in the Studio project settings.

For example:

{
    "enhanced_output": "false",
    "debugger": "true",
    "debugger_port": "9091",
    "explain_rule": "-1",
    "all_categories": "true",
    "filename": "Doc185672.xml.txt"
}

Where:

  • enhanced_output: toggles the display of additional disambiguation information, for example in the Entities tab of the Disambiguation Info tool window. This option is set here.
  • debugger: if true, the debugger is on, false otherwise.
  • debugger_port: the debugger port. This option is set here.
  • all_categories: toggles the return of all categories, winners and losers in the Categorization tool window. This option is set here.
  • filename: the analyzed text filename.

The syntax is:

CTX.getOptions();

getTemplates

The getTemplates method returns an array object containing the templates, the related fields and possible attributes used in the project.

For example:

["
    {"template": 
        "TEMPLATE01", 
            "fields": 
                "[
                "
                {"field": "FIELD01", "cardinal": "false", "solitary": "false"}", 
                "
                {"field": "FIELD02", "cardinal": "false", "solitary": "false"}
                "]
    "}
"]

Represented in tabular format:

TEMPLATE01
FIELD01
cardinal false
solitary false
FIELD02
cardinal false
solitary false

where cardinal and solitary are attributes specified with rules.

The syntax is:

CTX.getTemplates();