LEADTOOLS OCR (Leadtools.Forms.Ocr assembly)
LEAD Technologies, Inc

DetectLanguage Method

Example 





The IOcrPage to detect its language.
An array of System.String objects that contain the names of the languages to check for. The language values used throughout the LEADTOOLS OCR toolkit are string values based on RFC 4646 (Windows Vista and later). The name could be an ISO 639 two-letter lowercase culture code associated with a language or a combination of ISO 630 and ISO 3166 two-letter uppercase subculture codes associated with a country or region.
An array of System.Int32 objects updated by the confidences of the languages. The array size must be equivalent to the number of items in languages array. If it is set to null it will be ignored. The confidence value range is between -1 and 100. A value of -1 means the language is not supprted, 0 means it is not confident, and 100 is fully confident.
The minimum confidence value to stop checking other languages when a language confidence is equal to or higher than its value.
Detects the language used in the specified IOcrPage from a list of languages that is provided by the user. .NET support WinRT support
Syntax
int DetectLanguage( 
   IOcrPage page,
   string[] languages,
   int[] confidences,
   int minimumConfidence
)
'Declaration
 
Function DetectLanguage( _
   ByVal page As IOcrPage, _
   ByVal languages() As String, _
   ByVal confidences() As Integer, _
   ByVal minimumConfidence As Integer _
) As Integer
'Usage
 
Dim instance As IOcrLanguageManager
Dim page As IOcrPage
Dim languages() As String
Dim confidences() As Integer
Dim minimumConfidence As Integer
Dim value As Integer
 
value = instance.DetectLanguage(page, languages, confidences, minimumConfidence)
int DetectLanguage( 
   IOcrPage page,
   string[] languages,
   int[] confidences,
   int minimumConfidence
)
function Leadtools.Forms.Ocr.IOcrLanguageManager.DetectLanguage( 
   page ,
   languages ,
   confidences ,
   minimumConfidence 
)
int DetectLanguage( 
   IOcrPage^ page,
   array<String^>^ languages,
   array<int>^ confidences,
   int minimumConfidence
) 

Parameters

page
The IOcrPage to detect its language.
languages
An array of System.String objects that contain the names of the languages to check for. The language values used throughout the LEADTOOLS OCR toolkit are string values based on RFC 4646 (Windows Vista and later). The name could be an ISO 639 two-letter lowercase culture code associated with a language or a combination of ISO 630 and ISO 3166 two-letter uppercase subculture codes associated with a country or region.
confidences
An array of System.Int32 objects updated by the confidences of the languages. The array size must be equivalent to the number of items in languages array. If it is set to null it will be ignored. The confidence value range is between -1 and 100. A value of -1 means the language is not supprted, 0 means it is not confident, and 100 is fully confident.
minimumConfidence
The minimum confidence value to stop checking other languages when a language confidence is equal to or higher than its value.

Return Value

The index of the language with the highest confidence in languages parameter.
Remarks

DetectLanguage is supported in the LEADTOOLS OCR Advantage Engine only.

The DetectLanguage method is a dictionary based method that the recognition confidence has low contribution to its calculations. The confidence of a language without a dictionay is low. To determine whether a given spell language (dictionary) is supported by the current spell checker engine use IOcrSpellCheckManager.IsSpellLanguageSupported. In order to get a list of the languages (dictionaries) supported by the current spell checker engine use IOcrSpellCheckManager.GetSupportedSpellLanguages.

Use the GetSupportedLanguages to obtain a list of the languages supported by the IOcrEngine.

Use the IsLanguageSupported to check if a given language is supported by the IOcrEngine.

Example
Copy CodeCopy Code  
Private Sub DetectLanguageExample(ByVal engine As IOcrEngine, ByVal page As IOcrPage)
    Dim languages As String() = New String(2) {}
    languages(0) = "en"
    languages(0) = "fr"
    languages(0) = "de"
    Dim confidences As Integer() = New Integer(languages.Length - 1) {}
    Dim maxIndex As Integer = engine.LanguageManager.DetectLanguage(page, languages, confidences, 90)
    If maxIndex = -1 Then
        Console.WriteLine("No language has been detected")
    Else
        Console.WriteLine("The page language with the highest confidence is: " & languages(maxIndex) & ", with confidence: " & confidences(maxIndex))
    End If
    Dim i As Integer = 0
    Do While i < languages.Length
        Console.WriteLine("Language: " & languages(i) & ", with confidence: " & confidences(i))
        i += 1
    Loop
End Sub
private void DetectLanguageExample(IOcrEngine engine, IOcrPage page)
{
    string[] languages = new string[3];
    languages[0] = "en";
    languages[0] = "fr";
    languages[0] = "de";
    int[] confidences = new int[languages.Length];
    int maxIndex = engine.LanguageManager.DetectLanguage(page, languages, confidences, 90);
    if (maxIndex == -1)
        Console.WriteLine("No language has been detected");
    else
        Console.WriteLine("The page language with the highest confidence is: " + languages[maxIndex] + ", with confidence: " + confidences[maxIndex]);
    for (int i = 0; i < languages.Length; i++)
        Console.WriteLine("Language: " + languages[i] + ", with confidence: " + confidences[i]);
}
private void DetectLanguageExample(IOcrEngine engine, IOcrPage page)
{
    string[] languages = new string[3];
    languages[0] = "en";
    languages[0] = "fr";
    languages[0] = "de";
    int[] confidences = new int[languages.Length];
    int maxIndex = engine.LanguageManager.DetectLanguage(page, languages, confidences, 90);
    if (maxIndex == -1)
        Debug.WriteLine("No language has been detected");
    else
        Debug.WriteLine("The page language with the highest confidence is: " + languages[maxIndex] + ", with confidence: " + confidences[maxIndex]);
    for (int i = 0; i < languages.Length; i++)
        Debug.WriteLine("Language: " + languages[i] + ", with confidence: " + confidences[i]);
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IOcrLanguageManager Interface
IOcrLanguageManager Members
IOcrLanguageManager Interface
GetSupportedLanguages Method
IsLanguageSupported Method
EnableLanguages Method
IOcrEngine.Startup
IOcrEngine.IsStarted
IOcrEngine.Shutdown
OcrEngineManager Class
OcrEngineType Enumeration
Programming with the LEADTOOLS .NET OCR
Working with OCR Languages
OCR Languages and Spell Checking

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

DetectLanguage requires an OCR module license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features