"Fossies" - the Fresh Open Source Software Archive

Member "tesseract-ocr/doc/html/char__altlist_8h_source.html" (26 Oct 2012, 19496 Bytes) of package /linux/misc/old/tesseract-ocr-3.02.02-doc-html.tar.gz:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the tesseract-ocr-3.02.02-doc-html.tar.gz project site itself.

Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
char_altlist.h
Go to the documentation of this file.
1 /**********************************************************************
2  * File: char_altlist.h
3  * Description: Declaration of a Character Alternate List Class
4  * Author: Ahmad Abdulkader
5  * Created: 2007
6  *
7  * (C) Copyright 2008, Google Inc.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  **********************************************************************/
19 
20 #ifndef CHAR_ALT_LIST_H
21 #define CHAR_ALT_LIST_H
22 
23 // The CharAltList class holds the list of class alternates returned from
24 // a character classifier. Each alternate represents a class ID.
25 // It inherits from the AltList class.
26 // The CharAltList owns a CharSet object that maps a class-id to a string.
27 
28 #include "altlist.h"
29 #include "char_set.h"
30 
31 namespace tesseract {
32 class CharAltList : public AltList {
33  public:
34  CharAltList(const CharSet *char_set, int max_alt = kMaxCharAlt);
35  ~CharAltList();
36 
37  // Sort the alternate list based on cost
38  void Sort();
39  // insert a new alternate with the specified class-id, cost and tag
40  bool Insert(int class_id, int cost, void *tag = NULL);
41  // returns the cost of a specific class ID
42  inline int ClassCost(int class_id) const {
43  if (class_id_cost_ == NULL ||
44  class_id < 0 ||
45  class_id >= char_set_->ClassCount()) {
46  return WORST_COST;
47  }
48  return class_id_cost_[class_id];
49  }
50  // returns the alternate class-id corresponding to an alternate index
51  inline int Alt(int alt_idx) const { return class_id_alt_[alt_idx]; }
52  // set the cost of a certain alternate
53  void SetAltCost(int alt_idx, int cost) {
54  alt_cost_[alt_idx] = cost;
55  class_id_cost_[class_id_alt_[alt_idx]] = cost;
56  }
57 
58  private:
59  // character set object. Passed at construction time
60  const CharSet *char_set_;
61  // array of alternate class-ids
62  int *class_id_alt_;
63  // array of alternate costs
64  int *class_id_cost_;
65  // default max count of alternates
66  static const int kMaxCharAlt = 256;
67 };
68 }
69 
70 #endif // CHAR_ALT_LIST_H