mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-24 02:59:07 +08:00
Rename UnicityTable<T>::get_id to UnicityTable<T>::get_index
This prepares replacing UnicityTable<FontInfo> by FontInfoTable. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
c9f42ce62b
commit
553ab64d8d
@ -412,7 +412,7 @@ static void CollectFonts(const UnicityTable<FontInfo> &new_fonts,
|
||||
// Helper assigns an id to lang_fonts using the index in all_fonts table.
|
||||
static void AssignIds(const UnicityTable<FontInfo> &all_fonts, UnicityTable<FontInfo> *lang_fonts) {
|
||||
for (int i = 0; i < lang_fonts->size(); ++i) {
|
||||
int index = all_fonts.get_id(lang_fonts->at(i));
|
||||
auto index = all_fonts.get_index(lang_fonts->at(i));
|
||||
lang_fonts->at(i).universal_id = index;
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,9 @@ public:
|
||||
/// Return the id of the T object.
|
||||
/// This method NEEDS a compare_callback to be passed to
|
||||
/// set_compare_callback.
|
||||
int get_id(T object) const;
|
||||
int get_index(T object) const {
|
||||
return table_.get_index(object);
|
||||
}
|
||||
|
||||
/// Return true if T is in the table
|
||||
bool contains(T object) const;
|
||||
@ -124,22 +126,16 @@ T UnicityTable<T>::contains_id(int id) const {
|
||||
return table_.contains_index(id);
|
||||
}
|
||||
|
||||
// Return the id of the T object.
|
||||
template <typename T>
|
||||
int UnicityTable<T>::get_id(T object) const {
|
||||
return table_.get_index(object);
|
||||
}
|
||||
|
||||
// Return true if T is in the table
|
||||
template <typename T>
|
||||
bool UnicityTable<T>::contains(T object) const {
|
||||
return get_id(object) != -1;
|
||||
return get_index(object) != -1;
|
||||
}
|
||||
|
||||
// Add an element in the table
|
||||
template <typename T>
|
||||
int UnicityTable<T>::push_back(T object) {
|
||||
int idx = get_id(object);
|
||||
auto idx = get_index(object);
|
||||
if (idx == -1) {
|
||||
table_.push_back(object);
|
||||
idx = size();
|
||||
|
@ -421,7 +421,7 @@ void Classify::LearnPieces(const char *fontname, int start, int length, float th
|
||||
LearnBlob(fontname, rotated_blob, cn_denorm, fx_info, correct_text);
|
||||
} else if (unicharset.contains_unichar(correct_text)) {
|
||||
UNICHAR_ID class_id = unicharset.unichar_to_id(correct_text);
|
||||
int font_id = word->fontinfo != nullptr ? fontinfo_table_.get_id(*word->fontinfo) : 0;
|
||||
int font_id = word->fontinfo != nullptr ? fontinfo_table_.get_index(*word->fontinfo) : 0;
|
||||
if (classify_learning_debug_level >= 1) {
|
||||
tprintf("Adapting to char = %s, thr= %g font_id= %d\n", unicharset.id_to_unichar(class_id),
|
||||
threshold, font_id);
|
||||
|
@ -511,7 +511,7 @@ INT_TEMPLATES_STRUCT *Classify::CreateIntTemplates(CLASSES FloatProtos,
|
||||
fs[i] = FClass->font_set.at(i);
|
||||
}
|
||||
if (this->fontset_table_.contains(fs)) {
|
||||
IClass->font_set_id = this->fontset_table_.get_id(fs);
|
||||
IClass->font_set_id = this->fontset_table_.get_index(fs);
|
||||
} else {
|
||||
IClass->font_set_id = this->fontset_table_.push_back(fs);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user