tesseract  5.0.0-alpha-619-ge9db
validate_javanese.h
Go to the documentation of this file.
1 /**********************************************************************
2  * File: validate_javanese.h
3  * Description: Text validator for Javanese Script - aksara jawa.
4  * Author: Shree Devi Kumar
5  * Created: August 03, 2018
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * http://www.apache.org/licenses/LICENSE-2.0
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  **********************************************************************/
18 
19 #ifndef TESSERACT_TRAINING_VALIDATE_JAVANESE_H_
20 #define TESSERACT_TRAINING_VALIDATE_JAVANESE_H_
21 
22 #include "validator.h"
23 
24 
25 namespace tesseract {
26 
27 // Subclass of Validator that validates and segments Javanese scripts
28 
29 class ValidateJavanese : public Validator {
30  public:
31  ValidateJavanese(ViramaScript script, bool report_errors)
32  : Validator(script, report_errors) {}
34 
35  protected:
36  // Returns whether codes matches the pattern for an Javanese Grapheme.
37  // Consumes the next Grapheme in codes_[codes_used_++...] and copies it to
38  // parts_ and output_. Returns true if a valid Grapheme was consumed,
39  // otherwise does not increment codes_used_.
40  bool ConsumeGraphemeIfValid() override;
41  // Returns the CharClass corresponding to the given Unicode ch.
43 
44  private:
45  // Helper consumes/copies a virama and any associated post-virama joiners.
46  bool ConsumeViramaIfValid(IndicPair joiner, bool post_matra);
47  // Helper consumes/copies a series of consonants separated by viramas while
48  // valid, but not any vowel or other modifiers.
49  bool ConsumeConsonantHeadIfValid();
50  // Helper consumes/copies a tail part of a consonant, comprising optional
51  // matra/piece, vowel modifier, vedic mark, terminating virama.
52  bool ConsumeConsonantTailIfValid();
53  // Helper consumes/copies a vowel and optional modifiers.
54  bool ConsumeVowelIfValid();
55 
56  // Some special unicodes used only for Javanese processing.
57  static const char32 kPengkal = 0xa9be; // Javanese Ya
58  static const char32 kCakra = 0xa9bf; // Javanese Ra
59 };
60 
61 } // namespace tesseract
62 
63 #endif // TESSERACT_TRAINING_VALIDATE_JAVANESE_H_
tesseract::ValidateJavanese::ValidateJavanese
ValidateJavanese(ViramaScript script, bool report_errors)
Definition: validate_javanese.h:60
tesseract::ValidateJavanese::UnicodeToCharClass
Validator::CharClass UnicodeToCharClass(char32 ch) const override
Definition: validate_javanese.cpp:270
tesseract::ValidateJavanese::ConsumeGraphemeIfValid
bool ConsumeGraphemeIfValid() override
Definition: validate_javanese.cpp:53
tesseract::Validator::IndicPair
std::pair< CharClass, char32 > IndicPair
Definition: validator.h:148
tesseract::ViramaScript
ViramaScript
Definition: validator.h:67
tesseract::Validator::CharClass
CharClass
Definition: validator.h:126
validator.h
tesseract::char32
signed int char32
Definition: unichar.h:53
tesseract
Definition: baseapi.h:65
char32
signed int char32
Definition: pango_font_info.h:33
tesseract::ValidateJavanese::~ValidateJavanese
~ValidateJavanese()
Definition: validate_javanese.h:62
tesseract::Validator::Validator
Validator(ViramaScript script, bool report_errors)
Definition: validator.h:150