提交 6b8b1f00 编写于 作者: S Stefan Weil

unittest: Remove some dependencies on abseil

Signed-off-by: NStefan Weil <sw@weilnetz.de>
上级 d50baec7
......@@ -1521,7 +1521,7 @@ qrsequence_test_LDADD = $(ABSEIL_LIBS) $(TESS_LIBS)
recodebeam_test_SOURCES = unittest/recodebeam_test.cc
recodebeam_test_CPPFLAGS = $(unittest_CPPFLAGS)
recodebeam_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS) $(ICU_I18N_LIBS) $(ICU_UC_LIBS)
recodebeam_test_LDADD = $(TRAINING_LIBS) $(ICU_I18N_LIBS) $(ICU_UC_LIBS)
rect_test_SOURCES = unittest/rect_test.cc
rect_test_CPPFLAGS = $(unittest_CPPFLAGS)
......@@ -1529,7 +1529,7 @@ rect_test_LDADD = $(TESS_LIBS)
resultiterator_test_SOURCES = unittest/resultiterator_test.cc
resultiterator_test_CPPFLAGS = $(unittest_CPPFLAGS)
resultiterator_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS)
resultiterator_test_LDADD = $(TRAINING_LIBS)
resultiterator_test_LDADD += $(LEPTONICA_LIBS) $(ICU_I18N_LIBS) $(ICU_UC_LIBS)
scanutils_test_SOURCES = unittest/scanutils_test.cc
......@@ -1580,7 +1580,7 @@ tatweel_test_LDADD = $(TRAINING_LIBS)
textlineprojection_test_SOURCES = unittest/textlineprojection_test.cc
textlineprojection_test_CPPFLAGS = $(unittest_CPPFLAGS)
textlineprojection_test_LDADD = $(ABSEIL_LIBS) $(TRAINING_LIBS) $(LEPTONICA_LIBS)
textlineprojection_test_LDADD = $(TRAINING_LIBS) $(LEPTONICA_LIBS)
tfile_test_SOURCES = unittest/tfile_test.cc
tfile_test_CPPFLAGS = $(unittest_CPPFLAGS)
......
......@@ -32,7 +32,6 @@
#include "trainingsample.h"
#include "unicharset.h"
#include "absl/strings/numbers.h" // for safe_strto32
#include "absl/strings/str_split.h" // for absl::StrSplit
#include <string>
......
......@@ -22,8 +22,6 @@
#include "helpers.h"
#include "absl/strings/str_format.h" // for absl::StrFormat
namespace tesseract {
// Number of characters to test beam search with.
......@@ -160,9 +158,9 @@ protected:
if (u_decoded.size() < truth_utf8.size()) {
const char *str = ccutil_.unicharset.id_to_unichar(unichar_ids[u]);
total_rating += ratings[u];
LOG(INFO) << absl::StrFormat("%d:u_id=%d=%s, c=%g, r=%g, r_sum=%g @%d", u, unichar_ids[u],
str, certainties[u], ratings[u], total_rating, xcoords[u])
<< "\n";
LOG(INFO) << u << ":u_id=" << unichar_ids[u] << "=" << str << ", c="
<< certainties[u] << ", r=" << ratings[u] << "r_sum="
<< total_rating << " @" << xcoords[u] << "\n";
if (str[0] == ' ') {
total_rating = 0.0f;
}
......@@ -184,11 +182,9 @@ protected:
}
w_decoded += word->best_choice->unichar_string().c_str();
}
LOG(INFO) << absl::StrFormat("Word:%d = %s, c=%g, r=%g, perm=%d", w,
word->best_choice->unichar_string().c_str(),
word->best_choice->certainty(), word->best_choice->rating(),
word->best_choice->permuter())
<< "\n";
LOG(INFO) << "Word:" << w << " = " << word->best_choice->unichar_string()
<< ", c=" << word->best_choice->certainty() << ", r=" << word->best_choice->rating()
<< ", perm=" << word->best_choice->permuter() << "\n";
}
std::string w_trunc(w_decoded.data(), truth_utf8.size());
if (truth_utf8 != w_trunc) {
......
......@@ -5,7 +5,6 @@
#include <string>
#include "scrollview.h"
#include "absl/strings/str_format.h" // for absl::StrFormat
#include "include_gunit.h"
#include "log.h" // for LOG
......@@ -99,7 +98,7 @@ protected:
pixWrite(outfile.c_str(), pix, IFF_PNG);
}
pix.destroy();
LOG(INFO) << absl::StrFormat("At level %d: pix diff = %d\n", level, pixcount);
LOG(INFO) << "At level " << level << ": pix diff = " << pixcount << "\n";
EXPECT_LE(pixcount, max_diff);
// if (base::GetFlag(FLAGS_v) > 1) CHECK_LE(pixcount, max_diff);
}
......@@ -293,7 +292,8 @@ TEST_F(ResultIteratorTest, EasyTest) {
// Test baseline of the first line.
int x1, y1, x2, y2;
r_it->Baseline(tesseract::RIL_TEXTLINE, &x1, &y1, &x2, &y2);
LOG(INFO) << absl::StrFormat("Baseline (%d,%d)->(%d,%d)", x1, y1, x2, y2) << "\n";
LOG(INFO) << "Baseline ("
<< x1 << ',' << y1 << ")->(" << x2 << ',' << y2 << ")\n";
// Make sure we have a decent vector.
EXPECT_GE(x2, x1 + 400);
// The point 200,116 should be very close to the baseline.
......@@ -315,9 +315,9 @@ TEST_F(ResultIteratorTest, EasyTest) {
float confidence = r_it->Confidence(tesseract::RIL_WORD);
EXPECT_GE(confidence, 80.0f);
char *word_str = r_it->GetUTF8Text(tesseract::RIL_WORD);
LOG(INFO) << absl::StrFormat("Word %s in font %s, id %d, size %d, conf %g", word_str, font,
font_id, pointsize, confidence)
<< "\n";
LOG(INFO) << "Word " << word_str << " in font " << font
<< ", id " << font_id << ", size " << pointsize
<< ", conf " << confidence << "\n";
delete[] word_str;
EXPECT_FALSE(bold);
EXPECT_FALSE(italic);
......@@ -372,8 +372,8 @@ TEST_F(ResultIteratorTest, SmallCapDropCapTest) {
&pointsize, &font_id);
char *word_str = r_it->GetUTF8Text(tesseract::RIL_WORD);
if (word_str != nullptr) {
LOG(INFO) << absl::StrFormat("Word %s is %s", word_str, smallcaps ? "SMALLCAPS" : "Normal")
<< "\n";
LOG(INFO) << "Word " << word_str
<< " is " << (smallcaps ? "SMALLCAPS" : "Normal") << "\n";
if (r_it->SymbolIsDropcap()) {
++found_dropcaps;
}
......@@ -392,7 +392,7 @@ TEST_F(ResultIteratorTest, SmallCapDropCapTest) {
while (s_it.Next(tesseract::RIL_SYMBOL) && !s_it.IsAtBeginningOf(tesseract::RIL_WORD)) {
if (s_it.SymbolIsDropcap()) {
char *sym_str = s_it.GetUTF8Text(tesseract::RIL_SYMBOL);
LOG(ERROR) << absl::StrFormat("Symbol %s of word %s is dropcap", sym_str, word_str);
LOG(ERROR) << "Symbol " << sym_str << " of word " << word_str << " is dropcap";
delete[] sym_str;
}
EXPECT_FALSE(s_it.SymbolIsDropcap());
......@@ -433,8 +433,7 @@ TEST_F(ResultIteratorTest, SubSuperTest) {
result = r_it->GetUTF8Text(tesseract::RIL_SYMBOL);
if (strchr(kAllowedSupers, result[0]) == nullptr) {
char* word = r_it->GetUTF8Text(tesseract::RIL_WORD);
LOG(ERROR) << absl::StrFormat("Char %s in word %s is unexpected super!",
result, word);
LOG(ERROR) << "Char " << result << " in word " << word << " is unexpected super!";
delete [] word;
EXPECT_TRUE(strchr(kAllowedSupers, result[0]) != nullptr);
}
......@@ -445,8 +444,8 @@ TEST_F(ResultIteratorTest, SubSuperTest) {
}
} while (r_it->Next(tesseract::RIL_SYMBOL));
delete r_it;
LOG(INFO) << absl::StrFormat("Subs = %d, supers= %d, normal = %d",
found_subs, found_supers, found_normal) << "\n";
LOG(INFO) << "Subs = " << found_subs << ", supers= " << found_supers
<< ", normal = " << found_normal << "\n";
EXPECT_GE(found_subs, 25);
EXPECT_GE(found_supers, 25);
EXPECT_GE(found_normal, 1350);
......@@ -528,7 +527,7 @@ TEST_F(ResultIteratorTest, DISABLED_NonNullChoicesTest) {
do {
char *word_str = r_it->GetUTF8Text(tesseract::RIL_WORD);
if (word_str != nullptr) {
LOG(INFO) << absl::StrFormat("Word %s:", word_str) << "\n";
LOG(INFO) << "Word " << word_str << ":\n";
ResultIterator s_it = *r_it;
do {
tesseract::ChoiceIterator c_it(s_it);
......@@ -571,7 +570,7 @@ TEST_F(ResultIteratorTest, NonNullConfidencesTest) {
const char *char_str = s_it.GetUTF8Text(tesseract::RIL_SYMBOL);
CHECK(char_str != nullptr);
float confidence = s_it.Confidence(tesseract::RIL_SYMBOL);
LOG(INFO) << absl::StrFormat("Char %s has confidence %g\n", char_str, confidence);
LOG(INFO) << "Char " << char_str << " has confidence " << confidence << "\n";
delete[] char_str;
} while (!s_it.IsAtFinalElement(tesseract::RIL_WORD, tesseract::RIL_SYMBOL) &&
s_it.Next(tesseract::RIL_SYMBOL));
......
......@@ -12,7 +12,6 @@
#include <allheaders.h>
#include <string> // for std::string
#include "absl/strings/str_format.h" // for absl::StrFormat
#include "include_gunit.h"
#include <tesseract/baseapi.h>
......@@ -114,13 +113,12 @@ protected:
const char *message) {
int value = projection_->EvaluateBox(box, denorm_, false);
if (greater_or_equal != (value > target_value)) {
LOG(INFO) << absl::StrFormat(
"EvaluateBox too %s:%d vs %d for %s word '%s' at:", greater_or_equal ? "low" : "high",
value, target_value, message, text);
LOG(INFO) << "EvaluateBox too " << (greater_or_equal ? "low" : "high")
<< ":" << value << " vs " << target_value << " for " << message << " word '" << text << "' at:";
box.print();
value = projection_->EvaluateBox(box, denorm_, true);
} else {
LOG(INFO) << absl::StrFormat("EvaluateBox OK(%d) for %s word '%s'", value, message, text);
LOG(INFO) << "EvaluateBox OK(" << value << ") for " << message << " word '" << text << "'";
}
if (greater_or_equal) {
EXPECT_GE(value, target_value);
......@@ -136,14 +134,14 @@ protected:
int true_dist = projection_->DistanceOfBoxFromBox(box, true_box, true, denorm_, false);
int false_dist = projection_->DistanceOfBoxFromBox(box, false_box, true, denorm_, false);
if (false_dist <= true_dist) {
LOG(INFO) << absl::StrFormat("Distance wrong:%d vs %d for %s word '%s' at:", false_dist,
true_dist, message, text);
LOG(INFO) << "Distance wrong:" << false_dist << " vs " << true_dist
<< " for " << message << " word '" << text << "' at:";
true_box.print();
projection_->DistanceOfBoxFromBox(box, true_box, true, denorm_, true);
projection_->DistanceOfBoxFromBox(box, false_box, true, denorm_, true);
} else {
LOG(INFO) << absl::StrFormat("Distance OK(%d vs %d) for %s word '%s'", false_dist, true_dist,
message, text);
LOG(INFO) << "Distance OK(" << false_dist << " vs " << true_dist
<< ") for " << message << " word '" << text << "'";
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册