Skip to content

import_lexiconImportLexiconImportLexiconimport_lexiconT_import_lexicon🔗

Short description🔗

import_lexiconImportLexiconImportLexiconimport_lexiconT_import_lexicon — Create a lexicon from a text file.

Signature🔗

import_lexicon( string Name, filename.read FileName, out lexicon LexiconHandle )void ImportLexicon( const HTuple& Name, const HTuple& FileName, HTuple* LexiconHandle )static void HOperatorSet.ImportLexicon( HTuple name, HTuple fileName, out HTuple lexiconHandle )def import_lexicon( name: str, file_name: str ) -> HHandle

Herror T_import_lexicon( const Htuple Name, const Htuple FileName, Htuple* LexiconHandle )

void HLexicon::HLexicon( const HString& Name, const HString& FileName )

void HLexicon::HLexicon( const char* Name, const char* FileName )

void HLexicon::HLexicon( const wchar_t* Name, const wchar_t* FileName ) (Windows only)

public HLexicon( string name, string fileName )

void HLexicon::ImportLexicon( const HString& Name, const HString& FileName )

void HLexicon::ImportLexicon( const char* Name, const char* FileName )

void HLexicon::ImportLexicon( const wchar_t* Name, const wchar_t* FileName ) (Windows only)

void HLexicon.ImportLexicon( string name, string fileName )

Description🔗

import_lexiconImportLexicon creates a new lexicon based on a list of words in the file specified by FileNamefileNamefile_name. The format of the file is a simple text file with one word per line. By specifying a unique textual Namenamename, you can later refer to the lexicon from syntax expressions like those used, e.g., by do_ocr_word_mlpDoOcrWordMlp.

Note that lexicon support in HALCON is currently not aimed at natural languages. Rather, it is intended as a post-processing step in OCR applications that only need to distinguish between a limited set of not more than a few thousand valid words, e.g., country or product names. When the lexicon file contains entries with special, non-ASCII characters, it is expected to be encoded in UTF-8. However, old lexicon files which use the local 8-bit encoding, can still be loaded as long as they contain at least one byte sequence, which cannot be misinterpreted as UTF-8 character. MVTec itself does not provide any lexica.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.

Parameters🔗

Namenamename (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Unique name for the new lexicon.

Default: 'lex1'"lex1"

FileNamefileNamefile_name (input_control) filename.read → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Name of a text file containing words for the new lexicon.

Default: 'words.txt'"words.txt"
File extension: .txt

LexiconHandlelexiconHandlelexicon_handle (output_control) lexicon → (handle)HTuple (HHandle)HLexicon, HTuple (IntPtr)HHandleHtuple (handle)

Handle of the lexicon.

Combinations with other operators🔗

Combinations

Possible successors

do_ocr_word_mlpDoOcrWordMlp, do_ocr_word_svmDoOcrWordSvm

Alternatives

create_lexiconCreateLexicon

See also

lookup_lexiconLookupLexicon, suggest_lexiconSuggestLexicon

Module🔗

OCR/OCV