Skip to content

Commit

Permalink
wordrec: Fix some signed/unsigned compiler warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Oct 10, 2021
1 parent cb10da0 commit 86d981e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/wordrec/chopper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TBOX> &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];
Expand Down Expand Up @@ -319,13 +319,13 @@ SEAM *Wordrec::chop_overlapping_blob(const std::vector<TBOX> &boxes, bool italic
*/
SEAM *Wordrec::improve_one_blob(const std::vector<BLOB_CHOICE *> &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) {
Expand All @@ -334,7 +334,7 @@ SEAM *Wordrec::improve_one_blob(const std::vector<BLOB_CHOICE *> &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;
Expand Down Expand Up @@ -365,7 +365,7 @@ SEAM *Wordrec::improve_one_blob(const std::vector<BLOB_CHOICE *> &blob_choices,
*/
SEAM *Wordrec::chop_one_blob(const std::vector<TBOX> &boxes,
const std::vector<BLOB_CHOICE *> &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 {
Expand Down Expand Up @@ -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<SegSearchPending> *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.
Expand Down
5 changes: 2 additions & 3 deletions src/wordrec/language_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/wordrec/params_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/wordrec/wordrec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<SEAM *> &seams);
SEAM *chop_overlapping_blob(const std::vector<TBOX> &boxes, bool italic_blob, WERD_RES *word_res,
int *blob_number);
unsigned *blob_number);
SEAM *improve_one_blob(const std::vector<BLOB_CHOICE *> &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<TBOX> &boxes,
const std::vector<BLOB_CHOICE *> &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,
Expand Down

0 comments on commit 86d981e

Please sign in to comment.