------------------------------------ |
------------------------------------ |
## For training Neural net based LSTM Tesseract 4.00 see Training Tesseract 4.00 |
##ニューラルネットベースのLSTM Tesseract 4.00のトレーニングについては、Training Tesseract 4.00を参照してください。 |
------------------------------------- |
------------------------------------- |
## How to use the tools provided to train Tesseract 2.x for a new language? |
## Tesseract 2.xを新しい言語にトレーニングするために提供されているツールをどのように使用しますか? |
NOTE: These instructions are for an older version of Tesseract. Training instructions for more recent versions are [[here |
TrainingTesseract]]. |
注:これらの説明はTesseractの旧バージョン用です。より新しいバージョンのためのトレーニング手順は[[here |
TrainingTesseract]]です。 |
* Introduction |
* はじめに |
* Background and Limitations |
* 背景と制限 |
* Data files required |
* 必要なデータファイル |
* Training Procedure |
* トレーニング手順 |
* Generate Training Images |
* トレーニング画像の生成 |
* Make Box Files |
* ボックスファイルの作成 |
* Bootstrapping a new character set |
* 新しい文字セットのブートストラップ |
* Tif/Box pairs provided! |
* Tif / Boxペアが提供されました! |
* Run Tesseract for Training |
* トレーニングのためにTesseractを実行する |
* Clustering |
* クラスタリング |
* Compute the Character Set |
* 文字セットを計算する |
* Dictionary Data |
* 辞書データ |
* The last file |
* 最後のファイル |
* Putting it all together |
* 全部まとめて |
# Introduction |
# 前書き |
Tesseract 2.0 is fully trainable. This page describes the training process, provides some guidelines on applicability to various languages, and what to expect from the results. |
Tesseract 2.0は完全にトレーニング可能です。このページでは、トレーニングプロセスについて説明し、さまざまな言語への適用性に関するガイドライン、および結果から何を期待するかについて説明します。 |
# Background and Limitations |
#背景と制限 |
Tesseract was originally designed to recognize English text only. Efforts have been made to modify the engine and its training system to make them able to deal with other languages and UTF-8 characters. Tesseract 2.0 can handle any Unicode characters (coded with UTF-8), but there are limits as to the range of languages that it will be successful with, so please take this section into account before building up your hopes that it will work well on your particular language! |
Tesseractはもともと英語のテキストだけを認識するように設計されました。エンジンとそのトレーニングシステムを変更して、他の言語とUTF-8文字を処理できるようにする努力がなされています。 Tesseract 2.0は(UTF-8でコード化された)どんなUnicode文字も扱うことができますが、それがうまくいく言語の範囲に関して制限があるので、それがうまくいくことを期待する前にこのセクションを考慮に入れてくださいあなたの特定の言語! |
Tesseract can only handle left-to-right languages. While you can get something out with a right-to-left language, the output file will be ordered as if the text were left-to-right. Top-to-bottom languages will currently be hopeless. |
Tesseractは左から右への言語しか扱えません。右から左に書く言語で何かを出すことができますが、出力ファイルはあたかもテキストが左から右に書かれているかのように並べられます。上から下への言語は現在絶望的になるでしょう。 |
Tesseract is unlikely to be able to handle connected scripts like Arabic. It will take some specialized algorithms to handle this case, and right now it doesn't have them. |
Tesseractはアラビア語のような接続されたスクリプトを扱うことができそうにないです。このケースを処理するには、いくつかの特殊なアルゴリズムが必要ですが、今はそれがありません。 |
Tesseract is likely to be so slow with large character set languages (like Chinese) that it is probably not going to be useful. There also still need to be some code changes to accommodate languages with more than 256 characters. |
Tesseractは(中国語のような)大きな文字セット言語ではとても遅いのでおそらく役に立たないでしょう。 256文字を超える言語に対応するために、いくつかコードを変更する必要があります。 |
Any language that has different punctuation and numbers is going to be disadvantaged by some of the hard-coded algorithms that assume ASCII punctuation and digits. |
異なる句読点と数字を持つ言語は、ASCII句読点と数字を想定したハードコードされたアルゴリズムによって不利になるでしょう。 |
# Data files required |
#必要なデータファイル |
To train for another language, you have to create 8 data files in the tessdata subdirectory. The naming convention is languagecode.file_name Language codes follow the ISO 639-3 standard. The 8 files used for English are: |
他の言語を訓練するには、 tessdata サブディレクトリに8つのデータファイルを作成しなければなりません。命名規則は languagecode.file_name です。言語コードはISO 639-3規格に従います。英語に使用される8つのファイルは次のとおりです。 |
* tessdata/eng.freq-dawg |
* tessdata / eng.freq-dawg |
* tessdata/eng.word-dawg |
* tessdata / eng.word-dawg |
* tessdata/eng.user-words |
* tessdata / eng.user-words |
* tessdata/eng.inttemp |
* tessdata / eng.inttemp |
* tessdata/eng.normproto |
* tessdata / eng.normproto |
* tessdata/eng.pffmtable |
* tessdata / eng.pffmtable |
* tessdata/eng.unicharset |
* tessdata / eng.unicharset |
* tessdata/eng.DangAmbigs |
* tessdata / eng.DangAmbigs |
How little can you get away with? |
あなたはどのくらい逃げることができますか? |
You must create inttemp, normproto, pffmtable, freq-dawg, word-dawg and unicharset using the procedure described below. If you are only trying to recognize a limited range of fonts (like a single font for instance), then a single training page might be enough. DangAmbigs and user-words may be empty files. The dictionary files freq-dawg and word-dawg don't have to be given many words if you don't have a wordlist to hand, but accuracy will be lower than if you have a decent sized (10s of thousands for English say) dictionary, but for 2.04 and below at least, empty dawg files and dawgs with no words are NOT allowed. |
下記の手順で、inttemp、normproto、pffmtable、freq-dawg、word-dawg、unicharsetを作成する必要があります。限られた範囲のフォント(たとえば単一のフォントなど)のみを認識しようとしている場合は、単一のトレーニングページで十分かもしれません。 DangAmbigsとユーザーワードは空のファイルかもしれません。辞書ファイルfreq-dawgとword-dawgはあなたが手元に単語リストを持っていなければ多くの単語を指定する必要はありませんが、あなたがまともなサイズを持っている場合より正確さは低くなります辞書、しかし少なくとも2.04以下では、空のdawgファイルと単語のないdawgsは許されません。 |
# Training Procedure |
#トレーニング手順 |
Some of the procedure is inevitably manual. As much automated help as possible is provided. More automated tools may appear in the future. The tools referenced below are all built in the training subdirectory. |
手順のいくつかは必然的に手動です。できるだけ多くの自動ヘルプが提供されています。より自動化されたツールが将来登場する可能性があります。下記のツールはすべてtrainingサブディレクトリに構築されています。 |
## Generate Training Images |
##トレーニング画像を生成する |
The first step is to determine the full character set to be used, and prepare a text or word processor file containing a set of examples. The most important points to bear in mind when creating a training file are: |
最初のステップは、使用する全文字セットを決定し、一連の例を含むテキストまたはワードプロセッサファイルを準備することです。トレーニングファイルを作成する際に留意する必要がある最も重要な点は次のとおりです。 |
* Make sure there are a minimum number of samples of each character. 10 is good, but 5 is OK for rare characters. |
*各文字のサンプル数が最小であることを確認してください。 10が良いですが、5はまれな文字のためにOKです。 |
* There should be more samples of the more frequent characters - at least 20. |
*より頻繁な文字のサンプルがもっとあるはずです - 少なくとも20。 |
Don't make the mistake of grouping all the non-letters together. Make the text more realistic. For example, The quick brown fox jumps over the lazy dog. 0123456789 !@#$%^&(),..md{}/? is terrible. Much better is The (quick) brown {fox} jumps! over the $3,456.78 `` #90 dog & duck/goose, as 12.5% of E-mail from aspammer@website.com is spam? This gives the textline finding code a much better chance of getting sensible baseline metrics for the special characters. | すべての非文字を一緒にグループ化するのを間違えないでください。テキストをよりリアルにします。例えば、速い茶色のキツネは怠惰な犬を飛び越えます。 0123456789!@#$%^&()、。。md{} /?はひどいです。もっといいのは、(クイック)brown{fox}がジャンプすることです! aspammer@website.comからの電子メールの12.5%がスパムであるため、$ 3,456.78 ``#90の犬&アヒル/ガチョウより上です。これにより、テキスト検索のコードが適切なベースラインメトリックを取得できる可能性が高くなります。特殊文字 |
* It is ABSOLUTELY VITAL to space out the text a bit when printing, so up the inter-character and inter-line spacing in your word processor. Not spacing text out sufficiently will cause "FAILURE! box overlaps no blobs or blobs in multiple rows" errors during tr file generation, which leads to FATALITY - 0 labeled samples of "x", which leads to "Error: X classes in inttemp while unicharset contains Y unichars" and you can't use your nice new data files. |
*印刷時にテキストを少しずらすのは絶対に必然ですので、ワープロの文字間隔と行間をあけてください。テキストの間隔を十分に空けないと、trファイルの生成時に "FAILURE!boxが複数行のblobやblobと重ならない"エラーが発生し、FATALITY - 0のラベル付きサンプル "x"が表示されます。 unicharsetはYのunicharsを含んでいます "そしてあなたはあなたの素晴らしい新しいデータファイルを使うことができません。 |
* The training data currently needs to fit in a single tiff image, but it may be multi-page tiff (if you have libtiff installed). |
*トレーニングデータは現在単一のTIFF画像に収まる必要がありますが、マルチページTIFFの場合もあります(libtiffがインストールされている場合)。 |
* There is no need to train with multiple sizes. 10 point will do. (An exception to this is very small text. If you want to recognize text with an x-height smaller than about 15 pixels, you should either train it specifically or scale your images before trying to recognize them.) |
*複数のサイズで訓練する必要はありません。 10点になります。 (これに対する例外は非常に小さいテキストです。もしあなたが約15ピクセルより小さいx高さを持つテキストを認識したいのなら、それらを認識することを試みる前にあなたはそれを特別に訓練するかあなたのイメージを拡大縮小するべきです |
* DO NOT MIX FONTS ON A PAGE (In a single .tr file to be precise.) This will cause features to be dropped at clustering, which leads to recognition errors. |
* ページにフォントを混ぜない(正確に言うと単一の.trファイル内)。これにより、クラスタリング時にフィーチャが削除され、認識エラーが発生します。 |
* The example boxtiff files on the downloads page will help if you are not sure how to format your training data. |
*ダウンロードページのboxtiffファイルの例は、トレーニングデータのフォーマット方法がわからない場合に役立ちます。 |
Next print and scan (or use some electronic rendering method) to create an image of your training page. Up to 32 training images can be used. It is best to create pages in a mix of fonts and styles, including italic and bold. |
次に印刷してスキャンし(または何らかの電子レンダリング方法を使用して)、トレーニングページの画像を作成します。最大32個のトレーニング画像を使用できます。斜体や太字など、フォントとスタイルを組み合わせてページを作成することをお勧めします。 |
NOTE: training from real images is actually quite hard, due to the spacing-out requirements. This will be improved in a future release. For now it is much easier if you can print/scan your own training text. |
注:実際の画像からのトレーニングは、間隔を空ける必要があるため、実際にはかなり困難です。これは将来のリリースで改善されるでしょう。今のところ、あなた自身のトレーニングテキストを印刷/スキャンすることができればはるかに簡単です。 |
You will also need to save your training image as a UTF-8 text file for use in the next step where you have to insert the codes into another file. |
次のステップでコードを別のファイルに挿入する必要がある場合は、トレーニング画像をUTF-8テキストファイルとして保存する必要もあります。 |
Clarification for large amounts of training data |
大量のトレーニングデータの説明 |
The 32 images limit is for the number of FONTS. Each font may be put in a single multi-page tiff (only if you are using libtiff!) and the box file can be modified to specify the page number for each character after the coordinates. Thus an arbitrarily large amount of training data may be created for any given font, allowing training for large character-set languages. An alternative to multi-page tiffs is to create many single-page tiffs for a single font, and then you must cat together the tr files for each font into several single-font tr files. In any case, the input tr files to mftraining must each contain a single font, and the order files are given to mftraining must match the order they are given to unicharset_extractor. |
32画像の制限はフォントの数の制限です。各フォントは単一の複数ページのTIFFに入れることができます(libtiffを使用している場合のみ)ボックスファイルは座標の後の各文字のページ番号。したがって、任意のフォントに対して任意の量のトレーニングデータを作成でき、大きな文字セット言語のトレーニングが可能になります。複数ページのTIFFに代わる方法は、単一のフォントに対して複数の単一ページのTIFFを作成することです。その後、各フォントのtrファイルをいくつかの単一フォントのtrファイルにまとめる必要があります。いずれにせよ、mftrainingへの入力trファイルはそれぞれ単一のフォントを含まなければならず、mftrainingに与えられる順番はunicharset \ _extractorに与えられる順番と一致しなければなりません。 |
## Make Box Files |
##ボックスファイルを作る |
For the next step below, Tesseract needs a 'box' file to go with each training image. The box file is a text file that lists the characters in the training image, in order, one per line, with the coordinates of the bounding box around the image. Tesseract 2.0 has a mode in which it will output a text file of the required format, but if the character set is different to its current training, it will naturally have the text incorrect. So the key process here is to manually edit the file to put the correct characters in it. |
以下の次のステップでは、Tesseractは各トレーニング画像を処理するための「ボックス」ファイルを必要とします。ボックスファイルは、トレーニング画像内の文字を1行に1つずつ順番に、画像の周囲の境界ボックスの座標とともにリストしたテキストファイルです。 Tesseract 2.0には、必要な形式のテキストファイルを出力するモードがありますが、文字セットが現在のトレーニングと異なる場合、当然テキストが正しくありません。そのため、ここで重要なプロセスは、ファイルを手動で編集して正しい文字を入れることです。 |
Run Tesseract on each of your training images using this command line: |
このコマンドラインを使用して、各トレーニング画像に対してTesseractを実行します。 |
` | ` |
tesseract fontfile.tif fontfile batch.nochop makebox |
tesseract fontfile.tifフォントファイルbatch.nochop makebox |
` | ` |
You then have to rename fontfile.txt to fontfile.box . |
それから fontfile.txt をfontfile.box にリネームする必要があります。 |
Now the hard part. You have to edit the file fontfile.box and put the UTF-8 codes for each character in the file at the start of each line, in place of the incorrect character put there by Tesseract. Example: The distribution includes an image eurotext.tif. Running the above command produces a text file that includes the following lines (lines 142-155): |
今難しい部分です。ファイルfontfile.boxを編集して、ファイル内の各文字のUTF-8コードを各行の先頭に追加します。代わりに、Tesseractによって誤った文字が表示されます。例:配布には画像eurotext.tifが含まれています。上記のコマンドを実行すると、次の行(142〜155行目)を含むテキストファイルが生成されます。 |
` | ` |
s 734 491 751 516 |
s 734 491 751 516 |
p 753 483 776 515 |
p 753 483 776 515 |
r 779 492 796 516 |
r 779 492 796 516 |
i 799 492 810 525 |
私799 492 810 525 |
n 814 492 837 516 |
n 814 492 837 516 |
g 839 483 862 516 |
g 839 483 862 516 |
t 865 491 878 520 |
t 865 491 878 520 |
u 101 452 122 483 |
u 101 452 122 483 |
b 126 453 146 486 |
b 126 453 146 486 |
e 149 452 168 477 |
e 149 452 168 477 |
r 172 453 187 476 |
r 172 453 187 476 |
d 211 450 232 483 |
d 211 450 232 483 |
e 236 450 255 474 |
e 236 450 255 474 |
n 259 451 281 474 |
n 259 451 281 474 |
` | ` |
Since Tesseract was run in English mode, it does not correctly recognize the umlaut. This character needs to be corrected using a suitable editor. An editor that understands UTF-8 should be used for this purpose. HTML editors are usually a good choice. (Mozilla on Linux allows you to edit UTF-8 text files directly from the browser. Firefox and IE do not let you do this. MS Word is very good at handling different text encodings, and Notepad++ is another editor that understands UTF-8.) Linux and Windows both have a character map that can be used for copying characters that cannot be typed. In this case the u needs to be changed to ü. |
Tesseractは英語モードで実行されたので、ウムラウトを正しく認識しません。この文字は適切なエディタを使用して修正する必要があります。この目的のためには、UTF-8を理解しているエディターを使用する必要があります。 HTMLエディタは通常良い選択です。 (Linux上のMozillaでは、ブラウザから直接UTF-8テキストファイルを編集できます。FirefoxとIEではこれを実行できません。MSWordはさまざまなテキストエンコーディングの処理に非常に優れており、Notepad ++はUTF-8を理解する別のエディタです。 )LinuxとWindowsはどちらも、入力できない文字をコピーするために使用できる文字マップを持っています。この場合、uをüに変更する必要があります。 |
In theory, each line in the box file should represent one of the characters from your training file, but if you have a horizontally broken character, such as the lower double quote „ it will probably have 2 boxes that need to be merged! |
理論的には、ボックスファイルの各行はトレーニングファイルの文字の1つを表すはずですが、下の二重引用符のように横に途切れた文字がある場合は、おそらく結合する必要がある2つのボックスがあります。 |
Example: lines 117-130: |
例:117〜130行目: |
` | ` |
D 101 503 131 534 |
D 101 503 131 534 |
e 135 501 154 527 |
e 135 501 154 527 |
r 158 503 173 526 |
r 158 503 173 526 |
, 197 496 205 507 |
、197 496 205 507 |
, 206 496 214 508 |
、206 496 214 508 |
s 220 499 236 524 |
s 220 499 236 524 |
c 239 499 258 523 |
c 239 499 258 523 |
h 262 500 284 532 |
h 262 500 284 532 |
n 288 500 310 524 |
n 288 500 310 524 |
e 313 499 332 523 |
e 313 499 332 523 |
l 336 500 347 533 |
l 336 500 347 533 |
l 352 500 363 532 |
l 352 500 363 532 |
e 367 499 386 524 |
e 367 499 386 524 |
" 389 520 407 532 |
"389 520 407 532 |
` | ` |
As you can see, the low double quote character has been expressed as two single commas. The bounding boxes must be merged as follows: |
ご覧のように、低い二重引用符は2つのシングルコンマとして表現されています。境界ボックスは次のようにマージする必要があります。 |
* First number (left) take the minimum of the two lines (197) |
*最初の数字(左)は2行のうち最小のものをとります(197) |
* Second number (bottom) take the minimum of the two lines (496) |
* 2番目の数字(下)は2行のうち最小の値をとる(496) |
* Third number (right) take the maximum of the two lines (214) |
* 3番目の数字(右)は2行のうち最大のものをとる(214) |
* Fourth number (top) take the maximum of the two lines (508) |
* 4番目の数字(上)は最大2行(508)を取ります |
This gives: |
これは与える: |
` | ` |
D 101 503 131 534 |
D 101 503 131 534 |
e 135 501 154 527 |
e 135 501 154 527 |
r 158 503 173 526 |
r 158 503 173 526 |
„ 197 496 214 508 |
197 496 214 508 |
s 220 499 236 524 |
s 220 499 236 524 |
c 239 499 258 523 |
c 239 499 258 523 |
h 262 500 284 532 |
h 262 500 284 532 |
n 288 500 310 524 |
n 288 500 310 524 |
e 313 499 332 523 |
e 313 499 332 523 |
l 336 500 347 533 |
l 336 500 347 533 |
l 352 500 363 532 |
l 352 500 363 532 |
e 367 499 386 524 |
e 367 499 386 524 |
" 389 520 407 532 |
"389 520 407 532 |
` | ` |
If you didn't successfully space out the characters on the training image, some may have been joined into a single box. In this case, you can either remake the images with better spacing and start again, or if the pair is common, put both characters at the start of the line, leaving the bounding box to represent them both. (As of 2.04, there is a limit of 24 bytes for the description of a "character". This will allow you between 6 and 24 unicodes to describe the character, depending on where your codes sit in the unicode set. If anyone hits this limit, please file an issue describing your situation.) |
トレーニング画像上の文字の間隔をうまく調整できなかった場合は、いくつかが1つのボックスに結合されている可能性があります。この場合は、間隔を空けてイメージを作り直してやり直すか、ペアが一般的な場合は、両方の文字を表すために境界ボックスを残して両方の文字を行頭に配置します。 (2.04以降、 "文字"の記述には24バイトの制限があります。これにより、コードがUnicodeセット内のどこにあるかに応じて、6から24のUnicodeで文字を記述できます。制限してください、あなたの状況を説明する問題を提出してください。) |
Note that the coordinate system used in the box file has (0,0) at the bottom-left. |
Note ボックスファイルで使用されている座標系の左下に(0,0)があることに注意してください。 |
If you have an editor that understands UTF-8, this process will be a lot easier than if it doesn't, as each UTF-8 character has up to 4 bytes to code it, and dumb editors will show you all the bytes separately. |
あなたがUTF-8を理解するエディタを持っているなら、それぞれのUTF-8文字がそれをコード化するために最大4バイトを持っているので、このプロセスはそれがしないよりはるかに簡単になります。 。 |
There are several visual tools for editing box file - please check AddOns wiki. |
ボックスファイルを編集するための視覚的なツールがいくつかあります - AddOns wikiを確認してください。 |
### Bootstrapping a new character set |
###新しい文字セットをブートストラップする |
If you are trying to train a new character set, it is a good idea to put in the effort on a single font to get one good box file, run the rest of the training process, and then use Tesseract in your new language to make the rest of the box files as follows: |
もしあなたが新しい文字セットを訓練しようとしているのなら、一つのフォントに努力して一つの良いボックスファイルを作り、残りのトレーニングプロセスを実行し、そしてあなたの新しい言語でTesseractを使うのが良い考えです。その他のボックスファイルは次のとおりです。 |
` | ` |
tesseract fontfile.tif fontfile -l yournewlanguage batch.nochop makebox |
tesseract fontfile.tifフォントファイル-l yournewlanguage batch.nochop makebox |
` | ` |
This should make the 2nd box file easier to make, as there is a good chance that Tesseract will recognize most of the text correctly. You can always iterate this sequence adding more fonts to he training set (i.e. to the command line of mfTraining and cnTraining below) as you make them, but note that there is no incremental training mode that allows you to add new training data to existing sets. This means that each time you run mfTraining and cnTraining you are making new data files from scratch from the tr files you give on the command line, and these programs cannot take an existing intproto/pffmtable/normproto and add to them directly. |
Tesseractがほとんどのテキストを正しく認識する可能性が高いので、これは2番目のボックスファイルを作りやすくします。このシーケンスを繰り返して、作成するときにトレーニングセットにフォントを追加することができます(つまり、以下のmfTrainingおよびcnTrainingのコマンドラインに追加できます)が、既存のセットに新しいトレーニングデータを追加できるインクリメンタルトレーニングモードはありません。 。つまり、mfTrainingとcnTrainingを実行するたびに、コマンドラインで指定したtrファイルから最初から新しいデータファイルを作成し、これらのプログラムで既存のintproto / pffmtable / normprotoを取得して直接追加することはできません。 |
### Tif/Box pairs provided! |
### Tif / Boxペアが提供されました! |
The Tif/Box file pairs are on the downloads page. (Note the tiff files are G4 compressed |
Tif / Boxファイルのペアはダウンロードページにあります。 (tiffファイルはG4圧縮されています。 |
to save space, so you will have to have libtiff or uncompress them first). You could |
スペースを節約するためには、libtiffを用意するか、最初にそれらを解凍する必要があります。あなたは出来る |
follow the following process to make better training data for your own language or |
あなた自身の言語のためのより良いトレーニングデータを作るために次のプロセスに従ってください。 |
subset of an existing language, or add different characters/shapes to an existing language: |
既存の言語のサブセット、または既存の言語に異なる文字/図形を追加します。 |
1. Filter the box files, keeping lines for only the characters you want. |
1.ボックスファイルをフィルタして、必要な文字だけを表示するようにします。 |
1. Run tesseract for training (below). |
1.トレーニングのためにtesseractを実行します(下記)。 |
1. Cat the .tr files from multiple languages for each font to get the character set that you want and add the .tr files from your own fonts or characters. |
1.フォントごとに複数の言語の.trファイルを集めて、必要な文字セットを取得し、独自のフォントまたは文字から.trファイルを追加します。 |
1. Cat the filtered box files in an identical way to the .tr files for handing off to unicharset_extractor. |
1. unicharset \ _extractorに引き渡すために、.trファイルと同じ方法でフィルタ処理されたボックスファイルをキャットします。 |
1. Run the rest of the training process. |
1.残りのトレーニングプロセスを実行します。 |
Caution! This is not quite as simple as it sounds! cntraining and mftraining can only |
あぶない!これはそれほど簡単ではありません。 cntrainingとmftrainingは |
take up to 32 .tr files, so you must cat all the files from multiple languages for the |
最大32個の.trファイルを使用できます。そのためには、複数の言語のすべてのファイルを |
same font together to make 32 language-combined, but font-individual files. |
同じフォントを一緒に使用して32の言語を組み合わせたファイルを作成しますが、フォントはファイルごとに異なります。 |
The characters found in the tr files must match the sequence |
trファイルにある文字は、シーケンスと一致している必要があります。 |
of characters found in the box files when given to unicharset_extractor, so you have to |
unicharset \ _extractorに渡されたときにボックスファイルで見つかった文字の数 |
cat the box files together in the same order as the tr files. |
trファイルと同じ順序でボックスファイルをまとめてください。 |
The command lines for cn/mftraining and unicharset_extractor must be given the .tr |
cn / mftrainingおよびunicharset \ _extractorのコマンドラインには、.trを指定する必要があります。 |
and .box files (respectively) in the same order just in case you have different |
異なる場合に備えて、ファイルと.boxファイル(それぞれ)は同じ順序で |
filterings for the different fonts. |
さまざまなフォントのフィルタリング。 |
There may be a program available to do all this and pick out the characters in |
これらすべてを行い、文字を抽出するために利用可能なプログラムがあるかもしれません。 |
the style of character map. This might make the whole thing easier. |
文字マップのスタイルこれは全体を簡単にするかもしれません。 |
## Run Tesseract for Training |
##トレーニングのためにTesseractを実行する |
For each of your training image, boxfile pairs, run Tesseract in training mode: |
トレーニング画像、ボックスファイルのペアごとに、Tesseractをトレーニングモードで実行します。 |
` | ` |
tesseract fontfile.tif junk nobatch box.train |
tesseract fontfile.tifがらくたノバッチbox.train |
` | ` |
OR |
または |
` | ` |
tesseract fontfile.tif junk nobatch box.train.stderr |
tesseract fontfile.tifがらくたnobatch box.train.stderr |
` | ` |
The first form sends all the errors to tesseract.log (on all platforms) like it did on windows versions 2.03 and below. With box.train.stderr, all errors are sent to stderr, on all platforms, just like it did on non-windows platforms for versions 2.03 and below. |
最初の形式は、Windowsバージョン2.03以下の場合と同様に、すべてのエラーを(すべてのプラットフォームの)tesseract.logに送信します。 box.train.stderrを使用すると、バージョン2.03以下のWindows以外のプラットフォームの場合と同様に、すべてのプラットフォームで、すべてのエラーがstderrに送信されます。 |
Note that the box filename must match the tif filename, including the path, or Tesseract won't find it. The output of this step is fontfile.tr which contains the features of each character of the training page. Note also that the output name is derived from the input image name, not the normal output name, shown here as junk . junk.txt will also be written with a single newline and no text. |
ボックスfilenameはパスを含むtifファイル名と一致しなければならないことに注意してください。そうしないとTesseractはそれを見つけられません。このステップの出力は fontfile.tr です。これはトレーニングページの各文字の機能を含みます。出力名は通常の出力名ではなく、入力イメージ名から派生していることにも注意してください。ここでは junk と表示しています。 junk.txtも1行の改行で書かれ、テキストは含まれません。 |
Important Check for errors in the output from apply_box. If there are FATALITIES reported, then there is no point continuing with the training process until you fix the box file. The new box.train.stderr config file makes is easier to choose the location of the output. A FATALITY usually indicates that this step failed to find any training samples of one of the characters listed in your box file. Either the coordinates are wrong, or there is something wrong with the image of the character concerned. If there is no workable sample of a character, it can't be recognized, and the generated inttemp file won't match the unicharset file later and Tesseract will abort. |
重要 apply \ _boxからの出力にエラーがないか確認してください。死亡が報告されている場合は、ボックスファイルを修正するまでトレーニングプロセスを続行しても意味がありません。新しいbox.train.stderr設定ファイルにより、出力の場所を選択しやすくなりました。 FATALITYは通常、このステップであなたのボックスファイルにリストされているキャラクターの1つのトレーニングサンプルを見つけることができなかったことを示します。座標が間違っているか、関係するキャラクターのイメージに問題があります。実行可能な文字のサンプルがない場合、それは認識されず、生成されたinttempファイルは後でunicharsetファイルと一致せず、Tesseractは中止されます。 |
Another error that can occur that is also fatal and needs attention is an error about "Box file format error on line n". If preceded by "Bad utf-8 char..." then the UTF-8 codes are incorrect and need to be fixed. The error "utf-8 string too long..." indicates that you have exceeded the 8 (v2.01) byte limit on a character description. If you need a description longer than 8 bytes, please file an issue. Box file format errors without either of the above errors indicate either something wrong with the bounding box integers, or possibly a blank line in the box file. Blank lines are actually harmless, and the error can be ignored in this case. They could be ignored by the code, but it doesn't ignore them in case there is something unintentional wrong with the box file. |
発生する可能性があるもう1つのエラーこれも致命的で注意が必要ですは "行nのボックスファイル形式エラー"に関するエラーです。 "Bad utf-8 char ..."が前に付いている場合、UTF-8コードは正しくないため修正する必要があります。エラー "utf-8 string too long ..."は、文字の説明で8(v2.01)バイトの制限を超えたことを示します。 8バイトを超える説明が必要な場合は、問題を報告してください。上記のどちらのエラーも発生していないボックスファイル形式エラーは、境界ボックスの整数に問題があるか、ボックスファイル内の空白行である可能性があります。空白行は実際には無害です。この場合、エラーは無視できます。これらはコードによって無視される可能性がありますが、ボックスファイルに意図しない問題がある場合でも無視されません。 |
There is no need to edit the content of the fontfile.tr file. The font name inside it need not be set. For the curious, here is some information on the format: |
fontfile.trファイルの内容を編集する必要はありません。その中のフォント名を設定する必要はありません。好奇心旺盛な人のために、フォーマットに関する情報をいくつか示します。 |
` | ` |
Every character in the box file has a corresponding set of entries in |
ボックスファイル内のすべての文字には、対応する一連のエントリがあります。 |
the .tr file (in order) like this |
.trファイル(この順) |
UnknownFont 2 |
UnknownFont 2 |
mf |
mf |
x y length dir 0 0 |
x yの長さdir 0 0 |
... (there are a set of these determined by |
...(によって決定されるこれらのセットがあります) |
above) |
上記) |
cn 1 |
CN 1 |
ypos length x2ndmoment y2ndmoment |
yposの長さx 2ndmoment y 2ndmoment |
The mf features are polygon segments of the outline normalized to the |
mfフィーチャは、に正規化されたアウトラインのポリゴンセグメントです。 |
1st and 2nd moments. |
第一と第二の瞬間。 |
x= x position [-0.5.0.5] |
x = x位置[-0.5.0.5] |
y = y position [-0.25, 0.75] |
y = y位置[-0.25、0.75] |
length is the length of the polygon segment [0,1.0] |
lengthはポリゴンセグメントの長さです[0,1.0] |
dir is the direction of the segment [0,1.0] |
dirはセグメントの方向です[0,1.0] |
The cn feature is to correct for the moment normalization to |
cn機能は、次の正規化の瞬間を修正することです。 |
distinguish position and size (eg c vs C and , vs ') |
位置とサイズを区別する(例:cとC、そしてvs ') |
` | ` |
## Clustering |
##クラスタリング |
When the character features of all the training pages have been extracted, we need to cluster them to create the prototypes. The character shape features can be clustered using the mftraining and cntraining programs: |
すべてのトレーニングページの特徴を抽出したら、それらをクラスタ化してプロトタイプを作成する必要があります。文字の形の特徴は mftraining とcntraining プログラムを使ってクラスタ化することができます。 |
` | ` |
mftraining fontfile_1.tr fontfile_2.tr ... |
mftraining fontfile_1.tr fontfile_2.tr ... |
` | ` |
This will output two data files: inttemp (the shape prototypes) and pffmtable (the number of expected features for each character). (A third file called Microfeat is also written by this program, but it is not used.) |
これは2つのデータファイルを出力します: inttemp (形状プロトタイプ)とpffmtable (各文字に期待される機能の数)。 ( Microfeat という3番目のファイルもこのプログラムによって書かれていますが、使用されていません。) |
` | ` |
cntraining fontfile_1.tr fontfile_2.tr ... |
cntraining fontfile_1.tr fontfile_2.tr ... |
` | ` |
This will output the normproto data file (the character normalization sensitivity prototypes). |
これは normproto データファイル(文字正規化感度プロトタイプ)を出力します。 |
## Compute the Character Set |
##文字セットを計算する |
Tesseract needs to know the set of possible characters it can output. To generate the unicharset data file, use the unicharset_extractor program on the same training pages bounding box files as used for clustering: |
Tesseractは出力可能な文字のセットを知っている必要があります。 unicharset データファイルを生成するには、クラスタリングに使われるのと同じトレーニングページのバウンディングボックスファイルでunicharset_extractor プログラムを使います: |
` | ` |
unicharset_extractor fontfile_1.box fontfile_2.box ... |
unicharset_extractor fontfile_1.box fontfile_2.box ... |
` | ` |
Tesseract needs to have access to character properties isalpha, isdigit, isupper, islower. This data must be encoded in the unicharset data file. Each line of this file corresponds to one character. The character in UTF-8 is followed by a hexadecimal number representing a binary mask that encodes the properties. Each bit corresponds to a property. If the bit is set to 1, it means that the property is true. The bit ordering is (from least significant bit to most significant bit): isalpha, islower, isupper, isdigit. |
Tesseractは、文字プロパティisalpha、isdigit、isupper、islowerにアクセスできる必要があります。このデータは unicharset データファイルにエンコードされなければなりません。このファイルの各行は1文字に対応しています。 UTF-8の文字の後には、プロパティーをエンコードする2進マスクを表す16進数が続きます。各ビットはプロパティに対応します。ビットが1に設定されている場合は、そのプロパティがtrueであることを意味します。ビット順序は、(最下位ビットから最上位ビットへ)isalpha、islower、isupper、isdigitです。 |
Example: |
例: |
* ';' is not an alphabetic character, a lower case character, an upper case character nor a digit. Its properties are thus represented by the binary number 0000 (0 in hexadecimal). |
* ';'英字、小文字、大文字、数字ではありません。そのプロパティは、2進数0000(16進数で0)で表されます。 |
* 'b' is an alphabetic character and a lower case character. Its properties are thus represented by the binary number 0011 (3 in hexadecimal). |
* 'b'は英字と小文字です。したがって、その特性は2進数0011(16進数で3)で表されます。 |
* 'W' is an alphabetic character and an upper case character. Its properties are thus represented by the binary number 0101 (5 in hexadecimal). |
* 'W'は英字と大文字です。したがって、その特性は2進数0101(16進数で5)で表されます。 |
* '7' is just a digit. Its properties are thus represented by the binary number 1000 (8 in hexadecimal). |
* '7'は単なる数字です。その特性は、2進数1000(16進数で8)で表されます。 |
` | ` |
; 0 |
; 0 |
b 3 |
b 3 |
W 5 |
W 5 |
7 8 |
7 8 |
` | ` |
If your system supports the wctype functions, these values will be set automatically by unicharset_extractor and there is no need to edit the unicharset file. On some older systems (eg Windows 95), the unicharset file must be edited by hand to add these property description codes. |
システムがwctype関数をサポートしている場合、これらの値はunicharset \ _extractor によって自動的に設定され、unicharsetファイルを編集する必要はありません。一部の古いシステム(Windows 95など)では、unicharsetファイルは次のように編集します。これらの特性記述コードを追加する手。 |
NOTE The unicharset file must be regenerated whenever inttemp, normproto and pffmtable are generated (i.e. they must all be recreated when the box file is changed) as they have to be in sync. The lines in unicharset must be in the correct order, as inttemp stores an index into unicharset and the actual characters returned by the classifier come from unicharset at the given index. |
NOTE inttemp、normproto、およびpffmtableが生成されるたびにユニキャストファイルを再生成する必要があります(つまり、ボックスファイルが変更されたときにすべて再作成する必要があります)。 inttempはインデックスをunicharsetに格納し、分類子によって返される実際の文字は指定されたインデックスのunicharsetから来るため、unicharset内の行は正しい順序である必要があります。 |
## Dictionary Data |
##辞書データ |
Tesseract uses 3 dictionary files for each language. Two of the files are coded as a Directed Acyclic Word Graph (DAWG), and the other is a plain UTF-8 text file. To make the DAWG dictionary files, you first need a wordlist for your language. The wordlist is formatted as a UTF-8 text file with one word per line. Split the wordlist into two sets: the frequent words, and the rest of the words, and then use wordlist2dawg to make the DAWG files: |
Tesseractは各言語ごとに3つの辞書ファイルを使用します。 2つのファイルは有向非循環ワードグラフ(DAWG)としてコード化されており、もう1つはプレーンなUTF-8テキストファイルです。 DAWG辞書ファイルを作成するには、まずあなたの言語のワードリストが必要です。ワードリストは、1行に1ワードのUTF-8テキストファイルとしてフォーマットされています。単語リストを頻繁な単語と残りの単語の2つのセットに分け、DAWGファイルを作成するために wordlist2dawg を使います。 |
` | ` |
wordlist2dawg frequent_words_list freq-dawg |
wordlist2dawg frequent_words_list freq-dawg |
wordlist2dawg words_list word-dawg |
wordlist2dawg words_list単語dawg |
` | ` |
NOTE: wordlists must contain at least one word! Empty files and dictionaries with no words are not currently supported! (Surely you know at least one word to be recognized.) |
注:単語リストには少なくとも1つの単語を含める必要があります!単語のない空のファイルと辞書は現在サポートされていません**。 (きっとあなたは認識されるべき少なくとも一つの単語を知っています。) |
If words always have some punctuation in them, like google.com then it is a good idea to include them in the dictionary. |
google.comのように、単語に常に句読点が含まれている場合は、辞書に含めることをお勧めします。 |
The third dictionary file is called user-words and is usually empty. |
3番目の辞書ファイルはユーザーワードと呼ばれ、通常は空です。 |
## The last file |
##最後のファイル |
The final data file that Tesseract uses is called DangAmbigs. It represents the intrinsic ambiguity between characters or sets of characters, and is currently entirely manually generated. To understand the file format, look at the following example: |
Tesseractが使用する最後のデータファイルはDangAmbigsです。これは、文字間または文字セット間の固有のあいまいさを表し、現在は完全に手動で生成されています。ファイル形式を理解するために、次の例を見てください。 |
` | ` |
1 m 2 r n |
1 m 2 r n |
3 i i i 1 m |
3 1 i 1 m |
` | ` |
The first field is the number of characters in the second field. The 3rd field is the number of characters in the 4th field. As with the other files, this is a UTF-8 format file, and therefore each character may be represented by multiple bytes. The first line shows that the pair 'rn' may sometimes be recognized incorrectly as 'm'. The second line shows that the character 'm' may sometimes be recognized incorrectly as the sequence 'iii' |
最初のフィールドは2番目のフィールドの文字数です。 3番目のフィールドは、4番目のフィールドの文字数です。他のファイルと同様に、これはUTF-8形式のファイルであるため、各文字は複数バイトで表されることがあります。最初の行は、ペア 'rn'が 'm'として誤って認識されることがあることを示しています。 2行目は、文字 'm'がシーケンス 'iii'として誤って認識されることがあることを示しています。 |
Note that the characters on both sides should occur in unicharset. This file cannot be used to translate characters from one set to another. |
両側の文字は1文字セットで出現するはずです。このファイルを使用して、あるセットから別のセットに文字を変換することはできません。 |
The DangAmbigs file may also be empty. |
DangAmbigsファイルも空の可能性があります。 |
# Putting it all together |
# すべてを一緒に入れて |
That is all there is to it! All you need to do now is collect together all 8 files and rename them with a lang. prefix, where lang is the 3-letter code for your language taken from http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes and put them in your tessdata directory. Tesseract can then recognize text in your language (in theory) with the following: |
それだけです。今する必要があるのは、8つのファイルすべてを集めて、それらを lang. 接頭辞で名前変更することです。ここで、langは、http://en.wikipedia.org/wiki/List_of_ISO_639-から取られた言語の3文字のコードです。 2_codesしてそれらをtessdataディレクトリに置きます。 Tesseractはそれからあなたの言語のテキストを(理論的に)次のように認識することができます: |
` | ` |
tesseract image.tif output -l lang |
tesseract image.tif出力-l lang |
` | ` |
(Actually, you can use any string you like for the language code, but if you want anybody else to be able to use it easily, ISO 639 is the way to go.) |
(実際には、言語コードに好きな文字列を使用できますが、他の人が簡単に使用できるようにしたい場合は、ISO 639が適しています。) |