Tesseract  3.02
tesseract-ocr/cube/word_altlist.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        word_altlist.h
00003  * Description: Declaration of the Word Alternate List Class
00004  * Author:    Ahmad Abdulkader
00005  * Created:   2008
00006  *
00007  * (C) Copyright 2008, Google Inc.
00008  ** Licensed under the Apache License, Version 2.0 (the "License");
00009  ** you may not use this file except in compliance with the License.
00010  ** You may obtain a copy of the License at
00011  ** http://www.apache.org/licenses/LICENSE-2.0
00012  ** Unless required by applicable law or agreed to in writing, software
00013  ** distributed under the License is distributed on an "AS IS" BASIS,
00014  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  ** See the License for the specific language governing permissions and
00016  ** limitations under the License.
00017  *
00018  **********************************************************************/
00019 
00020 // The WordAltList abstracts a alternate list of words and their corresponding
00021 // costs that result from the word recognition process. The class inherits
00022 // from the AltList class
00023 // It provides methods to add a new word alternate, its corresponding score and
00024 // a tag.
00025 
00026 #ifndef WORD_ALT_LIST_H
00027 #define WORD_ALT_LIST_H
00028 
00029 #include "altlist.h"
00030 
00031 namespace tesseract {
00032 class WordAltList : public AltList {
00033  public:
00034   explicit WordAltList(int max_alt);
00035   ~WordAltList();
00036   // Sort the list of alternates based on cost
00037   void Sort();
00038   // insert an alternate word with the specified cost and tag
00039   bool Insert(char_32 *char_ptr, int cost, void *tag = NULL);
00040   // returns the alternate string at the specified position
00041   inline char_32 * Alt(int alt_idx) { return word_alt_[alt_idx]; }
00042   // print each entry of the altlist, both UTF8 and unichar ids, and
00043   // their costs, to stderr
00044   void PrintDebug();
00045  private:
00046   char_32 **word_alt_;
00047 };
00048 }  // namespace tesseract
00049 
00050 #endif  // WORD_ALT_LIST_H