Fixed a lot of compiler/clang warnings

git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@1015 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
theraysmith@gmail.com 2014-01-25 02:28:51 +00:00
parent aa62157687
commit d11dc049e3
51 changed files with 149 additions and 363 deletions

View File

@ -2282,7 +2282,6 @@ void TessBaseAPI::AdaptToCharacter(const char *unichar_repr,
tesseract_->classify_bln_numeric_mode,
tesseract_->pix_binary());
float threshold;
UNICHAR_ID best_class = 0;
float best_rating = -100;
@ -2295,7 +2294,6 @@ void TessBaseAPI::AdaptToCharacter(const char *unichar_repr,
choice_it.forward()) {
if (choice_it.data()->rating() > best_rating) {
best_rating = choice_it.data()->rating();
best_class = choice_it.data()->unichar_id();
}
}

View File

@ -37,7 +37,7 @@ template <typename T> class GenericVector;
class PAGE_RES;
class PAGE_RES_IT;
class ParagraphModel;
class BlamerBundle;
struct BlamerBundle;
class BLOCK_LIST;
class DENORM;
class IMAGE;

View File

@ -177,12 +177,10 @@ char* TessPDFRenderer::GetPDFTextObjects(TessBaseAPI* api,
break;
}
const char *font_name;
bool bold, italic, underlined, monospace, serif, smallcaps;
int font_id;
font_name = res_it->WordFontAttributes(&bold, &italic, &underlined,
&monospace, &serif, &smallcaps,
&pointsize, &font_id);
res_it->WordFontAttributes(&bold, &italic, &underlined, &monospace,
&serif, &smallcaps, &pointsize, &font_id);
if (pointsize != old_pointsize) {
char textfont[20];
@ -209,7 +207,6 @@ char* TessPDFRenderer::GetPDFTextObjects(TessBaseAPI* api,
old_y = y;
bool last_word_in_line = res_it->IsAtFinalElement(RIL_TEXTLINE, RIL_WORD);
bool last_word_in_para = res_it->IsAtFinalElement(RIL_PARA, RIL_WORD);
bool last_word_in_block = res_it->IsAtFinalElement(RIL_BLOCK, RIL_WORD);
STRING pdf_word("");
int pdf_word_len = 0;
@ -221,7 +218,7 @@ char* TessPDFRenderer::GetPDFTextObjects(TessBaseAPI* api,
string_32 utf32;
CubeUtils::UTF8ToUTF32(grapheme, &utf32);
char utf16[20];
for (int i = 0; i < utf32.length(); i++) {
for (int i = 0; i < static_cast<int>(utf32.length()); i++) {
snprintf(utf16, sizeof(utf16), "<%04X>", utf32[i]);
pdf_word += utf16;
pdf_word_len++;
@ -262,7 +259,6 @@ bool TessPDFRenderer::BeginDocumentHandler() {
AppendPDFObject(buf);
// CATALOG
long int catalog = obj_;
snprintf(buf, sizeof(buf),
"1 0 obj\n"
"<<\n"
@ -479,7 +475,8 @@ bool TessPDFRenderer::fileToPDFObj(char *filename, long int objnum,
if (!pdf_object)
return false;
memcpy(*pdf_object, b1, b1_len);
if (fread(*pdf_object + b1_len, 1, jpeg_size, fp) != jpeg_size) {
if (static_cast<int>(fread(*pdf_object + b1_len, 1, jpeg_size, fp)) !=
jpeg_size) {
delete[] pdf_object;
return false;
}

View File

@ -245,7 +245,8 @@ int main(int argc, char **argv) {
pixs = pixReadMem(&ch_data[0], ch_data.size());
}
if (pagesegmode == tesseract::PSM_AUTO_OSD) {
if (pagesegmode == tesseract::PSM_AUTO_ONLY ||
pagesegmode == tesseract::PSM_OSD_ONLY) {
tesseract::Orientation orientation;
tesseract::WritingDirection direction;
tesseract::TextlineOrder order;

View File

@ -331,7 +331,6 @@ bool LTRResultIterator::SymbolIsDropcap() const {
ChoiceIterator::ChoiceIterator(const LTRResultIterator& result_it) {
ASSERT_HOST(result_it.it_->word() != NULL);
word_res_ = result_it.it_->word();
PAGE_RES_IT res_it(*result_it.it_);
BLOB_CHOICE_LIST* choices = NULL;
if (word_res_->ratings != NULL)
choices = word_res_->GetBlobChoices(result_it.blob_index_);

View File

@ -395,10 +395,8 @@ bool OrientationDetector::detect_blob(BLOB_CHOICE_LIST* scores) {
float first = -1;
float second = -1;
int idx = -1;
for (int i = 0; i < 4; ++i) {
if (osr_->orientations[i] > first) {
idx = i;
second = first;
first = osr_->orientations[i];
} else if (osr_->orientations[i] > second) {
@ -443,14 +441,9 @@ void ScriptDetector::detect_blob(BLOB_CHOICE_LIST* scores) {
float prev_score = -1;
int script_count = 0;
int prev_id = -1;
int prev_script;
int prev_class_id = -1;
int prev_fontinfo_id = -1;
const char* prev_unichar = "";
const char* unichar = "";
float next_best_score = -1.0;
int next_best_script_id = -1;
const char* next_best_unichar = "";
for (choice_it.mark_cycle_pt(); !choice_it.cycled_list();
choice_it.forward()) {
@ -466,15 +459,10 @@ void ScriptDetector::detect_blob(BLOB_CHOICE_LIST* scores) {
prev_score = -choice->certainty();
script_count = 1;
prev_id = id;
prev_script = choice->script_id();
prev_unichar = unichar;
prev_class_id = choice->unichar_id();
prev_fontinfo_id = choice->fontinfo_id();
} else if (-choice->certainty() < prev_score + kNonAmbiguousMargin) {
++script_count;
next_best_score = -choice->certainty();
next_best_script_id = choice->script_id();
next_best_unichar = tess_->unicharset.id_to_unichar(choice->unichar_id());
}
if (strlen(prev_unichar) == 1)

View File

@ -70,7 +70,6 @@ void Tesseract::output_pass( //Tess output pass //send to api
PAGE_RES_IT &page_res_it,
const TBOX *target_word_box) {
BLOCK_RES *block_of_last_word;
inT16 block_id;
BOOL8 force_eol; //During output
BLOCK *nextblock; //block of next word
WERD *nextword; //next word
@ -95,7 +94,6 @@ void Tesseract::output_pass( //Tess output pass //send to api
if (tessedit_write_block_separators &&
block_of_last_word != page_res_it.block ()) {
block_of_last_word = page_res_it.block ();
block_id = block_of_last_word->block->index();
}
force_eol = (tessedit_write_block_separators &&
@ -137,18 +135,10 @@ void Tesseract::write_results(PAGE_RES_IT &page_res_it,
BOOL8 force_eol) { // override tilde crunch?
WERD_RES *word = page_res_it.word();
const UNICHARSET &uchset = *word->uch_set;
STRING repetition_code;
const STRING *wordstr;
STRING wordstr_lengths;
int i;
char unrecognised = STRING (unrecognised_char)[0];
char ep_chars[32]; //Only for unlv_tilde_crunch
int ep_chars_index = 0;
char txt_chs[32]; //Only for unlv_tilde_crunch
char map_chs[32]; //Only for unlv_tilde_crunch
int txt_index = 0;
BOOL8 need_reject = FALSE;
UNICHAR_ID space = uchset.unichar_to_id(" ");
if ((word->unlv_crunch_mode != CR_NONE ||
word->best_choice->length() == 0) &&
!tessedit_zero_kelvin_rejection && !tessedit_word_for_word) {
@ -162,10 +152,6 @@ void Tesseract::write_results(PAGE_RES_IT &page_res_it,
(word->word->space () > 0) &&
!word->word->flag (W_FUZZY_NON) &&
!word->word->flag (W_FUZZY_SP)) {
// Write a space to separate from preceeding good text.
txt_chs[txt_index] = ' ';
map_chs[txt_index++] = '1';
ep_chars[ep_chars_index++] = ' ';
stats_.last_char_was_tilde = false;
}
need_reject = TRUE;
@ -174,50 +160,16 @@ void Tesseract::write_results(PAGE_RES_IT &page_res_it,
(force_eol && stats_.write_results_empty_block)) {
/* Write a reject char - mark as rejected unless zero_rejection mode */
stats_.last_char_was_tilde = TRUE;
txt_chs[txt_index] = unrecognised;
if (tessedit_zero_rejection || (suspect_level == 0)) {
map_chs[txt_index++] = '1';
ep_chars[ep_chars_index++] = unrecognised;
}
else {
map_chs[txt_index++] = '0';
/*
The ep_choice string is a faked reject to allow newdiff to sync the
.etx with the .txt and .map files.
*/
ep_chars[ep_chars_index++] = CTRL_INSET; // escape code
//dummy reject
ep_chars[ep_chars_index++] = 1;
//dummy reject
ep_chars[ep_chars_index++] = 1;
//type
ep_chars[ep_chars_index++] = 2;
//dummy reject
ep_chars[ep_chars_index++] = 1;
//dummy reject
ep_chars[ep_chars_index++] = 1;
}
stats_.tilde_crunch_written = true;
stats_.last_char_was_newline = false;
stats_.write_results_empty_block = false;
}
if ((word->word->flag (W_EOL) && !stats_.last_char_was_newline) || force_eol) {
/* Add a new line output */
txt_chs[txt_index] = '\n';
map_chs[txt_index++] = '\n';
//end line
ep_chars[ep_chars_index++] = newline_type;
//Cos of the real newline
stats_.tilde_crunch_written = false;
stats_.last_char_was_newline = true;
stats_.last_char_was_tilde = false;
}
txt_chs[txt_index] = '\0';
map_chs[txt_index] = '\0';
ep_chars[ep_chars_index] = '\0'; // terminate string
word->ep_choice = new WERD_CHOICE(ep_chars, uchset);
if (force_eol)
stats_.write_results_empty_block = true;
@ -266,13 +218,7 @@ void Tesseract::write_results(PAGE_RES_IT &page_res_it,
word->best_choice->debug_string().string(),
dict_word(*(word->best_choice)));
}
if (word->word->flag (W_REP_CHAR) && tessedit_write_rep_codes) {
repetition_code = "|^~R";
wordstr_lengths = "\001\001\001\001";
repetition_code += uchset.id_to_unichar(get_rep_char(word));
wordstr_lengths += strlen(uchset.id_to_unichar(get_rep_char(word)));
wordstr = &repetition_code;
} else {
if (!word->word->flag (W_REP_CHAR) || !tessedit_write_rep_codes) {
if (tessedit_zero_rejection) {
/* OVERRIDE ALL REJECTION MECHANISMS - ONLY REJECT TESS FAILURES */
for (i = 0; i < word->best_choice->length(); ++i) {

View File

@ -24,7 +24,7 @@
#include "publictypes.h"
#include "platform.h"
class BlamerBundle;
struct BlamerBundle;
class C_BLOB_IT;
class PAGE_RES;
class PAGE_RES_IT;

View File

@ -629,7 +629,6 @@ void Tesseract::flip_hyphens(WERD_RES *word_res) {
int num_blobs = word_res->rebuild_word->NumBlobs();
UNICHAR_ID unichar_dash = word_res->uch_set->unichar_to_id("-");
bool modified = false;
for (i = 0; i < best_choice->length() && i < num_blobs; ++i) {
TBLOB* blob = word_res->rebuild_word->blobs[i];
out_box = blob->bounding_box();
@ -647,7 +646,6 @@ void Tesseract::flip_hyphens(WERD_RES *word_res) {
word_res->uch_set->get_enabled(unichar_dash)) {
/* Certain HYPHEN */
best_choice->set_unichar_id(unichar_dash, i);
modified = true;
if (word_res->reject_map[i].rejected())
word_res->reject_map[i].setrej_hyphen_accept();
}
@ -702,7 +700,6 @@ void Tesseract::flip_0O(WERD_RES *word_res) {
!word_res->uch_set->get_enabled(unichar_O)) {
return; // 0 or O are not present/enabled in unicharset
}
bool modified = false;
for (i = 1; i < best_choice->length(); ++i) {
if (best_choice->unichar_id(i) == unichar_0 ||
best_choice->unichar_id(i) == unichar_O) {
@ -711,7 +708,6 @@ void Tesseract::flip_0O(WERD_RES *word_res) {
non_O_upper(*word_res->uch_set, best_choice->unichar_id(i-1)) &&
non_O_upper(*word_res->uch_set, best_choice->unichar_id(i+1))) {
best_choice->set_unichar_id(unichar_O, i);
modified = true;
}
/* A00A */
if (non_O_upper(*word_res->uch_set, best_choice->unichar_id(i-1)) &&
@ -721,7 +717,6 @@ void Tesseract::flip_0O(WERD_RES *word_res) {
(i+2) < best_choice->length() &&
non_O_upper(*word_res->uch_set, best_choice->unichar_id(i+2))) {
best_choice->set_unichar_id(unichar_O, i);
modified = true;
i++;
}
/* AA0<non digit or end of word> */
@ -734,14 +729,12 @@ void Tesseract::flip_0O(WERD_RES *word_res) {
!word_res->uch_set->eq(best_choice->unichar_id(i+1), "I")) ||
(i == best_choice->length() - 1))) {
best_choice->set_unichar_id(unichar_O, i);
modified = true;
}
/* 9O9 */
if (non_0_digit(*word_res->uch_set, best_choice->unichar_id(i-1)) &&
(i+1) < best_choice->length() &&
non_0_digit(*word_res->uch_set, best_choice->unichar_id(i+1))) {
best_choice->set_unichar_id(unichar_0, i);
modified = true;
}
/* 9OOO */
if (non_0_digit(*word_res->uch_set, best_choice->unichar_id(i-1)) &&
@ -753,7 +746,6 @@ void Tesseract::flip_0O(WERD_RES *word_res) {
best_choice->set_unichar_id(unichar_0, i);
best_choice->set_unichar_id(unichar_0, i+1);
best_choice->set_unichar_id(unichar_0, i+2);
modified = true;
i += 2;
}
/* 9OO<non upper> */
@ -764,7 +756,6 @@ void Tesseract::flip_0O(WERD_RES *word_res) {
!word_res->uch_set->get_isupper(best_choice->unichar_id(i+2))) {
best_choice->set_unichar_id(unichar_0, i);
best_choice->set_unichar_id(unichar_0, i+1);
modified = true;
i++;
}
/* 9O<non upper> */
@ -781,13 +772,11 @@ void Tesseract::flip_0O(WERD_RES *word_res) {
best_choice->unichar_id(i-2) == unichar_O)) {
if (best_choice->unichar_id(i-2) == unichar_O) {
best_choice->set_unichar_id(unichar_0, i-2);
modified = true;
}
while (i < best_choice->length() &&
(best_choice->unichar_id(i) == unichar_O ||
best_choice->unichar_id(i) == unichar_0)) {
best_choice->set_unichar_id(unichar_0, i);
modified = true;
i++;
}
i--;

View File

@ -90,8 +90,8 @@ void Tesseract::recog_word(WERD_RES *word) {
// Factored out from control.cpp
ASSERT_HOST((word->best_choice == NULL) == (word->raw_choice == NULL));
if (word->best_choice == NULL || word->best_choice->length() == 0 ||
strspn(word->best_choice->unichar_string().string(), " ") ==
word->best_choice->length()) {
static_cast<int>(strspn(word->best_choice->unichar_string().string(),
" ")) == word->best_choice->length()) {
word->tess_failed = true;
word->reject_map.initialise(word->box_word->length());
word->reject_map.rej_word_tess_failure();
@ -145,8 +145,6 @@ void Tesseract::split_and_recog_word(WERD_RES *word) {
// Find the biggest blob gap in the chopped_word.
int bestgap = -MAX_INT32;
int split_index = 0;
TBLOB* best_end = NULL;
TBLOB* prev_blob = NULL;
for (int b = 1; b < word->chopped_word->NumBlobs(); ++b) {
TBOX prev_box = word->chopped_word->blobs[b - 1]->bounding_box();
TBOX blob_box = word->chopped_word->blobs[b]->bounding_box();

View File

@ -306,7 +306,6 @@ static TESSLINE** ApproximateOutlineList(bool allow_detailed_fx,
// contain pointers to the input C_OUTLINEs that enable higher-resolution
// feature extraction that does not use the polygonal approximation.
TBLOB* TBLOB::PolygonalCopy(bool allow_detailed_fx, C_BLOB* src) {
C_OUTLINE_IT ol_it = src->out_list();
TBLOB* tblob = new TBLOB;
ApproximateOutlineList(allow_detailed_fx, src->out_list(), false,
&tblob->outlines);

View File

@ -156,7 +156,8 @@ bool read_info(FILE* f, FontInfo* fi, bool swap) {
Reverse32(&size);
char* font_name = new char[size + 1];
fi->name = font_name;
if (fread(font_name, sizeof(*font_name), size, f) != size) return false;
if (static_cast<int>(fread(font_name, sizeof(*font_name), size, f)) != size)
return false;
font_name[size] = '\0';
if (fread(&fi->properties, sizeof(fi->properties), 1, f) != 1) return false;
if (swap)
@ -167,7 +168,8 @@ bool read_info(FILE* f, FontInfo* fi, bool swap) {
bool write_info(FILE* f, const FontInfo& fi) {
inT32 size = strlen(fi.name);
if (fwrite(&size, sizeof(size), 1, f) != 1) return false;
if (fwrite(fi.name, sizeof(*fi.name), size, f) != size) return false;
if (static_cast<int>(fwrite(fi.name, sizeof(*fi.name), size, f)) != size)
return false;
if (fwrite(&fi.properties, sizeof(fi.properties), 1, f) != 1) return false;
return true;
}

View File

@ -32,9 +32,9 @@ struct Pix;
class ROW; // Forward decl
class BLOCK;
class FCOORD;
class TBLOB;
struct TBLOB;
class TBOX;
class TPOINT;
struct TPOINT;
class UNICHARSET;
namespace tesseract {

View File

@ -27,7 +27,7 @@
class TO_ROW;
class PARA;
struct PARA;
class ROW:public ELIST_LINK
{

View File

@ -26,7 +26,7 @@
#include "rect.h"
class ROW;
class Pix;
struct Pix;
class QSPLINE
{

View File

@ -31,8 +31,8 @@
#include "werd.h"
class MATRIX;
class TBLOB;
class TWERD;
struct TBLOB;
struct TWERD;
// Enum to describe the source of a BLOB_CHOICE to make it possible to determine
// whether a blob has been classified by inspecting the BLOB_CHOICEs.

View File

@ -193,10 +193,7 @@ bool test_insert_seam(const GenericVector<SEAM*>& seam_array,
void insert_seam(const TWERD* word, int index, SEAM *seam,
GenericVector<SEAM*>* seam_array) {
SEAM *test_seam;
int test_index;
int list_length;
list_length = seam_array->size();
int list_length = seam_array->size();
for (int test_index = 0; test_index < index; ++test_index) {
test_seam = seam_array->get(test_index);
if (test_index + test_seam->widthp >= index) {

View File

@ -28,7 +28,7 @@
#include <math.h>
#include "blobs.h"
class EDGEPT;
struct EDGEPT;
/*----------------------------------------------------------------------
M a c r o s

View File

@ -465,7 +465,7 @@ WERD* WERD::ConstructWerdWithNewBlobs(C_BLOB_LIST* all_blobs,
TBOX a_blob_box = a_blob->bounding_box();
if ((not_found_box.major_overlap(a_blob_box) ||
a_blob_box.major_overlap(not_found_box)) &&
not_found_box.y_overlap(a_blob_box) > 0.8) {
not_found_box.y_overlap_fraction(a_blob_box) > 0.8) {
// Already taken care of.
delete not_found_it.extract();
break;

View File

@ -138,7 +138,8 @@ void BitVector::Init(int length) {
bool BitVector::Serialize(FILE* fp) const {
if (fwrite(&bit_size_, sizeof(bit_size_), 1, fp) != 1) return false;
int wordlen = WordLength();
if (fwrite(array_, sizeof(*array_), wordlen, fp) != wordlen) return false;
if (static_cast<int>(fwrite(array_, sizeof(*array_), wordlen, fp)) != wordlen)
return false;
return true;
}
@ -152,7 +153,8 @@ bool BitVector::DeSerialize(bool swap, FILE* fp) {
}
Alloc(new_bit_size);
int wordlen = WordLength();
if (fread(array_, sizeof(*array_), wordlen, fp) != wordlen) return false;
if (static_cast<int>(fread(array_, sizeof(*array_), wordlen, fp)) != wordlen)
return false;
if (swap) {
for (int i = 0; i < wordlen; ++i)
ReverseN(&array_[i], sizeof(array_[i]));

View File

@ -129,7 +129,7 @@ class BitVector {
}
// Number of bits in this BitVector.
uinT32 bit_size_;
inT32 bit_size_;
// Array of words used to pack the bits.
// Bits are stored little-endian by uinT32 word, ie by word first and then
// starting with the least significant bit in each word.

View File

@ -87,12 +87,21 @@ const ERRCODE ASSERT_FAILED = "Assert failed";
__FILE__, __LINE__); \
}
#ifdef _MSC_VER
#define ASSERT_HOST_MSG(x, msg, ...) if (!(x)) \
{ \
tprintf(msg); \
ASSERT_FAILED.error(#x, ABORT, "in file %s, line %d", \
__FILE__, __LINE__); \
}
#else
#define ASSERT_HOST_MSG(x, msg...) if (!(x)) \
{ \
tprintf(msg); \
ASSERT_FAILED.error(#x, ABORT, "in file %s, line %d", \
__FILE__, __LINE__); \
}
#endif
void signal_exit(int signal_code);

View File

@ -346,7 +346,8 @@ inline bool SaveDataToFile(const GenericVector<char>& data,
const STRING& filename) {
FILE* fp = fopen(filename.string(), "wb");
if (fp == NULL) return false;
bool result = fwrite(&data[0], 1, data.size(), fp) == data.size();
bool result =
static_cast<int>(fwrite(&data[0], 1, data.size(), fp)) == data.size();
fclose(fp);
return result;
}

View File

@ -125,7 +125,7 @@ typedef unsigned char BOOL8;
#define MIN_INT8 0x80
#define MIN_INT16 0x8000
#define MIN_INT32 0x80000000
#define MIN_INT32 static_cast<int>(0x80000000)
#define MIN_UINT8 0x00
#define MIN_UINT16 0x0000
#define MIN_UINT32 0x00000000

View File

@ -50,7 +50,7 @@ bool TFile::Open(FILE* fp, inT64 end_offset) {
}
int size = end_offset - current_pos;
data_.init_to_size(size, 0);
return fread(&data_[0], 1, size, fp) == size;
return static_cast<int>(fread(&data_[0], 1, size, fp)) == size;
}
char* TFile::FGets(char* buffer, int buffer_size) {

View File

@ -131,7 +131,7 @@ STRING::~STRING() {
bool STRING::Serialize(FILE* fp) const {
inT32 len = length();
if (fwrite(&len, sizeof(len), 1, fp) != 1) return false;
if (fwrite(GetCStr(), 1, len, fp) != len) return false;
if (static_cast<int>(fwrite(GetCStr(), 1, len, fp)) != len) return false;
return true;
}
// Reads from the given file. Returns false in case of error.
@ -142,7 +142,7 @@ bool STRING::DeSerialize(bool swap, FILE* fp) {
if (swap)
ReverseN(&len, sizeof(len));
truncate_at(len);
if (fread(GetCStr(), 1, len, fp) != len) return false;
if (static_cast<int>(fread(GetCStr(), 1, len, fp)) != len) return false;
return true;
}

View File

@ -9,7 +9,7 @@ AM_CPPFLAGS += -DTESS_EXPORTS \
endif
noinst_HEADERS = \
adaptive.h blobclass.h chartoname.h \
adaptive.h blobclass.h \
classify.h cluster.h clusttool.h cutoffs.h \
errorcounter.h extern.h extract.h \
featdefs.h flexfx.h float2int.h fpoint.h fxdefs.h \
@ -36,7 +36,7 @@ endif
libtesseract_classify_la_SOURCES = \
adaptive.cpp adaptmatch.cpp blobclass.cpp \
chartoname.cpp classify.cpp cluster.cpp clusttool.cpp cutoffs.cpp \
classify.cpp cluster.cpp clusttool.cpp cutoffs.cpp \
errorcounter.cpp extract.cpp \
featdefs.cpp flexfx.cpp float2int.cpp fpoint.cpp fxdefs.cpp \
intfeaturedist.cpp intfeaturemap.cpp intfeaturespace.cpp \

View File

@ -24,7 +24,6 @@
#include "efio.h"
#include "featdefs.h"
#include "callcpp.h"
#include "chartoname.h"
#include <math.h>
#include <stdio.h>

View File

@ -1,74 +0,0 @@
/**************************************************************************
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
** http://www.apache.org/licenses/LICENSE-2.0
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**************************************************************************/
#include <string.h>
#include <ctype.h>
/*chartoname(name,c,dir) converts c into a useful filename*/
void chartoname(register char *name, /*result */
char c, /*char to convert */
const char *dir) { /*directory to use */
char file[3]; /*filename */
int index; /*index of namelist */
static const char *namelist[] = {
"!bang",
"\"doubleq",
"#hash",
"$dollar",
"%percent",
"&and",
"'quote",
"(lround",
")rround",
"*asterisk",
"+plus",
",comma",
"-minus",
".dot",
"/slash",
":colon",
";semic",
"<less",
"=equal",
">greater",
"?question",
"@at",
"[lsquare",
"\\backsl",
"]rsquare",
"^uparr",
"_unders",
"`grave",
"{lbrace",
"|bar",
"}rbrace",
"~tilde"
};
strcpy(name, dir); /*add specific directory */
for (index = 0; index < sizeof namelist / sizeof (char *)
&& c != namelist[index][0]; index++);
if (index < sizeof namelist / sizeof (char *))
/*add text name */
strcat (name, &namelist[index][1]);
else {
if (isupper (c)) {
file[0] = 'c'; /*direct a-z or A-Z */
file[1] = c; /*direct a-z or A-Z */
file[2] = '\0';
}
else {
file[0] = c; /*direct a-z or A-Z */
file[1] = '\0';
}
strcat(name, file); /*append filename */
}
}

View File

@ -1,21 +0,0 @@
#ifndef CHARTONAME_H
#define CHARTONAME_H
/*result */
void chartoname(register char *name,
char c, /*char to convert */
const char *dir); /*directory to use */
/*
#if defined(__STDC__) || defined(__cplusplus)
# define _P(s) s
#else
# define _P(s) ()
#endif*/
/* chartoname.c
int chartoname _P((char *name, int c, char *dir));
#undef _P
*/
#endif

View File

@ -30,7 +30,7 @@ class FontInfoTable;
class SampleIterator;
class ShapeClassifier;
class TrainingSample;
class UnicharRating;
struct UnicharRating;
// Enumeration of the different types of error count.
// Error counts work as follows:

View File

@ -46,7 +46,7 @@ struct CHAR_DESC_STRUCT {
typedef CHAR_DESC_STRUCT *CHAR_DESC;
struct FEATURE_DEFS_STRUCT {
uinT32 NumFeatureTypes;
inT32 NumFeatureTypes;
const FEATURE_DESC_STRUCT* FeatureDesc[NUM_FEATURE_TYPES];
const FEATURE_EXT_STRUCT* FeatureExtractors[NUM_FEATURE_TYPES];
int FeatureEnabled[NUM_FEATURE_TYPES];

View File

@ -41,7 +41,7 @@ class FCOORD;
#define Y_SHIFT (0.5)
#define MAX_PROTO_INDEX 24
#define BITS_PER_WERD (8 * sizeof (uinT32))
#define BITS_PER_WERD static_cast<int>(8 * sizeof(uinT32))
/* Script detection: increase this number to 128 */
#define MAX_NUM_CONFIGS 64
#define MAX_NUM_PROTOS 512

View File

@ -290,8 +290,6 @@ class MasterTrainer {
bool enable_shape_anaylsis_;
// Flag to indicate that sample replication is required.
bool enable_replication_;
// Flag to indicate that junk should be included in samples_.
bool include_junk_;
// Array of classids of fragments that replace the correctly segmented chars.
int* fragments_;
// Classid of previous correctly segmented sample that was added.

View File

@ -24,7 +24,7 @@ class IntFeatureMap;
class ShapeTable;
class TrainingSample;
class TrainingSampleSet;
class UnicharAndFonts;
struct UnicharAndFonts;
// Iterator class to encapsulate the complex iteration involved in getting
// all samples of all shapes needed for a classification problem.

View File

@ -61,10 +61,12 @@ bool TrainingSample::Serialize(FILE* fp) const {
return false;
if (fwrite(&outline_length_, sizeof(outline_length_), 1, fp) != 1)
return false;
if (fwrite(features_, sizeof(*features_), num_features_, fp) != num_features_)
if (static_cast<int>(fwrite(features_, sizeof(*features_), num_features_, fp))
!= num_features_)
return false;
if (fwrite(micro_features_, sizeof(*micro_features_), num_micro_features_,
fp) != num_micro_features_)
if (static_cast<int>(fwrite(micro_features_, sizeof(*micro_features_),
num_micro_features_,
fp)) != num_micro_features_)
return false;
if (fwrite(cn_feature_, sizeof(*cn_feature_), kNumCNParams, fp) !=
kNumCNParams) return false;
@ -102,12 +104,14 @@ bool TrainingSample::DeSerialize(bool swap, FILE* fp) {
}
delete [] features_;
features_ = new INT_FEATURE_STRUCT[num_features_];
if (fread(features_, sizeof(*features_), num_features_, fp) != num_features_)
if (static_cast<int>(fread(features_, sizeof(*features_), num_features_, fp))
!= num_features_)
return false;
delete [] micro_features_;
micro_features_ = new MicroFeature[num_micro_features_];
if (fread(micro_features_, sizeof(*micro_features_), num_micro_features_,
fp) != num_micro_features_)
if (static_cast<int>(fread(micro_features_, sizeof(*micro_features_),
num_micro_features_,
fp)) != num_micro_features_)
return false;
if (fread(cn_feature_, sizeof(*cn_feature_), kNumCNParams, fp) !=
kNumCNParams) return false;

View File

@ -32,7 +32,7 @@ class FontInfoTable;
class IntFeatureMap;
class IntFeatureSpace;
class TrainingSample;
class UnicharAndFonts;
struct UnicharAndFonts;
// Collection of TrainingSample used for training or testing a classifier.
// Provides several useful methods to operate on the collection as a whole,

View File

@ -157,7 +157,6 @@ class CubeObject {
CubeRecoContext *cntxt_;
BeamSearch *beam_obj_;
BeamSearch *deslanted_beam_obj_;
bool offline_mode_;
bool own_char_samp_;
bool deslanted_;
CharSamp *char_samp_;

View File

@ -56,7 +56,6 @@ const int case_state_table[6][4] = { {
};
int Dict::case_ok(const WERD_CHOICE &word, const UNICHARSET &unicharset) {
int last_state = 0;
int state = 0;
int x;
for (x = 0; x < word.length(); ++x) {
@ -70,7 +69,6 @@ int Dict::case_ok(const WERD_CHOICE &word, const UNICHARSET &unicharset) {
else
state = case_state_table[state][0];
if (state == -1) return false;
last_state = state;
}
return state != 5; // single lower is bad
}

View File

@ -18,7 +18,7 @@ NeuralNet::NeuralNet() {
NeuralNet::~NeuralNet() {
// clean up the wts chunks vector
for(int vec = 0; vec < wts_vec_.size(); vec++) {
for (int vec = 0; vec < static_cast<int>(wts_vec_.size()); vec++) {
delete wts_vec_[vec];
}
// clean up neurons

View File

@ -30,7 +30,7 @@ class BLOBNBOX_LIST;
class TO_BLOCK;
class TO_BLOCK_LIST;
class TO_ROW;
class Pix;
struct Pix;
namespace tesseract {

View File

@ -444,7 +444,7 @@ void ShiroRekhaSplitter::GetShiroRekhaYExtents(Pix* word_pix,
int llimit = topline_ylevel;
while (ulimit > 0 && hist_horiz.hist()[ulimit] >= thresh)
--ulimit;
while (llimit < word_pix->h && hist_horiz.hist()[llimit] >= thresh)
while (llimit < pixGetHeight(word_pix) && hist_horiz.hist()[llimit] >= thresh)
++llimit;
if (shirorekha_top) *shirorekha_top = ulimit;

View File

@ -69,7 +69,6 @@ ROW *fixed_pitch_words( //find lines
WERD_IT rep_it = &row->rep_words;
WERD *word; //new word
inT32 xstarts[2]; //row ends
double coeffs[3]; //quadratic
inT32 prev_x; //end of prev blob
//iterator
BLOBNBOX_IT box_it = row->blob_list ();
@ -190,9 +189,6 @@ ROW *fixed_pitch_words( //find lines
if (prev_chop_coord > prev_x)
prev_x = prev_chop_coord;
xstarts[1] = prev_x + 1;
coeffs[0] = 0;
coeffs[1] = row->line_m ();
coeffs[2] = row->line_c ();
real_row = new ROW (row, (inT16) row->kern_size, (inT16) row->space_size);
word_it.set_to_list (real_row->word_list ());
//put words in row
@ -410,7 +406,6 @@ BOOL8 fixed_chop_coutline( //chop the outline
C_OUTLINE_FRAG_LIST *right_frags //right half of chop
) {
BOOL8 first_frag; //fragment
BOOL8 anticlock; //direction of loop
inT16 left_edge; //of outline
inT16 startindex; //in first fragment
inT32 length; //of outline
@ -425,7 +420,6 @@ BOOL8 fixed_chop_coutline( //chop the outline
length = srcline->pathlength ();
pos = srcline->start_pos ();
anticlock = srcline->turn_direction () > 0;
left_edge = pos.x ();
tail_index = 0;
tail_pos = pos;

View File

@ -2079,7 +2079,6 @@ void Textord::make_spline_rows(TO_BLOCK *block, // block to do
*/
void make_baseline_spline(TO_ROW *row, //row to fit
TO_BLOCK *block) {
BLOBNBOX_IT blob_it = row->blob_list ();
inT32 *xstarts; // spline boundaries
double *coeffs; // quadratic coeffs
inT32 segments; // no of segments

View File

@ -230,7 +230,6 @@ int Textord::correlate_with_stats(TO_ROW **rows, // rows of block.
float descheight; /*mean descender drop */
float mindescheight; /*min allowed descheight */
int desccount; /*no of samples */
float xshift; /*shift in xheight */
/*no samples */
xcount = fullcount = desccount = 0;
@ -285,8 +284,6 @@ int Textord::correlate_with_stats(TO_ROW **rows, // rows of block.
if (row->xheight >= lineheight * (1 - MAXHEIGHTVARIANCE)
&& row->xheight <= lineheight * (1 + MAXHEIGHTVARIANCE)) {
row->ascrise = fullheight - lineheight;
/*shift in x */
xshift = lineheight - row->xheight;
/*set to average */
row->xheight = lineheight;
@ -294,7 +291,6 @@ int Textord::correlate_with_stats(TO_ROW **rows, // rows of block.
else if (row->xheight >= fullheight * (1 - MAXHEIGHTVARIANCE)
&& row->xheight <= fullheight * (1 + MAXHEIGHTVARIANCE)) {
row->ascrise = row->xheight - lineheight;
xshift = -row->ascrise; /*shift in x */
/*set to average */
row->xheight = lineheight;
row->all_caps = TRUE;
@ -302,7 +298,6 @@ int Textord::correlate_with_stats(TO_ROW **rows, // rows of block.
else {
row->ascrise = (fullheight - lineheight) * row->xheight
/ fullheight;
xshift = -row->ascrise; /*shift in x */
/*scale it */
row->xheight -= row->ascrise;
row->all_caps = TRUE;
@ -1388,7 +1383,6 @@ int bestpart /*biggest partition */
int poscount; /*count of best up step */
int negcount; /*count of best down step */
float partsteps[MAXPARTS]; /*average step to part */
float bestpos; /*best up step */
float bestneg; /*best down step */
int runlength; /*length of bad run */
int biggestrun; /*biggest bad run */
@ -1400,12 +1394,14 @@ int bestpart /*biggest partition */
xcentre = (blobcoords[blobindex].left ()
+ blobcoords[blobindex].right ()) >> 1;
/*in other parts */
if (partids[blobindex] != bestpart) {
int part_id =
static_cast<int>(static_cast<unsigned char>(partids[blobindex]));
if (part_id != bestpart) {
runlength++; /*run of non bests */
if (runlength > biggestrun)
biggestrun = runlength;
partsteps[partids[blobindex]] += blobcoords[blobindex].bottom ()
- row->baseline.y (xcentre);
partsteps[part_id] += blobcoords[blobindex].bottom()
- row->baseline.y(xcentre);
}
else
runlength = 0;
@ -1415,7 +1411,7 @@ int bestpart /*biggest partition */
else
row->xheight = 1.0f; /*success */
poscount = negcount = 0;
bestpos = bestneg = 0.0; /*no step yet */
bestneg = 0.0; /*no step yet */
for (partition = 0; partition < partcount; partition++) {
if (partition != bestpart) {
@ -1429,9 +1425,6 @@ int bestpart /*biggest partition */
if (partsteps[partition] >= MINASCRISE
&& partsizes[partition] > poscount) {
/*ascender rise */
bestpos = partsteps[partition];
/*2nd most popular */
poscount = partsizes[partition];
}
if (partsteps[partition] <= -MINASCRISE

View File

@ -553,7 +553,6 @@ BOOL8 try_rows_fixed( //find line stats
inT32 block_index, //block number
BOOL8 testing_on //correct orientation
) {
inT32 maxwidth; //of spaces
TO_ROW *row; //current row
inT32 row_index; //row number.
inT32 def_fixed = 0; //counters
@ -570,7 +569,6 @@ BOOL8 try_rows_fixed( //find line stats
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
ASSERT_HOST (row->xheight > 0);
maxwidth = (inT32) ceil (row->xheight * textord_words_maxspace);
if (row->fixed_pitch > 0 &&
fixed_pitch_row(row, block->block, block_index)) {
if (row->fixed_pitch == 0) {

View File

@ -907,7 +907,6 @@ ROW *Textord::make_prop_words(
inT32 next_rep_char_word_right = MAX_INT32;
float repetition_spacing; //gap between repetitions
inT32 xstarts[2]; //row ends
double coeffs[3]; //quadratic
inT32 prev_x; //end of prev blob
BLOBNBOX *bblob; //current blob
TBOX blob_box; //bounding box
@ -1149,9 +1148,6 @@ ROW *Textord::make_prop_words(
rep_char_it.forward ();
}
}
coeffs[0] = 0;
coeffs[1] = row->line_m ();
coeffs[2] = row->line_c ();
real_row = new ROW (row,
(inT16) row->kern_size, (inT16) row->space_size);
word_it.set_to_list (real_row->word_list ());
@ -1190,7 +1186,6 @@ ROW *Textord::make_blob_words(
WERD_LIST words;
WERD_IT word_it; // new words
WERD *word; // new word
double coeffs[3]; // quadratic
BLOBNBOX *bblob; // current blob
TBOX blob_box; // bounding box
BLOBNBOX_IT box_it; // iterator
@ -1235,9 +1230,6 @@ ROW *Textord::make_blob_words(
}
while (!box_it.at_first()); // until back at start
/* Setup the row with created words. */
coeffs[0] = 0;
coeffs[1] = row->line_m();
coeffs[2] = row->line_c();
real_row = new ROW(row, (inT16) row->kern_size, (inT16) row->space_size);
word_it.set_to_list(real_row->word_list());
//put words in row

View File

@ -136,21 +136,14 @@ void set_row_spaces( //find space sizes
FCOORD rotation, //for drawing
BOOL8 testing_on //correct orientation
) {
inT32 maxwidth; //of widest space
TO_ROW *row; //current row
TO_ROW_IT row_it = block->get_rows ();
if (row_it.empty ())
return; //empty block
maxwidth = (inT32) ceil (block->xheight * textord_words_maxspace);
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
if (row->fixed_pitch == 0) {
// if (!textord_test_mode
// && row_words(block,row,maxwidth,rotation,testing_on)==0
// || textord_test_mode
// && row_words2(block,row,maxwidth,rotation,testing_on)==0)
// {
row->min_space =
(inT32) ceil (row->pr_space -
(row->pr_space -
@ -166,7 +159,6 @@ void set_row_spaces( //find space sizes
row->space_threshold = (row->max_nonspace + row->min_space) / 2;
row->space_size = row->pr_space;
row->kern_size = row->pr_nonsp;
// }
}
#ifndef GRAPHICS_DISABLED
if (textord_show_initial_words && testing_on) {
@ -572,10 +564,8 @@ ROW *make_rep_words( //make a row
TO_ROW *row, //row to convert
TO_BLOCK *block //block it lives in
) {
inT32 xstarts[2]; //ends of row
ROW *real_row; //output row
TBOX word_box; //bounding box
double coeffs[3]; //spline
//iterator
WERD_IT word_it = &row->rep_words;
@ -584,11 +574,6 @@ ROW *make_rep_words( //make a row
word_box = word_it.data ()->bounding_box ();
for (word_it.mark_cycle_pt (); !word_it.cycled_list (); word_it.forward ())
word_box += word_it.data ()->bounding_box ();
xstarts[0] = word_box.left ();
xstarts[1] = word_box.right ();
coeffs[0] = 0;
coeffs[1] = row->line_m ();
coeffs[2] = row->line_c ();
row->xheight = block->xheight;
real_row = new ROW(row,
(inT16) block->kern_size, (inT16) block->space_size);

View File

@ -96,90 +96,90 @@ void* ScrollView::MessageReceiver(void* a) {
// This is the main loop which iterates until the server is dead (strlen = -1).
// It basically parses for 3 different messagetypes and then distributes the
// events accordingly.
while (strlen(message) != -1) {
// The new event we create.
SVEvent* cur = new SVEvent;
// The ID of the corresponding window.
int window_id;
while (1) {
// The new event we create.
SVEvent* cur = new SVEvent;
// The ID of the corresponding window.
int window_id;
int ev_type;
int ev_type;
int n;
// Fill the new SVEvent properly.
sscanf(message, "%d,%d,%d,%d,%d,%d,%d,%n", &window_id, &ev_type, &cur->x,
&cur->y, &cur->x_size, &cur->y_size, &cur->command_id, &n);
char* p = (message + n);
int n;
// Fill the new SVEvent properly.
sscanf(message, "%d,%d,%d,%d,%d,%d,%d,%n", &window_id, &ev_type, &cur->x,
&cur->y, &cur->x_size, &cur->y_size, &cur->command_id, &n);
char* p = (message + n);
svmap_mu->Lock();
cur->window = svmap[window_id];
svmap_mu->Lock();
cur->window = svmap[window_id];
if (cur->window != NULL) {
cur->parameter = new char[strlen(p) + 1];
strncpy(cur->parameter, p, strlen(p) + 1);
if (strlen(p) > 0) { // remove the last \n
cur->parameter[strlen(p)] = '\0';
}
cur->type = static_cast<SVEventType>(ev_type);
// Correct selection coordinates so x,y is the min pt and size is +ve.
if (cur->x_size > 0)
cur->x -= cur->x_size;
else
cur->x_size = -cur->x_size;
if (cur->y_size > 0)
cur->y -= cur->y_size;
else
cur->y_size = -cur->y_size;
// Returned y will be the bottom-left if y is reversed.
if (cur->window->y_axis_is_reversed_)
cur->y = cur->window->TranslateYCoordinate(cur->y + cur->y_size);
cur->counter = counter_event_id;
// Increase by 2 since we will also create an SVET_ANY event from cur,
// which will have a counter_id of cur + 1 (and thus gets processed
// after cur).
counter_event_id += 2;
// In case of an SVET_EXIT event, quit the whole application.
if (ev_type == SVET_EXIT) { ScrollView::Exit(); }
// Place two copies of it in the table for the window.
cur->window->SetEvent(cur);
// Check if any of the threads currently waiting want it.
std::pair<ScrollView*, SVEventType> awaiting_list(cur->window,
cur->type);
std::pair<ScrollView*, SVEventType> awaiting_list_any(cur->window,
SVET_ANY);
std::pair<ScrollView*, SVEventType> awaiting_list_any_window((ScrollView*)0,
SVET_ANY);
waiting_for_events_mu->Lock();
if (waiting_for_events.count(awaiting_list) > 0) {
waiting_for_events[awaiting_list].second = cur;
waiting_for_events[awaiting_list].first->Signal();
} else if (waiting_for_events.count(awaiting_list_any) > 0) {
waiting_for_events[awaiting_list_any].second = cur;
waiting_for_events[awaiting_list_any].first->Signal();
} else if (waiting_for_events.count(awaiting_list_any_window) > 0) {
waiting_for_events[awaiting_list_any_window].second = cur;
waiting_for_events[awaiting_list_any_window].first->Signal();
} else {
// No one wanted it, so delete it.
delete cur;
}
waiting_for_events_mu->Unlock();
// Signal the corresponding semaphore twice (for both copies).
ScrollView* sv = svmap[window_id];
if (sv != NULL) {
sv->Signal();
sv->Signal();
}
if (cur->window != NULL) {
cur->parameter = new char[strlen(p) + 1];
strncpy(cur->parameter, p, strlen(p) + 1);
if (strlen(p) > 0) { // remove the last \n
cur->parameter[strlen(p)] = '\0';
}
svmap_mu->Unlock();
cur->type = static_cast<SVEventType>(ev_type);
// Correct selection coordinates so x,y is the min pt and size is +ve.
if (cur->x_size > 0)
cur->x -= cur->x_size;
else
cur->x_size = -cur->x_size;
if (cur->y_size > 0)
cur->y -= cur->y_size;
else
cur->y_size = -cur->y_size;
// Returned y will be the bottom-left if y is reversed.
if (cur->window->y_axis_is_reversed_)
cur->y = cur->window->TranslateYCoordinate(cur->y + cur->y_size);
cur->counter = counter_event_id;
// Increase by 2 since we will also create an SVET_ANY event from cur,
// which will have a counter_id of cur + 1 (and thus gets processed
// after cur).
counter_event_id += 2;
// Wait until a new message appears in the input stream_.
do {
message = ScrollView::GetStream()->Receive();
} while (message == NULL);
// In case of an SVET_EXIT event, quit the whole application.
if (ev_type == SVET_EXIT) { ScrollView::Exit(); }
// Place two copies of it in the table for the window.
cur->window->SetEvent(cur);
// Check if any of the threads currently waiting want it.
std::pair<ScrollView*, SVEventType> awaiting_list(cur->window,
cur->type);
std::pair<ScrollView*, SVEventType> awaiting_list_any(cur->window,
SVET_ANY);
std::pair<ScrollView*, SVEventType> awaiting_list_any_window((ScrollView*)0,
SVET_ANY);
waiting_for_events_mu->Lock();
if (waiting_for_events.count(awaiting_list) > 0) {
waiting_for_events[awaiting_list].second = cur;
waiting_for_events[awaiting_list].first->Signal();
} else if (waiting_for_events.count(awaiting_list_any) > 0) {
waiting_for_events[awaiting_list_any].second = cur;
waiting_for_events[awaiting_list_any].first->Signal();
} else if (waiting_for_events.count(awaiting_list_any_window) > 0) {
waiting_for_events[awaiting_list_any_window].second = cur;
waiting_for_events[awaiting_list_any_window].first->Signal();
} else {
// No one wanted it, so delete it.
delete cur;
}
waiting_for_events_mu->Unlock();
// Signal the corresponding semaphore twice (for both copies).
ScrollView* sv = svmap[window_id];
if (sv != NULL) {
sv->Signal();
sv->Signal();
}
}
svmap_mu->Unlock();
// Wait until a new message appears in the input stream_.
do {
message = ScrollView::GetStream()->Receive();
} while (message == NULL);
}
return 0;
}

View File

@ -396,7 +396,6 @@ SEAM* Wordrec::chop_one_blob(const GenericVector<TBOX>& boxes,
*/
inT16 check_seam_order(TBLOB *blob, SEAM *seam) {
TESSLINE *outline;
TESSLINE *last_outline;
inT8 found_em[3];
if (seam->split1 == NULL || blob == NULL)
@ -420,7 +419,6 @@ inT16 check_seam_order(TBLOB *blob, SEAM *seam) {
is_split_outline (outline, seam->split3))) {
found_em[2] = TRUE;
}
last_outline = outline;
}
if (!found_em[0] || !found_em[1] || !found_em[2])

View File

@ -155,12 +155,10 @@ void Wordrec::merge_and_put_fragment_lists(inT16 row, inT16 column,
// Find the maximum unichar_id of the current entry the iterators
// are pointing at
UNICHAR_ID max_unichar_id = choice_lists_it[0].data()->unichar_id();
int max_list = 0;
for (int i = 0; i < num_frag_parts; i++) {
UNICHAR_ID unichar_id = choice_lists_it[i].data()->unichar_id();
if (max_unichar_id < unichar_id) {
max_unichar_id = unichar_id;
max_list = i;
}
}