Skip to content

CTX

Introduction

The CTX pre-defined object returns information about the options influencing the analysis or the definitions of the extraction templates.

The methods of the object are described below.

getOptions

The getOptions method returns an object whose properties represent the options affecting or reflecting the analysis.
When used in the Studio IDE, the options are those set in Studio project settings plus others related to the analysis. For example, the JSON corresponding to the returned object could be like this:

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

where:

  • enhanced_output: the current value of the Enable Advanced Disambiguation Info configuration property.
  • debugger: if true, the Studio IDE debugger is on.
  • debugger_port: the current value of the Debugger Port configuration property.
  • all_categories: corresponds to the Show All Categories configuration property.
  • filename: the name of the file being analyzed.

When using the text intelligence engine via the Studio Local Deployment Agent API or when uploading a model to Platform and then publishing the model to NL Flow, putting it in a workflow and using it via NL Flow API, the options are those specified in the input JSON under the options key. For example:

"options": {
    "custom": {
        "doSomethingSpecial": true
    }
}

The custom key in the inpuit JSON corresponds to the custom_options property of the object returned by the method.

The syntax is:

CTX.getOptions()

For example, this code can access the doSomethingSpecial option of the example above and takes it into account:

var options = CTX.getOptions();

if(
    options != null &&
    options.custom_options != null &&
    options.custom_options.doSomethingSpecial != null &&
    options.custom_options.doSomethingSpecial
) { // Do something special }

getTemplates

The getTemplates method returns an array containing the definition of the extraction templates with their fields and fields' attributes.

For example, the JSON corresponding to the array could be something like this:

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

where cardinal and solitary are field attributes.

The syntax is:

CTX.getTemplates()