tesseract  4.0.0-1-g2a2b
validate_myanmar.h
Go to the documentation of this file.
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.
27  bool ConsumeSubscriptIfPresent();
28  // Helper consumes/copies a series of optional signs.
29  // Returns true if the end of input is reached.
30  bool ConsumeOptionalSignsIfPresent();
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_
bool ConsumeGraphemeIfValid() override
signed int char32
Definition: unichar.h:52
Validator::CharClass UnicodeToCharClass(char32 ch) const override
ValidateMyanmar(ViramaScript script, bool report_errors)