Customizing a Field Type

During application development, you need to select a field type when box-selecting a recognition area. If the box-selected text is a number, you can select the default field type Number.

If the default field types cannot meet your service requirements, you can create a field type.

Prerequisites

You have created an application using the general single-template workflow on the OCR Suite console. For details, see Creating an Application.

Procedure

  1. Log in to the ModelArts Pro > OCR Suite console.

    The AppDev > Workbench page is displayed by default.

  2. On the My Applications page, locate the desired application and click View in the Operation column.

    Go to the Application Assets page.

  3. Click Custom Field Types The Custom Field Types page is displayed.
  4. Click Create Field Type in the upper left corner.

    The Create Field Type dialog box is displayed.

  5. Specify related parameters.
    Figure 1 Creating a field type

    Field Type Name: Enter the name of a field type to be created. For example, if you want to recognize an image of an ID card, you can create a field type named Birthday.

    Field Attribute: Select a field attribute from the drop-down list. The options are Custom regular expression extraction or Custom dictionary, and then enter related information by referring to Table 1.

    Table 1 Parameters of a field attribute

    Field Attribute

    Parameter

    Description

    Example Value

    Custom dictionary

    Value Range

    When recognizing text of the current field type, select the most similar value in the value range of the dictionary as the final recognition result.

    For example,

    Field Type Name: City

    Field Attribute: Custom dictionary

    Value Range: Shenzhen, Beijing, and Xi'an

    When the field type of the text to be recognized is City, a value most similar to the text to be recognized is selected as the recognition result from values Shenzhen, Beijing, and Xi'an.

    Custom regular expression extraction

    Pre-filter

    Preprocess the to-be-recognized text.

    Enter a regular expression of text to be replaced in the text box on the left.

    Enter new text in the text box on the right.

    If this field is left blank, no preprocessing is performed by default.

    If you need to preprocess the text for multiple times, click and enter new preprocessing rule.

    For example,

    Field Type Name: Birthday

    Field Attribute: Custom regular expression extraction

    Pre-filter: /

    Extract: \year\month\day

    Post-process: year /.day/. or

    day/year month

    When the text Born on 2020 January 01 whose field type is Birthday is recognized, do not perform pre-filtering, extract key characters 2020 January 01, and finally post-process the key characters, and finally the extracted content is 2020.1.1.

    Extract

    Extract key characters from the preprocessed text.

    Enter a regular expression for searching for key characters in the text box.

    If this field is left blank, all fields will be extracted by default.

    If multiple extraction rules are required, click to add extraction rules. During extraction, the first non-empty content is selected as the extracted content based on the priority rule from top to bottom.

    Post-process

    Post-process the extracted text based on your needs.

You can also create a field type by choosing Application Development > Box-select Recognition. For details, see Creating a Field Type.