Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/tesseract-ocr-original/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
GerHobbelt committed May 24, 2024
2 parents 1bab168 + ea82f91 commit d6550e5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/lstm/recodebeam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,15 +891,13 @@ void RecodeBeamSearch::ContinueContext(
int length = LengthFromBeamsIndex(index);
bool use_dawgs = IsDawgFromBeamsIndex(index);
NodeContinuation prev_cont = ContinuationFromBeamsIndex(index);
for (int p = length - 1; p >= 0; --p, previous = previous->prev) {
while (previous != nullptr &&
(previous->duplicate || previous->code == null_char_)) {
for (int p = length - 1; p >= 0 && previous != nullptr; --p) {
while (previous->duplicate || previous->code == null_char_) {
previous = previous->prev;
}
if (previous != nullptr) {
prefix.Set(p, previous->code);
full_code.Set(p, previous->code);
}
prefix.Set(p, previous->code);
full_code.Set(p, previous->code);
previous = previous->prev;
}
if (prev != nullptr && !is_simple_text_) {
if (top_n_flags_[prev->code] == top_n_flag) {
Expand Down
2 changes: 1 addition & 1 deletion src/training/unicharset/fileio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bool File::Readable(const std::string &filename) {
}

bool File::ReadFileToString(const std::string &filename, std::string *out) {
FILE *stream = File::Open(filename.c_str(), "rb");
FILE *stream = File::Open(filename, "rb");
if (stream == nullptr) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/training/unicharset/lang_model_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ bool WriteRecoder(const UNICHARSET &unicharset, bool pass_through, const std::st
std::string suffix;
suffix += ".charset_size=" + std::to_string(recoder.code_range());
suffix += ".txt";
return WriteFile(output_dir, lang, suffix.c_str(), recoder_data, writer);
return WriteFile(output_dir, lang, suffix, recoder_data, writer);
}

// Helper builds a dawg from the given words, using the unicharset as coding,
Expand Down

0 comments on commit d6550e5

Please sign in to comment.