mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-23 18:49:08 +08:00
unittest: Remove dependency on absl::StrCat()
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
8486f59493
commit
61b8e301dd
@ -1192,7 +1192,6 @@ libabseil_la_SOURCES += abseil/absl/strings/internal/str_format/output.cc
|
||||
libabseil_la_SOURCES += abseil/absl/strings/internal/str_format/parser.cc
|
||||
libabseil_la_SOURCES += abseil/absl/strings/match.cc
|
||||
libabseil_la_SOURCES += abseil/absl/strings/numbers.cc
|
||||
libabseil_la_SOURCES += abseil/absl/strings/str_cat.cc
|
||||
libabseil_la_SOURCES += abseil/absl/strings/str_split.cc
|
||||
libabseil_la_SOURCES += abseil/absl/strings/string_view.cc
|
||||
libabseil_la_CPPFLAGS = -I$(top_srcdir)/abseil
|
||||
@ -1381,7 +1380,7 @@ heap_test_LDADD = $(TESS_LIBS)
|
||||
|
||||
imagedata_test_SOURCES = unittest/imagedata_test.cc
|
||||
imagedata_test_CPPFLAGS = $(unittest_CPPFLAGS)
|
||||
imagedata_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS)
|
||||
imagedata_test_LDADD = $(TRAINING_LIBS)
|
||||
|
||||
if !DISABLED_LEGACY_ENGINE
|
||||
indexmapbidi_test_SOURCES = unittest/indexmapbidi_test.cc
|
||||
@ -1407,7 +1406,7 @@ intsimdmatrix_test_LDADD = $(TESS_LIBS)
|
||||
|
||||
lang_model_test_SOURCES = unittest/lang_model_test.cc
|
||||
lang_model_test_CPPFLAGS = $(unittest_CPPFLAGS)
|
||||
lang_model_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS) $(ICU_I18N_LIBS) $(ICU_UC_LIBS)
|
||||
lang_model_test_LDADD = $(TRAINING_LIBS) $(ICU_I18N_LIBS) $(ICU_UC_LIBS)
|
||||
|
||||
layout_test_SOURCES = unittest/layout_test.cc
|
||||
layout_test_CPPFLAGS = $(unittest_CPPFLAGS)
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include <allheaders.h>
|
||||
#include "absl/strings/ascii.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "gmock/gmock-matchers.h"
|
||||
|
||||
#include <memory>
|
||||
@ -323,7 +322,9 @@ TEST(TesseractInstanceTest, TestMultipleTessInstances) {
|
||||
// Preload images and verify that OCR is correct on them individually.
|
||||
std::vector<Image > pix(num_langs);
|
||||
for (int i = 0; i < num_langs; ++i) {
|
||||
SCOPED_TRACE(absl::StrCat("Single instance test with lang = ", langs[i]));
|
||||
std::string tracestring = "Single instance test with lang = ";
|
||||
tracestring += langs[i];
|
||||
SCOPED_TRACE(tracestring);
|
||||
std::string path = file::JoinPath(TESTING_DIR, image_files[i]);
|
||||
pix[i] = pixRead(path.c_str());
|
||||
QCHECK(pix[i] != nullptr) << "Could not read " << path;
|
||||
|
@ -12,8 +12,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/str_cat.h"
|
||||
|
||||
#include "imagedata.h"
|
||||
#include "include_gunit.h"
|
||||
#include "log.h"
|
||||
@ -52,7 +50,8 @@ protected:
|
||||
}
|
||||
// Write it to a file.
|
||||
std::string filename =
|
||||
file::JoinPath(FLAGS_test_tmpdir, absl::StrCat("documentdata", doc_id, ".lstmf"));
|
||||
file::JoinPath(FLAGS_test_tmpdir, "documentdata");
|
||||
filename += std::to_string(doc_id) + ".lstmf";
|
||||
EXPECT_TRUE(write_doc.SaveDocument(filename.c_str(), nullptr));
|
||||
return filename;
|
||||
}
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
#include <string> // for std::string
|
||||
|
||||
#include "absl/strings/str_cat.h"
|
||||
|
||||
#include "gmock/gmock.h" // for testing::ElementsAreArray
|
||||
|
||||
#include "include_gunit.h"
|
||||
@ -59,7 +57,7 @@ TEST(LangModelTest, AddACharacter) {
|
||||
pass_through_recoder, words, puncs, numbers, lang_is_rtl, nullptr,
|
||||
nullptr));
|
||||
// Init a trainer with it, and encode kTestString.
|
||||
std::string traineddata1 = file::JoinPath(output_dir, lang1, absl::StrCat(lang1, ".traineddata"));
|
||||
std::string traineddata1 = file::JoinPath(output_dir, lang1, lang1) + ".traineddata";
|
||||
LSTMTrainer trainer1;
|
||||
trainer1.InitCharSet(traineddata1);
|
||||
std::vector<int> labels1;
|
||||
@ -79,7 +77,7 @@ TEST(LangModelTest, AddACharacter) {
|
||||
pass_through_recoder, words, puncs, numbers, lang_is_rtl,
|
||||
nullptr, nullptr));
|
||||
// Init a trainer with it, and encode kTestString.
|
||||
std::string traineddata2 = file::JoinPath(output_dir, lang2, absl::StrCat(lang2, ".traineddata"));
|
||||
std::string traineddata2 = file::JoinPath(output_dir, lang2, lang2) + ".traineddata";
|
||||
LSTMTrainer trainer2;
|
||||
trainer2.InitCharSet(traineddata2);
|
||||
std::vector<int> labels2;
|
||||
@ -144,7 +142,7 @@ TEST(LangModelTest, AddACharacterHindi) {
|
||||
pass_through_recoder, words, puncs, numbers, lang_is_rtl, nullptr,
|
||||
nullptr));
|
||||
// Init a trainer with it, and encode kTestString.
|
||||
std::string traineddata1 = file::JoinPath(output_dir, lang1, absl::StrCat(lang1, ".traineddata"));
|
||||
std::string traineddata1 = file::JoinPath(output_dir, lang1, lang1) + ".traineddata";
|
||||
LSTMTrainer trainer1;
|
||||
trainer1.InitCharSet(traineddata1);
|
||||
std::vector<int> labels1;
|
||||
@ -164,7 +162,7 @@ TEST(LangModelTest, AddACharacterHindi) {
|
||||
pass_through_recoder, words, puncs, numbers, lang_is_rtl,
|
||||
nullptr, nullptr));
|
||||
// Init a trainer with it, and encode kTestString.
|
||||
std::string traineddata2 = file::JoinPath(output_dir, lang2, absl::StrCat(lang2, ".traineddata"));
|
||||
std::string traineddata2 = file::JoinPath(output_dir, lang2, lang2) + ".traineddata";
|
||||
LSTMTrainer trainer2;
|
||||
trainer2.InitCharSet(traineddata2);
|
||||
std::vector<int> labels2;
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include "include_gunit.h"
|
||||
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "helpers.h"
|
||||
#include "tprintf.h"
|
||||
|
||||
@ -81,7 +80,7 @@ protected:
|
||||
std::string checkpoint_path = model_path + "_checkpoint";
|
||||
trainer_ = std::make_unique<LSTMTrainer>(model_path.c_str(), checkpoint_path.c_str(), 0, 0);
|
||||
trainer_->InitCharSet(
|
||||
file::JoinPath(FLAGS_test_tmpdir, kLang, absl::StrCat(kLang, ".traineddata")));
|
||||
file::JoinPath(FLAGS_test_tmpdir, kLang, kLang) + ".traineddata");
|
||||
int net_mode = adam ? NF_ADAM : 0;
|
||||
// Adam needs a higher learning rate, due to not multiplying the effective
|
||||
// rate by 1/(1-momentum).
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include <sstream> // for std::stringstream
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/str_join.h"
|
||||
|
||||
namespace tesseract {
|
||||
@ -33,7 +32,9 @@ inline std::string CodepointList(const std::vector<char32> &str32) {
|
||||
|
||||
inline std::string PrintString32WithUnicodes(const std::string &str) {
|
||||
std::vector<char32> str32 = UNICHAR::UTF8ToUTF32(str.c_str());
|
||||
return absl::StrCat("\"", str, "\" ", CodepointList(str32));
|
||||
std::string s = "\"";
|
||||
s += "\" " + CodepointList(str32);
|
||||
return s;
|
||||
}
|
||||
|
||||
inline std::string PrintStringVectorWithUnicodes(const std::vector<std::string> &glyphs) {
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <pango/pango.h>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include "absl/strings/str_cat.h" // for absl::StrCat
|
||||
#include "commandlineflags.h"
|
||||
#include "fileio.h"
|
||||
#include "gmock/gmock-matchers.h" // for EXPECT_THAT
|
||||
@ -316,7 +315,8 @@ TEST_F(FontUtilsTest, GetAllRenderableCharacters) {
|
||||
// Check that none of the included fonts cover the Mongolian or Ogham space
|
||||
// characters.
|
||||
for (size_t f = 0; f < countof(kExpectedFontNames); ++f) {
|
||||
SCOPED_TRACE(absl::StrCat("Testing ", kExpectedFontNames[f]));
|
||||
std::string tracestring = "Testing " + kExpectedFontNames[f];
|
||||
SCOPED_TRACE(tracestring);
|
||||
FontUtils::GetAllRenderableCharacters(kExpectedFontNames[f], &unicode_mask);
|
||||
# if 0 // TODO: check fails because DejaVu Sans Ultra-Light supports ogham
|
||||
EXPECT_FALSE(unicode_mask[kOghamChar]);
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include <string> // for std::string
|
||||
|
||||
#include "absl/strings/str_cat.h" // for absl::StrCat
|
||||
#include "absl/strings/str_join.h" // for absl::StrJoin
|
||||
#include "absl/strings/str_split.h" // for absl::StrSplit
|
||||
|
||||
@ -156,10 +155,11 @@ void EvaluateParagraphDetection(const TextAndModel *correct, int n,
|
||||
dbg_lines.emplace_back("# ==========================");
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (correct[i].model_type != PCONT) {
|
||||
dbg_lines.push_back(absl::StrCat(correct[i].ascii, " # ",
|
||||
correct[i].model.ToString().c_str(),
|
||||
correct[i].is_very_first_or_continuation ? " crown" : "",
|
||||
correct[i].is_list_item ? " li" : ""));
|
||||
std::string s = std::string(correct[i].ascii) + " # " +
|
||||
correct[i].model.ToString() +
|
||||
(correct[i].is_very_first_or_continuation ? " crown" : "") +
|
||||
(correct[i].is_list_item ? " li" : "");
|
||||
dbg_lines.push_back(s);
|
||||
} else {
|
||||
dbg_lines.emplace_back(correct[i].ascii);
|
||||
}
|
||||
@ -173,14 +173,15 @@ void EvaluateParagraphDetection(const TextAndModel *correct, int n,
|
||||
if (i == 0 || (detector_output[i - 1] != detector_output[i])) {
|
||||
if (detector_output[i] && detector_output[i]->model) {
|
||||
annotation +=
|
||||
absl::StrCat(" # ", detector_output[i]->model->ToString().c_str(),
|
||||
detector_output[i]->is_very_first_or_continuation ? " crown" : "",
|
||||
detector_output[i]->is_list_item ? " li" : "");
|
||||
" # " + detector_output[i]->model->ToString() +
|
||||
(detector_output[i]->is_very_first_or_continuation ? " crown" : "") +
|
||||
(detector_output[i]->is_list_item ? " li" : "");
|
||||
} else {
|
||||
annotation = " # Unmodeled paragraph.";
|
||||
}
|
||||
}
|
||||
dbg_lines.push_back(absl::StrCat(correct[i].ascii, annotation));
|
||||
std::string s = correct[i].ascii + annotation;
|
||||
dbg_lines.push_back(s);
|
||||
}
|
||||
LOG(INFO) << "Discrepancy!\n" << absl::StrJoin(dbg_lines, "\n");
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include <allheaders.h>
|
||||
#include "absl/strings/ascii.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/str_split.h"
|
||||
|
||||
#include "include_gunit.h"
|
||||
@ -46,7 +45,7 @@ protected:
|
||||
compressed_.EncodeUnichar(null_char_, &code);
|
||||
encoded_null_char_ = code(0);
|
||||
std::string output_name =
|
||||
file::JoinPath(FLAGS_test_tmpdir, absl::StrCat(unicharset_name, ".encoding.txt"));
|
||||
file::JoinPath(FLAGS_test_tmpdir, unicharset_name) + ".encoding.txt";
|
||||
std::string encoding = compressed_.GetEncodingAsString(unicharset_);
|
||||
std::string encoding_str(&encoding[0], encoding.size());
|
||||
CHECK_OK(file::SetContents(output_name, encoding_str, file::Defaults()));
|
||||
|
Loading…
Reference in New Issue
Block a user