mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-05 02:47:00 +08:00
Fix tesseract --list-langs
Signed-off-by: Stefan Weil <sw@weil.de>
This commit is contained in:
parent
e80a8869f5
commit
524fc67165
@ -256,12 +256,12 @@ class TESS_API TessBaseAPI {
|
|||||||
* Includes all languages loaded by the last Init, including those loaded
|
* Includes all languages loaded by the last Init, including those loaded
|
||||||
* as dependencies of other loaded languages.
|
* as dependencies of other loaded languages.
|
||||||
*/
|
*/
|
||||||
void GetLoadedLanguagesAsVector(GenericVector<STRING>* langs) const;
|
void GetLoadedLanguagesAsVector(std::vector<STRING>* langs) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the available languages in the sorted vector of STRINGs.
|
* Returns the available languages in the sorted vector of STRINGs.
|
||||||
*/
|
*/
|
||||||
void GetAvailableLanguagesAsVector(GenericVector<STRING>* langs) const;
|
void GetAvailableLanguagesAsVector(std::vector<STRING>* langs) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init only the lang model component of Tesseract. The only functions
|
* Init only the lang model component of Tesseract. The only functions
|
||||||
|
@ -127,7 +127,7 @@ const int kMaxIntSize = 22;
|
|||||||
/* Add all available languages recursively.
|
/* Add all available languages recursively.
|
||||||
*/
|
*/
|
||||||
static void addAvailableLanguages(const STRING &datadir, const STRING &base,
|
static void addAvailableLanguages(const STRING &datadir, const STRING &base,
|
||||||
GenericVector<STRING>* langs)
|
std::vector<STRING>* langs)
|
||||||
{
|
{
|
||||||
auto base2 = base;
|
auto base2 = base;
|
||||||
if (!base2.empty())
|
if (!base2.empty())
|
||||||
@ -278,6 +278,9 @@ void TessBaseAPI::SetInputName(const char* name) {
|
|||||||
|
|
||||||
/** Set the name of the output files. Needed only for debugging. */
|
/** Set the name of the output files. Needed only for debugging. */
|
||||||
void TessBaseAPI::SetOutputName(const char* name) {
|
void TessBaseAPI::SetOutputName(const char* name) {
|
||||||
|
if (name == nullptr) {
|
||||||
|
name = "";
|
||||||
|
}
|
||||||
if (output_file_ == nullptr)
|
if (output_file_ == nullptr)
|
||||||
output_file_ = new STRING(name);
|
output_file_ = new STRING(name);
|
||||||
else
|
else
|
||||||
@ -363,6 +366,9 @@ int TessBaseAPI::Init(const char* data, int data_size, const char* language,
|
|||||||
bool set_only_non_debug_params, FileReader reader) {
|
bool set_only_non_debug_params, FileReader reader) {
|
||||||
// Default language is "eng".
|
// Default language is "eng".
|
||||||
if (language == nullptr) language = "eng";
|
if (language == nullptr) language = "eng";
|
||||||
|
if (data == nullptr) {
|
||||||
|
data = "";
|
||||||
|
}
|
||||||
STRING datapath = data_size == 0 ? data : language;
|
STRING datapath = data_size == 0 ? data : language;
|
||||||
// If the datapath, OcrEngineMode or the language have changed - start again.
|
// If the datapath, OcrEngineMode or the language have changed - start again.
|
||||||
// Note that the language_ field stores the last requested language that was
|
// Note that the language_ field stores the last requested language that was
|
||||||
@ -441,7 +447,7 @@ const char* TessBaseAPI::GetInitLanguagesAsString() const {
|
|||||||
* as dependencies of other loaded languages.
|
* as dependencies of other loaded languages.
|
||||||
*/
|
*/
|
||||||
void TessBaseAPI::GetLoadedLanguagesAsVector(
|
void TessBaseAPI::GetLoadedLanguagesAsVector(
|
||||||
GenericVector<STRING>* langs) const {
|
std::vector<STRING>* langs) const {
|
||||||
langs->clear();
|
langs->clear();
|
||||||
if (tesseract_ != nullptr) {
|
if (tesseract_ != nullptr) {
|
||||||
langs->push_back(tesseract_->lang);
|
langs->push_back(tesseract_->lang);
|
||||||
@ -455,11 +461,11 @@ void TessBaseAPI::GetLoadedLanguagesAsVector(
|
|||||||
* Returns the available languages in the sorted vector of STRINGs.
|
* Returns the available languages in the sorted vector of STRINGs.
|
||||||
*/
|
*/
|
||||||
void TessBaseAPI::GetAvailableLanguagesAsVector(
|
void TessBaseAPI::GetAvailableLanguagesAsVector(
|
||||||
GenericVector<STRING>* langs) const {
|
std::vector<STRING>* langs) const {
|
||||||
langs->clear();
|
langs->clear();
|
||||||
if (tesseract_ != nullptr) {
|
if (tesseract_ != nullptr) {
|
||||||
addAvailableLanguages(tesseract_->datadir, "", langs);
|
addAvailableLanguages(tesseract_->datadir, "", langs);
|
||||||
langs->sort(CompareSTRING);
|
std::sort(langs->begin(), langs->end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user