Skip to main content

ExternalTransformer

Transforms a document using an external application to do so

Notesโ€‹

Executing an external application to extract data from and/or manipulate a document.

Command-line arguments:โ€‹

When constructing the command to launch the external application, it will look for specific tokens to be replaced by file paths arguments (in addition to other arguments you may have). The path arguments are created by this class. They are case-sensitive and the file they represent are temporary (will be deleted after they have been dealt with). It is possible to omit one or more tokens to use standard streams instead where applicable.

Tokens supported by:โ€‹

${INPUT}

Path to document to be handled by the external application. When omitted, the document content is sent to the external application using the standard input stream (STDIN).

${INPUT_META}

Path to file containing metadata information available so far for the document to be handled by the external application. By default in JSON format. When omitted, no metadata will be made available to the external application.

${REFERENCE}

Unique reference to the document being handled (URL, original file system location, etc.). When omitted, the document reference will not be made available to the external application.

There is no ${OUTPUT} token since transformers do not modify document content (only metadata).

To parse/extract raw text from files, it is recommended to use ExternalParser instead.

Parser Handler Compatibilityโ€‹

This functionality can be applied as either a pre-parse or post-parse handler.

Examplesโ€‹

The following example invokes an external application that accepts a document to transform and outputs a file containing the new metadata information.

handler:
class: ExternalTransformer
command: /path/tag/app ${INPUT} ${OUTPUT_META}

Usageโ€‹

Full configuration skeleton, with every option and its default
class: ExternalTransformer
command: string
environmentVariables: {}
extractionPatterns:
- fieldGroup: 0
onSet: APPEND
regex: {}
toField: string
valueGroup: 0
label: string
metadataInputFormat: string
metadataOutputFormat: string
onSet: APPEND
tempDir: string

Propertiesโ€‹

PropertyTypeRequiredDefault
commandstringNo-
environmentVariablesRecord<string, string>No-
extractionPatternsRegexFieldValueExtractor[]No-
labelstringNo-
metadataInputFormatstringNo-
metadataOutputFormatstringNo-
onSetenumNo-
tempDirstringNo-

Property Detailsโ€‹

commandโ€‹

The command line to execute, with $&#123;INPUT&#125; and $&#123;OUTPUT&#125; placeholders for the document going in and coming out. Escape spaces in the executable path and its arguments.

Sample command lineโ€‹

c:\Apps\myapp.exe ${INPUT} ${INPUT_META} ${OUTPUT_META} ${REFERENCE}

environmentVariablesโ€‹

Defines environment variables to set when executing the external command.

extractionPatternsโ€‹

Pattern only used when metadataOutputFormat is not specified

labelโ€‹

An optional, user-supplied label for this step in the importer pipeline. It has no effect on processing โ€” it exists purely to help identify this step, for example in large configurations or in the visual configurator.

metadataInputFormatโ€‹

Sets the format of the metadata input file sent to the external application. One of json (default), xml, or properties is expected. Only applicable when the $&#123;INPUT_META&#125; token is part of the command.

metadataOutputFormatโ€‹

Sets the format of the metadata output file from the external application. One of json (default), xml, or properties is expected. Set to null for relying on metadata extraction patterns instead. Only applicable when the $&#123;OUTPUT_META&#125; token is part of the command.

onSetโ€‹

What to do if a target field of the same name already exist.

Allowed Valuesโ€‹

  • APPEND
  • PREPEND
  • REPLACE
  • OPTIONAL

tempDirโ€‹

Sets the directory where to store temporary files used for the process.