Tesseract  3.02
tesseract-ocr/cube/lang_mod_edge.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        lang_mod_edge.h
00003  * Description: Declaration of the Language Model Edge Base Class
00004  * Author:    Ahmad Abdulkader
00005  * Created:   2007
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 LangModEdge abstracts an Edge in the language model trie
00021 // This is an abstract class that any Language Model Edge should inherit from
00022 // It provides methods for:
00023 // 1- Returns the class ID corresponding to the edge
00024 // 2- If the edge is a valid EndOfWord (EOW)
00025 // 3- If the edge is coming from a OutOfDictionary (OOF) state machine
00026 // 4- If the edge is a Terminal (has no children)
00027 // 5- A Hash of the edge that will be used to retrieve the edge
00028 // quickly from the BeamSearch lattice
00029 // 6- If two edges are identcial
00030 // 7- Returns a verbal description of the edge (use by debuggers)
00031 // 8- the language model cost of the edge (if any)
00032 // 9- The string corresponding to this edge
00033 // 10- Getting and setting the "Root" status of the edge
00034 
00035 #ifndef LANG_MOD_EDGE_H
00036 #define LANG_MOD_EDGE_H
00037 
00038 #include "cube_tuning_params.h"
00039 #include "char_set.h"
00040 
00041 namespace tesseract {
00042 
00043 class LangModEdge {
00044  public:
00045    LangModEdge() {}
00046   virtual ~LangModEdge() {}
00047 
00048   // The string corresponding to this edge
00049   virtual const char_32 * EdgeString() const = 0;
00050   // Returns the class ID corresponding to the edge
00051   virtual int ClassID() const = 0;
00052   // If the edge is the root edge
00053   virtual bool IsRoot() const = 0;
00054   // Set the Root flag
00055   virtual void SetRoot(bool flag) = 0;
00056   // If the edge is a valid EndOfWord (EOW)
00057   virtual bool IsEOW() const = 0;
00058   // is the edge is coming from a OutOfDictionary (OOF) state machine
00059   virtual bool IsOOD() const = 0;
00060   // Is the edge is a Terminal (has no children)
00061   virtual bool IsTerminal() const = 0;
00062   // Returns A hash of the edge that will be used to retrieve the edge
00063   virtual unsigned int Hash() const = 0;
00064   // Are the two edges identcial?
00065   virtual bool IsIdentical(LangModEdge *edge) const = 0;
00066   // a verbal description of the edge (use by debuggers)
00067   virtual char *Description() const = 0;
00068   // the language model cost of the edge (if any)
00069   virtual int PathCost() const = 0;
00070 };
00071 }
00072 
00073 #endif  // LANG_MOD_EDGE_H