tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
validate_javanese.h
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.
50  // Helper consumes/copies a tail part of a consonant, comprising optional
51  // matra/piece, vowel modifier, vedic mark, terminating virama.
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_
Validator::CharClass UnicodeToCharClass(char32 ch) const override
Definition: validate_javanese.cpp:257
ValidateJavanese(ViramaScript script, bool report_errors)
Definition: validate_javanese.h:31
signed int char32
Definition: unichar.h:52
bool ConsumeViramaIfValid(IndicPair joiner, bool post_matra)
Definition: validate_javanese.cpp:73
bool ConsumeConsonantHeadIfValid()
Definition: validate_javanese.cpp:145
Definition: validate_javanese.h:29
bool ConsumeGraphemeIfValid() override
Definition: validate_javanese.cpp:40
Definition: baseapi.cpp:94
std::pair< CharClass, char32 > IndicPair
Definition: validator.h:134
static const char32 kPengkal
Definition: validate_javanese.h:57
ViramaScript
Definition: validator.h:53
CharClass
Definition: validator.h:112
bool ConsumeVowelIfValid()
Definition: validate_javanese.cpp:242
~ValidateJavanese()
Definition: validate_javanese.h:33
static const char32 kCakra
Definition: validate_javanese.h:58
bool ConsumeConsonantTailIfValid()
Definition: validate_javanese.cpp:207
Definition: validator.h:72