comparison mupdf-source/thirdparty/tesseract/src/training/unicharset/validate_indic.h @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 #ifndef TESSERACT_TRAINING_VALIDATE_INDIC_H_
2 #define TESSERACT_TRAINING_VALIDATE_INDIC_H_
3
4 #include "validator.h"
5
6 namespace tesseract {
7
8 // Subclass of Validator that validates and segments Indic scripts in the
9 // unicode range 0x900-0xdff (Devanagari-Sinhala).
10 class ValidateIndic : public Validator {
11 public:
12 ValidateIndic(ViramaScript script, bool report_errors) : Validator(script, report_errors) {}
13 ~ValidateIndic() override = default;
14
15 protected:
16 // Returns whether codes matches the pattern for an Indic 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.
22 Validator::CharClass UnicodeToCharClass(char32 ch) const override;
23
24 private:
25 // Helper consumes/copies a virama and any associated post-virama joiners.
26 bool ConsumeViramaIfValid(IndicPair joiner, bool post_matra);
27 // Helper consumes/copies a series of consonants separated by viramas while
28 // valid, but not any vowel or other modifiers.
29 bool ConsumeConsonantHeadIfValid();
30 // Helper consumes/copies a tail part of a consonant, comprising optional
31 // matra/piece, vowel modifier, vedic mark, terminating virama.
32 bool ConsumeConsonantTailIfValid();
33 // Helper consumes/copies a vowel and optional modifiers.
34 bool ConsumeVowelIfValid();
35
36 // Some special unicodes used only for Indic processing.
37 static const char32 kYayana = 0xdba; // Sinhala Ya
38 static const char32 kRayana = 0xdbb; // Sinhala Ra
39 };
40
41 } // namespace tesseract
42
43 #endif // TESSERACT_TRAINING_VALIDATE_INDIC_H_