Merge pull request #1481 from stweil/version

training: Support new argument --version for remaining executables
This commit is contained in:
zdenop 2018-04-16 09:35:57 +02:00 committed by GitHub
commit 69c8292d81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 18 deletions

View File

@ -21,8 +21,6 @@
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// //
#include <stdio.h>
#include "baseapi.h" #include "baseapi.h"
#include "commontraining.h" // CheckSharedLibraryVersion #include "commontraining.h" // CheckSharedLibraryVersion
#include "helpers.h" #include "helpers.h"
@ -34,9 +32,12 @@ int main(int argc, char** argv) {
tesseract::CheckSharedLibraryVersion(); tesseract::CheckSharedLibraryVersion();
// Parse input arguments. // Parse input arguments.
if (argc != 4 && (argc != 6 || strcmp(argv[1], "-l") != 0)) { if (argc > 1 && !strcmp(argv[1], "--version")) {
printf("Usage: %s [-l lang] tessdata_dir wordlist_file" printf("%s\n", tesseract::TessBaseAPI::Version());
" output_ambiguous_wordlist_file\n", argv[0]); return 0;
} else if (argc != 4 && (argc != 6 || strcmp(argv[1], "-l") != 0)) {
printf("Usage: %s --version | %s [-l lang] tessdata_dir wordlist_file"
" output_ambiguous_wordlist_file\n", argv[0], argv[0]);
return 1; return 1;
} }
int argv_offset = 0; int argv_offset = 0;

View File

@ -70,7 +70,10 @@ int main(int argc, char **argv) {
int i; int i;
tesseract::TessdataManager tm; tesseract::TessdataManager tm;
if (argc == 2) { if (argc > 1 && !strcmp(argv[1], "--version")) {
printf("%s\n", tesseract::TessBaseAPI::Version());
return 0;
} else if (argc == 2) {
printf("Combining tessdata files\n"); printf("Combining tessdata files\n");
STRING lang = argv[1]; STRING lang = argv[1];
char* last = &argv[1][strlen(argv[1])-1]; char* last = &argv[1][strlen(argv[1])-1];

View File

@ -75,10 +75,13 @@ int WriteDawgAsWordlist(const UNICHARSET &unicharset,
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
tesseract::CheckSharedLibraryVersion(); tesseract::CheckSharedLibraryVersion();
if (argc != 4) { if (argc > 1 && !strcmp(argv[1], "--version")) {
printf("%s\n", tesseract::TessBaseAPI::Version());
return 0;
} else if (argc != 4) {
tprintf("Print all the words in a given dawg.\n"); tprintf("Print all the words in a given dawg.\n");
tprintf("Usage: %s <unicharset> <dawgfile> <wordlistfile>\n", tprintf("Usage: %s --version | %s <unicharset> <dawgfile> <wordlistfile>\n",
argv[0]); argv[0], argv[0]);
return 1; return 1;
} }
const char *unicharset_file = argv[1]; const char *unicharset_file = argv[1];

View File

@ -23,11 +23,15 @@
int main(int argc, char** argv) { int main(int argc, char** argv) {
tesseract::CheckSharedLibraryVersion(); tesseract::CheckSharedLibraryVersion();
// Print usage if (argc > 1 && !strcmp(argv[1], "--version")) {
if (argc < 4) { printf("%s\n", tesseract::TessBaseAPI::Version());
printf("Usage: %s unicharset-in-1 ... unicharset-in-n unicharset-out\n", return 0;
argv[0]); } else if (argc < 4) {
exit(1); // Print usage
printf("Usage: %s --version |\n"
" %s unicharset-in-1 ... unicharset-in-n unicharset-out\n",
argv[0], argv[0]);
return 1;
} }
UNICHARSET input_unicharset, result_unicharset; UNICHARSET input_unicharset, result_unicharset;

View File

@ -33,10 +33,14 @@
int main(int argc, char** argv) { int main(int argc, char** argv) {
tesseract::CheckSharedLibraryVersion(); tesseract::CheckSharedLibraryVersion();
if (!(argc == 4 || (argc == 5 && strcmp(argv[1], "-t") == 0) || if (argc > 1 && !strcmp(argv[1], "--version")) {
(argc == 6 && strcmp(argv[1], "-r") == 0))) { printf("%s\n", tesseract::TessBaseAPI::Version());
printf("Usage: %s [-t | -r [reverse policy] ] word_list_file" return 0;
" dawg_file unicharset_file\n", argv[0]); } else if (!(argc == 4 || (argc == 5 && strcmp(argv[1], "-t") == 0) ||
(argc == 6 && strcmp(argv[1], "-r") == 0))) {
printf("Usage: %s --version |\n"
" %s [-t | -r [reverse policy] ] word_list_file"
" dawg_file unicharset_file\n", argv[0], argv[0]);
return 1; return 1;
} }
tesseract::Classify *classify = new tesseract::Classify(); tesseract::Classify *classify = new tesseract::Classify();