Skip to main content
An ABBYY FlexiCapture classifier processes submitted documents and determines their class. This lets you choose a document definition to be used for field extraction. Each classifier corresponds to a specific classification training batch. If you want to use several classifiers for a single batch, you need to set up a classification script. This can be useful when there are documents that need to undergo additional classification. In this case, the first classifier will be used to classify the documents according to their class, and then, an additional classifier will be selected from the script depending on the classification results. For example, documents can be first classified into “invoices” and “contracts”, then the invoices can be further classified according to company name.
This script can only be set up for an already existing classification training batch and cannot be set up when creating a new batch.
To set up a classification script:
  1. Open Project → Project Properties…
  2. Go to the Recognition tab found in the project properties window.
  3. Open the classification script Editor by clicking Set… to the right of Use script in the Classification section.
  4. In the dialog box, select an appropriate classifier by clicking Add… and choosing a classification batch from the list.
  5. Now, you can change a classifier’s Alias Name. This allows you to not have to rewrite a script if a classifier’s name has been changed during processing. The script will refer to the particular name specified in the Alias Name column.
  6. Open the script editor window by clicking Edit Script…

Parameters

Name

Type

Access

Description

BatchTypeClassifier

IBatchTypeClassifier

Read-only

A classifier in the batch type.

IsConfident

bool

Read-only

Classification confidence. Unlike working with automatic classifiers, when working with the script this parameter must be manually specified in page properties.

Example
IClassificationResult result = Classifiers[0].ClassifyPage( Page );
Page.ResultClassName = result.ClassName;
Page.IsResultClassConfident = result.IsConfident;

Page

IPage

Read/write

Document page.

Processing

IProcessingCallback

Read/write

The object for logging the information about processing.

This script classifies pages and adds the name of a class to their properties:
IBatchTypeClassifierResult classifierResult = BatchTypeClassifier.ClassifyPage( Page, null );
Page.ResultClassName = classifierResult.ClassName;
The sample script below allows you to get classification confidence levels:
IClassificationResult result = Classifiers[0].ClassifyPage( Page );
FCTools.ShowMessage( "Class: " + result.ClassName );
Page.ResultClassName = result.ClassName;
FCTools.ShowMessage( "IsConfident: " + result.IsConfident );
Page.IsResultClassConfident = result.IsConfident;
var res0 = Classifiers.Get ( "Batch" ).ClassifyPage( Page );
IClassConfidences classVars = res0.Classes;
foreach( IClassConfidence c in classVars )
{
FCTools.ShowMessage( c.Name + " --> " + c.Confidence.ToString() );
}
FCTools.ShowMessage( "Class res0: " + res0.ClassName);
if (res0.ClassName == "Invoice")
{
var res1 = Classifiers.Get ( "Batch2" ).ClassifyPage( Page );
IClassConfidences classVars1 = res1.Classes;
foreach( IClassConfidence d in classVars1 )
{
FCTools.ShowMessage( d.Name + " --> " + d.Confidence.ToString() );
}
FCTools.ShowMessage( "Class res1: " + res1.ClassName);
Page.ResultClassName = res1.ClassName;
}
else
{
Page.ResultClassName = res0.ClassName;
}
FCTools.ShowMessage( "Page.ResultClassName: " +Page.ResultClassName);
The following script can be used if your scenario does not require documents with a low confidence level to be assigned a class (even if a class has already been specified for them). Such documents should be classified manually by an operator.Important! For the script to work, a new class should be created beforehand — for example, “Unknown”. Then, it should be linked to the document definition in the Class Mapping… dialog. For more information, see Mapping classes to Document Definition sections.
using System;
IClassificationResult result = Classifiers.Get ( "ClassifierBatch" ).ClassifyPage(Page);
Page.ResultClassName = result.ClassName;
IClassConfidences classVars = result.Classes;
Page.Comment = "";
foreach( IClassConfidence c in classVars )
{
    //FCTools.ShowMessage( c.Name + " -- " + c.Confidence.ToString() ); // records the classification confidence value in the event log
    Page.Comment = Page.Comment + c.Name + "-" + c.Confidence.ToString() + "; "; // records the classification confidence value in the page comments
}
if (classVars.Count>0)
{
    if (classVars[0].Confidence<80) Page.IsResultClassConfident=false; // confidence threshold below which a document will be classified as uncertainly classified
    else Page.IsResultClassConfident=true;
if (classVars[0].Confidence<20) Page.ResultClassName="Unknown"; // confidence threshold below which a document will be assigned the "Unknown" class
    if (classVars.Count>1) {
int classesToShow = Math.Min(classVars.Count, 3);
        for(int i=0; i<classesToShow; i++)
{ Page.Comment = Page.Comment + classVars[i].Name + "-" + classVars[i].Confidence.ToString() + "; "; }
    }
}
FCTools.ShowMessage( "Class: " + Page.ResultClassName );
Note: The confidence threshold values in this script are only for demonstration purposes and can be modified by the user depending on a particular workflow.