←Select platform

AddUserWords Method

Summary
Adds user words to a language dictionary.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public void AddUserWords( 
   string language, 
   string[] words 
) 
- (void)addUserWords:(LTOcrLanguage)language 
               words:(NSArray<NSString *> *)words 
               error:(NSError **)error 
public void addUserWords(String language, 
                         ArrayList<String> words) 
void AddUserWords(  
   String^ language, 
   array<String^>^ words 
)  
def AddUserWords(self,language,words): 

Parameters

language
The language name. For more information about the format of language names, refer to IOcrLanguageManager.

words
Array of words to add.

Remarks

Only supported by the LEADTOOLS OCR Module - LEAD Engine.

Use this method to add user words to the current loaded dictionary. Note that the OCR engine does not automatically correct the misspelling of words unless the confidence of the characters are low.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Forms.Common; 
using Leadtools.Ocr; 
using Leadtools.Drawing; 
 
public void AddUserWordsExample() 
{ 
   // 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; 
 
      // Add the following words to the English dictionary 
      string[] newWord = { "OMRing", "Binarization" }; 
      spellCheckManager.AddUserWords("en", newWord); 
 
      // 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 IOcrSpellCheckManagerAddUserWordsExample() { 
   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(); 
 
   // Add the following words to the English dictionary 
   String[] newWord = { "OMRing", "Binarization" }; 
   spellCheckManager.addUserWords("en", newWord); 
 
   // Shutdown the engine 
   // Note: calling Dispose will also automatically shutdown the engine if it has 
   // been started 
   ocrEngine.shutdown(); 
   ocrEngine.dispose(); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.4.19
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.