tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
validate_myanmar.h
1 #ifndef TESSERACT_TRAINING_VALIDATE_MYANMAR_H_
2 #define TESSERACT_TRAINING_VALIDATE_MYANMAR_H_
3 
4 #include "validator.h"
5 
6 namespace tesseract {
7 
8 // Subclass of Validator that validates and segments Myanmar.
9 class ValidateMyanmar : public Validator {
10  public:
11  ValidateMyanmar(ViramaScript script, bool report_errors)
12  : Validator(script, report_errors) {}
14 
15  protected:
16  // Returns whether codes matches the pattern for a Myanmar Grapheme.
17  // Consumes the next Grapheme in codes_[codes_used_++...] and copies it to
18  // parts_ and output_. Returns true if a valid Grapheme was consumed,
19  // otherwise does not increment codes_used_.
20  bool ConsumeGraphemeIfValid() override;
21  // Returns the CharClass corresponding to the given Unicode ch.
23 
24  private:
25  // Helper consumes/copies a virama and any subscript consonant.
26  // Returns true if the end of input is reached.
28  // Helper consumes/copies a series of optional signs.
29  // Returns true if the end of input is reached.
31  // Returns true if the unicode is a Myanmar "letter" including consonants
32  // and independent vowels. Although table 16-3 distinguishes between some
33  // base consonants and vowels, the extensions make no such distinction, so we
34  // put them all into a single bucket.
35  static bool IsMyanmarLetter(char32 ch);
36  // Returns true if ch is a Myanmar digit or other symbol that does not take
37  // part in being a syllable.
38  static bool IsMyanmarOther(char32 ch);
39 
40  // Some special unicodes used only for Myanmar processing.
41  static const char32 kMyanmarAsat = 0x103a;
42  static const char32 kMyanmarMedialYa = 0x103b;
43 };
44 
45 } // namespace tesseract
46 
47 #endif // TESSERACT_TRAINING_VALIDATE_MYANMAR_H_
ValidateMyanmar(ViramaScript script, bool report_errors)
Definition: validate_myanmar.h:11
signed int char32
Definition: unichar.h:52
static bool IsMyanmarOther(char32 ch)
Definition: validate_myanmar.cpp:149
static const char32 kMyanmarAsat
Definition: validate_myanmar.h:41
Definition: baseapi.cpp:94
static const char32 kMyanmarMedialYa
Definition: validate_myanmar.h:42
bool ConsumeSubscriptIfPresent()
Definition: validate_myanmar.cpp:62
ViramaScript
Definition: validator.h:53
Validator::CharClass UnicodeToCharClass(char32 ch) const override
Definition: validate_myanmar.cpp:55
CharClass
Definition: validator.h:112
Definition: validate_myanmar.h:9
bool ConsumeGraphemeIfValid() override
Definition: validate_myanmar.cpp:13
static bool IsMyanmarLetter(char32 ch)
Definition: validate_myanmar.cpp:136
bool ConsumeOptionalSignsIfPresent()
Definition: validate_myanmar.cpp:77
~ValidateMyanmar()
Definition: validate_myanmar.h:13
Definition: validator.h:72