←Select platform

OcrSpellCheckEngine Enumeration

Summary
OCR Spell Checker Type
Syntax
C#
Objective-C
C++/CLI
Java
Python
public enum OcrSpellCheckEngine 
typedef NS_ENUM(NSInteger, LTOcrSpellCheckEngine) { 
 LTOcrSpellCheckEngineNone = 0,  
 LTOcrSpellCheckEngineNative 
}; 
public enum OcrSpellCheckEngine 
public enum class OcrSpellCheckEngine 
class OcrSpellCheckEngine(Enum): 
   None = 0 
   Native = 1 
   OS = 2 
   Hunspell = 3 
Members
ValueMemberDescription
0None No spell checker (disables the spell check sub system)
1Native Native engine spell checker.
2OS The operating system spell checker.
3Hunspell Hunspell spell checker.
Remarks

Refer to IOcrSpellCheckManager for more information about the types of spell check engines available and any restrictions.

Set IOcrSpellCheckManager.SpellCheckEngine to OcrSpellCheckEngine.None to disable the spell checking sub system. Only one spell check language can be enabled at a time using IOcrSpellCheckManager.SpellLanguage.

The OcrEngineType.LEAD engine supports all OcrSpellCheckEngine types. User words and dictionaries are supported and the engine automatically loads the dictionaries based on the language(s) currently enabled in IOcrLanguageManager. IOcrSpellCheckManager.SpellLanguage is not used and will have no effect.

The following information is only for the OcrEngineType.LEAD engine.

All LEADTOOLS OCR Module - LEAD Engine spell checker engines support adding user words to create custom dictionaries through IOcrSpellCheckManager.AddUserWords.

The OcrSpellCheckEngine.Native engine uses the internal LEADTOOLS cross-platform spell checker. The dictionary files ship with LEADTOOLS in the LEAD OCR runtime in the following format LEAD.[Language].dic where [Language] is the specific language (such as "en" for English or "de" for German). This engine has no extra dependencies, except for the dictionary files.

The OcrSpellCheckEngine.OS engine uses the Operating System-specific spell checker, if any. In the Windows environment, this is the .NET spell checker (requires .NET 3.0 or later to be installed on the machine) which supports only English, French, German and Spanish. In order to use this engine, Leadtools.SpellCheckers.OS.dll must exist in the Bin folder next to the Leadtools.Ocr.LEADEngine.dll.

The OcrSpellCheckEngine.Hunspell uses the popular Hunspell spell checker (using the standard .NET NHunspell wrapper). The LEADTOOLS setup does not contain the NHunspell binaries or any language dictionaries. Download the required assemblies from the NHunspell page as well as the dictionaries for the languages you are interested in. Visit the NHunspell home page at https://www.nuget.org/packages/NHunspell/ for more information.

Using Hunspell Engine with LEADTOOLS OCR Module - LEAD Engine

The following prerequisites must exist in order for you to use the Hunspell engine with LEADTOOLS OCR Module - LEAD Engine:

  • The Leadtools.SpellCheckers.Hunspell.dll assembly must be in the Bin folder next to Leadtools.Ocr.LEADEngine.dll.

  • NHunspell.dll: NHunspell .NET wrapper. Must be in the bin folder next to Leadtools.SpellCheckers.Hunspell.dll.

  • Hunspellx86.dll or Hunspellx64.dll: Hunspell native DLL. The correct version for your platform must exist in the LEADTOOLS OCR Module - LEAD Engine runtime folder. By default, the location is:

    <LEADTOOLS\_INSTALLDIR\>\\Bin\\Common\\OcrLEADRuntime
  • lang.aff and lang.dic dictionary files: Language dictionary files for the Hunspell engine. Visit https://wiki.openoffice.org/wiki/Dictionaries to download the files for the languages you are interested in. You can use the same name as the original dictionary file, for example, "en_US" for English US dictionary. The dictionary file must reside in the LEADTOOLS OCR Module - LEAD Engine runtime folder. By default, the location is:

    <LEADTOOLS\_INSTALLDIR\>\\Bin\\Common\\OcrLEADRuntime
Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Forms.Common; 
using Leadtools.Ocr; 
using Leadtools.Drawing; 
 
public void OcrSpellCheckManagerExample() 
{ 
   // Create an instance of the engine 
   using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD)) 
   { 
      // Start the engine using default parameters 
      ocrEngine.Startup(null, null, null, LEAD_VARS.OcrLEADRuntimeDir); 
 
      IOcrSpellCheckManager spellCheckManager = ocrEngine.SpellCheckManager; 
 
      // Get the spell language supported (languages with a dictionary) 
      string[] spellLanguages = spellCheckManager.GetSupportedSpellLanguages(); 
      foreach (string spellLanguage in spellLanguages) 
         Console.WriteLine(spellLanguage); 
 
      // Check if English is supported 
      string language = "en"; 
      if (spellCheckManager.IsSpellLanguageSupported(language)) 
      { 
         // Yes, set it 
         spellCheckManager.SpellLanguage = language; 
         Console.WriteLine("Current spell language: {0}", spellCheckManager.SpellLanguage); 
      } 
 
      // Enable the spell checking system 
      spellCheckManager.SpellCheckEngine = OcrSpellCheckEngine.Native; 
 
      // Now perform other OCR functions here 
 
      // Shutdown the engine 
      // Note: calling Dispose will also automatically shutdown the engine if it has been started 
      ocrEngine.Shutdown(); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string OcrLEADRuntimeDir = @"C:\LEADTOOLS23\Bin\Common\OcrLEADRuntime"; 
} 
 
import java.io.File; 
import java.io.IOException; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.ocr.*; 
 
 
public void IOcrSpellCheckManagerExample() { 
   final String OCR_LEAD_RUNTIME_DIR = "C:\\LEADTOOLS23\\Bin\\Common\\OcrLEADRuntime"; 
   OcrEngine ocrEngine = OcrEngineManager.createEngine(OcrEngineType.LEAD); 
 
   // Start the engine using default parameters 
   ocrEngine.startup(null, null, null, OCR_LEAD_RUNTIME_DIR); 
   assertTrue("OCR engine failed to start", ocrEngine.isStarted()); 
 
   OcrSpellCheckManager spellCheckManager = ocrEngine.getSpellCheckManager(); 
 
   // Get the spell language supported (languages with a dictionary) 
   String[] spellLanguages = spellCheckManager.getSupportedSpellLanguages(); 
   for (var spellLanguage : spellLanguages) 
      System.out.println(spellLanguage); 
 
   // Check if English is supported 
   String language = "en"; 
   if (spellCheckManager.isSpellLanguageSupported(language)) { 
      // Yes, set it 
      spellCheckManager.setSpellLanguage(language); 
      System.out.println("Current spell language: " + spellCheckManager.getSpellLanguage()); 
   } 
 
   // Enable the spell checking system 
   spellCheckManager.setSpellCheckEngine(OcrSpellCheckEngine.NATIVE); 
   assertTrue("Spell checking system unsuccessfully enabled", spellCheckManager.getSpellCheckEngine() == OcrSpellCheckEngine.NATIVE); 
 
   // Shutdown the engine 
   // Note: calling Dispose will also automatically shutdown the engine if it has 
   // been started 
   ocrEngine.shutdown(); 
   ocrEngine.dispose(); 
} 
Requirements

Target Platforms

See Also

Reference

Leadtools.Ocr Namespace

Help Version 23.0.2024.3.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Ocr Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.