comparison mupdf-source/thirdparty/tesseract/src/training/merge_unicharsets.cpp @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 ///////////////////////////////////////////////////////////////////////
2 // File: merge_unicharsets.cpp
3 // Description: Simple tool to merge two or more unicharsets.
4 // Author: Ray Smith
5 //
6 // (C) Copyright 2015, Google Inc.
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 ///////////////////////////////////////////////////////////////////////
18
19 #include "commontraining.h" // CheckSharedLibraryVersion
20 #include "unicharset.h"
21
22 int main(int argc, char **argv) {
23 tesseract::CheckSharedLibraryVersion();
24
25 if (argc > 1 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))) {
26 printf("%s\n", tesseract::TessBaseAPI::Version());
27 return EXIT_SUCCESS;
28 } else if (argc < 4) {
29 // Print usage
30 printf(
31 "Usage: %s -v | --version |\n"
32 " %s unicharset-in-1 ... unicharset-in-n unicharset-out\n",
33 argv[0], argv[0]);
34 return EXIT_FAILURE;
35 }
36
37 tesseract::UNICHARSET input_unicharset, result_unicharset;
38 for (int arg = 1; arg < argc - 1; ++arg) {
39 // Load the input unicharset
40 if (input_unicharset.load_from_file(argv[arg])) {
41 printf("Loaded unicharset of size %zu from file %s\n", input_unicharset.size(), argv[arg]);
42 result_unicharset.AppendOtherUnicharset(input_unicharset);
43 } else {
44 printf("Failed to load unicharset from file %s!!\n", argv[arg]);
45 return EXIT_FAILURE;
46 }
47 }
48
49 // Save the combined unicharset.
50 if (result_unicharset.save_to_file(argv[argc - 1])) {
51 printf("Wrote unicharset file %s.\n", argv[argc - 1]);
52 } else {
53 printf("Cannot save unicharset file %s.\n", argv[argc - 1]);
54 return EXIT_FAILURE;
55 }
56 return EXIT_SUCCESS;
57 }