diff --git a/Makefile.am b/Makefile.am index efd0199b..9f17fe06 100644 --- a/Makefile.am +++ b/Makefile.am @@ -387,7 +387,6 @@ endif noinst_HEADERS += src/classify/classify.h if !DISABLED_LEGACY_ENGINE noinst_HEADERS += src/classify/adaptive.h -noinst_HEADERS += src/classify/blobclass.h noinst_HEADERS += src/classify/cluster.h noinst_HEADERS += src/classify/clusttool.h noinst_HEADERS += src/classify/featdefs.h diff --git a/src/api/baseapi.cpp b/src/api/baseapi.cpp index 61b7b390..d1383693 100644 --- a/src/api/baseapi.cpp +++ b/src/api/baseapi.cpp @@ -23,9 +23,6 @@ # include "config_auto.h" #endif -#ifndef DISABLED_LEGACY_ENGINE -# include "blobclass.h" // for ExtractFontName -#endif #include "boxword.h" // for BoxWord #include "coutln.h" // for C_OUTLINE_IT, C_OUTLINE_LIST #include "dawg_cache.h" // for DawgCache @@ -125,6 +122,34 @@ static const char *kOldVarsFile = "failed_vars.txt"; /** Max string length of an int. */ const int kMaxIntSize = 22; +#ifndef DISABLED_LEGACY_ENGINE +static const char kUnknownFontName[] = "UnknownFont"; + +static STRING_VAR(classify_font_name, kUnknownFontName, + "Default font name to be used in training"); + +// Finds the name of the training font and returns it in fontname, by cutting +// it out based on the expectation that the filename is of the form: +// /path/to/dir/[lang].[fontname].exp[num] +// The [lang], [fontname] and [num] fields should not have '.' characters. +// If the global parameter classify_font_name is set, its value is used instead. +static void ExtractFontName(const char* filename, std::string* fontname) { + *fontname = classify_font_name; + if (*fontname == kUnknownFontName) { + // filename is expected to be of the form [lang].[fontname].exp[num] + // The [lang], [fontname] and [num] fields should not have '.' characters. + const char *basename = strrchr(filename, '/'); + const char *firstdot = strchr(basename ? basename : filename, '.'); + const char *lastdot = strrchr(filename, '.'); + if (firstdot != lastdot && firstdot != nullptr && lastdot != nullptr) { + ++firstdot; + *fontname = firstdot; + fontname->resize(lastdot - firstdot); + } + } +} +#endif + /* Add all available languages recursively. */ static void addAvailableLanguages(const std::string &datadir, const std::string &base, diff --git a/src/classify/blobclass.cpp b/src/classify/blobclass.cpp index bac15657..501d069a 100644 --- a/src/classify/blobclass.cpp +++ b/src/classify/blobclass.cpp @@ -15,8 +15,6 @@ ** limitations under the License. ******************************************************************************/ -#include "blobclass.h" - #include #include "classify.h" @@ -26,35 +24,6 @@ namespace tesseract { -static const char kUnknownFontName[] = "UnknownFont"; - -static STRING_VAR(classify_font_name, kUnknownFontName, "Default font name to be used in training"); - -/**---------------------------------------------------------------------------- - Public Code -----------------------------------------------------------------------------**/ - -// Finds the name of the training font and returns it in fontname, by cutting -// it out based on the expectation that the filename is of the form: -// /path/to/dir/[lang].[fontname].exp[num] -// The [lang], [fontname] and [num] fields should not have '.' characters. -// If the global parameter classify_font_name is set, its value is used instead. -void ExtractFontName(const char *filename, std::string *fontname) { - *fontname = classify_font_name; - if (*fontname == kUnknownFontName) { - // filename is expected to be of the form [lang].[fontname].exp[num] - // The [lang], [fontname] and [num] fields should not have '.' characters. - const char *basename = strrchr(filename, '/'); - const char *firstdot = strchr(basename ? basename : filename, '.'); - const char *lastdot = strrchr(filename, '.'); - if (firstdot != lastdot && firstdot != nullptr && lastdot != nullptr) { - ++firstdot; - *fontname = firstdot; - fontname->resize(lastdot - firstdot); - } - } -} - /*---------------------------------------------------------------------------*/ // Extracts features from the given blob and saves them in the tr_file_data_ diff --git a/src/classify/blobclass.h b/src/classify/blobclass.h deleted file mode 100644 index 3bc9cfd8..00000000 --- a/src/classify/blobclass.h +++ /dev/null @@ -1,33 +0,0 @@ -/****************************************************************************** - ** Filename: blobclass.h - ** Purpose: Interface to high level classification and training. - ** Author: Dan Johnson - ** - ** (c) Copyright Hewlett-Packard Company, 1988. - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** http://www.apache.org/licenses/LICENSE-2.0 - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ** See the License for the specific language governing permissions and - ** limitations under the License. - ******************************************************************************/ - -#ifndef BLOBCLASS_H -#define BLOBCLASS_H - -#include - -namespace tesseract { -// Finds the name of the training font and returns it in fontname, by cutting -// it out based on the expectation that the filename is of the form: -// /path/to/dir/[lang].[fontname].exp[num] -// The [lang], [fontname] and [num] fields should not have '.' characters. -// If the global parameter classify_font_name is set, its value is used instead. -void ExtractFontName(const char *filename, std::string *fontname); - -} // namespace tesseract. - -#endif