tesseract 4.1.1
Loading...
Searching...
No Matches
validate_grapheme.h
Go to the documentation of this file.
1#ifndef TESSERACT_TRAINING_VALIDATE_GRAPHEME_H_
2#define TESSERACT_TRAINING_VALIDATE_GRAPHEME_H_
3
4#include "validator.h"
5
6namespace tesseract {
7
8// Subclass of Validator that validates and segments generic unicode into
9// grapheme clusters, including Latin with diacritics.
11 public:
12 ValidateGrapheme(ViramaScript script, bool report_errors)
13 : Validator(script, report_errors) {}
15
16 protected:
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.
22 CharClass UnicodeToCharClass(char32 ch) const override;
23
24 private:
25 // Helper returns true if the sequence prev_ch,ch is invalid.
26 bool IsBadlyFormed(char32 prev_ch, char32 ch);
27 // Helper returns true if the sequence prev_ch,ch is an invalid Indic vowel.
28 static bool IsBadlyFormedIndicVowel(char32 prev_ch, char32 ch);
29 // Helper returns true if the sequence prev_ch,ch is invalid Thai.
30 static bool IsBadlyFormedThai(char32 prev_ch, char32 ch);
31};
32
33} // namespace tesseract
34
35#endif // TESSERACT_TRAINING_VALIDATE_GRAPHEME_H_
signed int char32
Definition: unichar.h:51
CharClass UnicodeToCharClass(char32 ch) const override
ValidateGrapheme(ViramaScript script, bool report_errors)
bool ConsumeGraphemeIfValid() override