From 86d981eee69eb504cfd6c6e233f1fbf1862b5cfa Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 9 Oct 2021 20:58:16 +0200 Subject: [PATCH] wordrec: Fix some signed/unsigned compiler warnings Signed-off-by: Stefan Weil --- src/wordrec/chopper.cpp | 12 ++++++------ src/wordrec/language_model.cpp | 5 ++--- src/wordrec/params_model.cpp | 2 +- src/wordrec/wordrec.h | 6 +++--- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/wordrec/chopper.cpp b/src/wordrec/chopper.cpp index deb0f45bde..d035584865 100644 --- a/src/wordrec/chopper.cpp +++ b/src/wordrec/chopper.cpp @@ -264,7 +264,7 @@ SEAM *Wordrec::chop_numbered_blob(TWERD *word, int32_t blob_number, bool italic_ } SEAM *Wordrec::chop_overlapping_blob(const std::vector &boxes, bool italic_blob, - WERD_RES *word_res, int *blob_number) { + WERD_RES *word_res, unsigned *blob_number) { TWERD *word = word_res->chopped_word; for (*blob_number = 0; *blob_number < word->NumBlobs(); ++*blob_number) { TBLOB *blob = word->blobs[*blob_number]; @@ -319,13 +319,13 @@ SEAM *Wordrec::chop_overlapping_blob(const std::vector &boxes, bool italic */ SEAM *Wordrec::improve_one_blob(const std::vector &blob_choices, DANGERR *fixpt, bool split_next_to_fragment, bool italic_blob, WERD_RES *word, - int *blob_number) { + unsigned *blob_number) { float rating_ceiling = FLT_MAX; SEAM *seam = nullptr; do { *blob_number = select_blob_to_split_from_fixpt(fixpt); if (chop_debug) { - tprintf("blob_number from fixpt = %d\n", *blob_number); + tprintf("blob_number from fixpt = %u\n", *blob_number); } bool split_point_from_dict = (*blob_number != -1); if (split_point_from_dict) { @@ -334,7 +334,7 @@ SEAM *Wordrec::improve_one_blob(const std::vector &blob_choices, *blob_number = select_blob_to_split(blob_choices, rating_ceiling, split_next_to_fragment); } if (chop_debug) { - tprintf("blob_number = %d\n", *blob_number); + tprintf("blob_number = %u\n", *blob_number); } if (*blob_number == -1) { return nullptr; @@ -365,7 +365,7 @@ SEAM *Wordrec::improve_one_blob(const std::vector &blob_choices, */ SEAM *Wordrec::chop_one_blob(const std::vector &boxes, const std::vector &blob_choices, WERD_RES *word_res, - int *blob_number) { + unsigned *blob_number) { if (prioritize_division) { return chop_overlapping_blob(boxes, true, word_res, blob_number); } else { @@ -445,7 +445,7 @@ void Wordrec::improve_by_chopping(float rating_cert_scale, WERD_RES *word, BestChoiceBundle *best_choice_bundle, BlamerBundle *blamer_bundle, LMPainPoints *pain_points, std::vector *pending) { - int blob_number; + unsigned blob_number; do { // improvement loop. // Make a simple vector of BLOB_CHOICEs to make it easy to pick which // one to chop. diff --git a/src/wordrec/language_model.cpp b/src/wordrec/language_model.cpp index d1418bb896..cbce24265c 100644 --- a/src/wordrec/language_model.cpp +++ b/src/wordrec/language_model.cpp @@ -828,10 +828,9 @@ LanguageModelDawgInfo *LanguageModel::GenerateDawgInfo(bool word_end, int curr_c return nullptr; } - int i; - // Check a that the path terminated before the current character is a word. + // Check that the path terminated before the current character is a word. bool has_word_ending = false; - for (i = 0; i < parent_vse->dawg_info->active_dawgs.size(); ++i) { + for (unsigned i = 0; i < parent_vse->dawg_info->active_dawgs.size(); ++i) { const DawgPosition &pos = parent_vse->dawg_info->active_dawgs[i]; const Dawg *pdawg = pos.dawg_index < 0 ? nullptr : dict_->GetDawg(pos.dawg_index); if (pdawg == nullptr || pos.back_to_punc) { diff --git a/src/wordrec/params_model.cpp b/src/wordrec/params_model.cpp index cda48c8c47..6578ef2e17 100644 --- a/src/wordrec/params_model.cpp +++ b/src/wordrec/params_model.cpp @@ -154,7 +154,7 @@ bool ParamsModel::SaveToFile(const char *full_path) const { return false; } bool all_good = true; - for (int i = 0; i < weights.size(); i++) { + for (unsigned i = 0; i < weights.size(); i++) { if (fprintf(fp, "%s %f\n", kParamsTrainingFeatureTypeName[i], weights[i]) < 0) { all_good = false; } diff --git a/src/wordrec/wordrec.h b/src/wordrec/wordrec.h index c53ae9c0fa..2ddf4be4a2 100644 --- a/src/wordrec/wordrec.h +++ b/src/wordrec/wordrec.h @@ -338,13 +338,13 @@ class TESS_API Wordrec : public Classify { SEAM *chop_numbered_blob(TWERD *word, int32_t blob_number, bool italic_blob, const std::vector &seams); SEAM *chop_overlapping_blob(const std::vector &boxes, bool italic_blob, WERD_RES *word_res, - int *blob_number); + unsigned *blob_number); SEAM *improve_one_blob(const std::vector &blob_choices, DANGERR *fixpt, bool split_next_to_fragment, bool italic_blob, WERD_RES *word, - int *blob_number); + unsigned *blob_number); SEAM *chop_one_blob(const std::vector &boxes, const std::vector &blob_choices, WERD_RES *word_res, - int *blob_number); + unsigned *blob_number); void chop_word_main(WERD_RES *word); void improve_by_chopping(float rating_cert_scale, WERD_RES *word, BestChoiceBundle *best_choice_bundle, BlamerBundle *blamer_bundle,