Skip to content

Commit d359d89

Browse files
committed
Simplify code for osdetect
Remove the private static char pointers from osdetect.h. This does not break the API because the removed pointers are no member variables, and they could not be accessed because they were private. As all script names were used only once, there is also no need to have additional pointer constants, and using the names directly simplifies the code. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 647da29 commit d359d89

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

include/tesseract/osdetect.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ class ScriptDetector {
101101

102102
private:
103103
OSResults *osr_;
104-
static const char *korean_script_;
105-
static const char *japanese_script_;
106-
static const char *fraktur_script_;
107104
int korean_id_;
108105
int japanese_id_;
109106
int katakana_id_;

src/ccmain/osdetect.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,6 @@ const float kHanRatioInJapanese = 0.3;
4848

4949
const float kNonAmbiguousMargin = 1.0;
5050

51-
// General scripts
52-
static const char *han_script = "Han";
53-
static const char *latin_script = "Latin";
54-
static const char *katakana_script = "Katakana";
55-
static const char *hiragana_script = "Hiragana";
56-
static const char *hangul_script = "Hangul";
57-
58-
// Pseudo-scripts Name
59-
const char *ScriptDetector::korean_script_ = "Korean";
60-
const char *ScriptDetector::japanese_script_ = "Japanese";
61-
const char *ScriptDetector::fraktur_script_ = "Fraktur";
62-
6351
void OSResults::update_best_orientation() {
6452
float first = orientations[0];
6553
float second = orientations[1];
@@ -450,14 +438,16 @@ ScriptDetector::ScriptDetector(const std::vector<int> *allowed_scripts, OSResult
450438
osr_ = osr;
451439
tess_ = tess;
452440
allowed_scripts_ = allowed_scripts;
453-
katakana_id_ = tess_->unicharset.add_script(katakana_script);
454-
hiragana_id_ = tess_->unicharset.add_script(hiragana_script);
455-
han_id_ = tess_->unicharset.add_script(han_script);
456-
hangul_id_ = tess_->unicharset.add_script(hangul_script);
457-
japanese_id_ = tess_->unicharset.add_script(japanese_script_);
458-
korean_id_ = tess_->unicharset.add_script(korean_script_);
459-
latin_id_ = tess_->unicharset.add_script(latin_script);
460-
fraktur_id_ = tess_->unicharset.add_script(fraktur_script_);
441+
// General scripts
442+
katakana_id_ = tess_->unicharset.add_script("Katakana");
443+
hiragana_id_ = tess_->unicharset.add_script("Hiragana");
444+
han_id_ = tess_->unicharset.add_script("Han");
445+
hangul_id_ = tess_->unicharset.add_script("Hangul");
446+
latin_id_ = tess_->unicharset.add_script("Latin");
447+
// Pseudo-scripts
448+
fraktur_id_ = tess_->unicharset.add_script("Fraktur");
449+
japanese_id_ = tess_->unicharset.add_script("Japanese");
450+
korean_id_ = tess_->unicharset.add_script("Korean");
461451
}
462452

463453
// Score the given blob and return true if it is now sure of the script after

0 commit comments

Comments
 (0)