Connector Framework Server 25.4
Connector Framework Server Help

# lang_detect

The function `lang_detect` performs language detection on a document.

## Syntax

    lang_detect(document, params)

## Arguments

Argument | Description
--- | ---
`document` | (LuaDocument) The document to analyze.
`params` | (table) A table of named parameters to configure language detection. The table maps parameter names (String) to parameter values. For information about the parameters that you can set, see the following table.

## Named Parameters

Named Parameter | Description | Configuration Parameter
--- | --- | ---
`section` | (string) The name of a section in the CFS configuration file. If you set this then any parameters not set in the `params` table are read from this section of the configuration file. |
`language_detection_directory` | (string) The path of the directory that contains the `langdetect.dat` file, which is required for language detection. | LanguageDetectionDirectory
`output_field` | (string) The name of the document field to write the name of the detected language to. | OutputField

## Returns

(Boolean). Returns true if the language was successfully detected and added to the specified document field. Returns false if the language could not be detected.

## Example

The following Lua script performs language detection on a document and writes the result to a document field named `DetectedLanguage`. If the language cannot be detected the script adds the field with the value `UNKNOWN`.

    function handler(document)
        if(not lang_detect(document, {language_detection_directory="C:/langdetect/", output_field="DetectedLanguage"})) then
            document:addField("DetectedLanguage", "UNKNOWN")
        end
        return true
    end

Copyright 2025 Open Text
Version 25.4 | Last updated October 2025

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery Connector Framework Server 25.4

Topic Title: lang_detect