#include "ratngs.h"
#include "notdll.h"
Go to the source code of this file.
WERD_CHOICE* correct_segment_pass2 | ( | WERD * | word, | |
DENORM * | denorm, | |||
POLY_MATCHER | matcher, | |||
POLY_TESTER | tester, | |||
WERD_CHOICE *& | raw_choice, | |||
BLOB_CHOICE_LIST_CLIST * | blob_choices, | |||
WERD *& | outword | |||
) |
Segment a word correctly using the pass2 conditions of the tess segmenter.
word | bln word to do | |
denorm | de-normaliser | |
matcher | matcher function | |
tester | tester function | |
raw_choice | raw result //list of blob lists | |
blob_choices | list of blob lists | |
outword | bln word output |
Definition at line 136 of file tessbox.cpp.
References NULL, recog_word(), set_pass2(), and TRUE.
Referenced by match_word_pass2().
00144 { 00145 set_pass2(); 00146 return recog_word (word, denorm, matcher, NULL, tester, TRUE, 00147 raw_choice, blob_choices, outword); 00148 }
BOOL8 tess_acceptable_word | ( | WERD_CHOICE * | word_choice, | |
WERD_CHOICE * | raw_choice | |||
) |
Return true if the word is regarded as "good enough" (acceptable).
word_choice | after context | |
raw_choice | before context |
Definition at line 187 of file tessbox.cpp.
References AcceptableResult(), choicestruct::certainty, choicestruct::rating, and choicestruct::string.
Referenced by classify_word_pass1(), and match_word_pass2().
00190 { 00191 A_CHOICE choice; // after context 00192 A_CHOICE tess_raw; // before 00193 00194 choice.rating = word_choice->rating (); 00195 choice.certainty = word_choice->certainty (); 00196 choice.string = (char *) word_choice->string ().string (); 00197 tess_raw.rating = raw_choice->rating (); 00198 tess_raw.certainty = raw_choice->certainty (); 00199 tess_raw.string = (char *) raw_choice->string ().string (); 00200 return AcceptableResult (&choice, &tess_raw); // call tess 00201 }
BOOL8 tess_adaptable_word | ( | WERD * | word, | |
WERD_CHOICE * | word_choice, | |||
WERD_CHOICE * | raw_choice | |||
) |
Return true if the word is regarded as "good enough".
Definition at line 207 of file tessbox.cpp.
References AdaptableWord(), delete_word(), make_tess_word(), and NULL.
Referenced by classify_word_pass1().
00211 { 00212 TWERD *tessword; //converted word 00213 INT32 result; //answer 00214 00215 tessword = make_tess_word (word, NULL); 00216 result = AdaptableWord (tessword, word_choice->string ().string (), 00217 raw_choice->string ().string ()); 00218 delete_word(tessword); 00219 return result != 0; 00220 }
void tess_adapter | ( | WERD * | word, | |
DENORM * | denorm, | |||
const char * | string, | |||
const char * | raw_string, | |||
const char * | rejmap | |||
) |
Adapt to the word using the Tesseract mechanism.
word | bln word | |
denorm | de-normaliser | |
string | string for word | |
raw_string | before context | |
rejmap | reject map |
Definition at line 368 of file tessbox.cpp.
References AdaptToWord(), delete_word(), make_tess_row(), and make_tess_word().
Referenced by classify_word_pass1().
00374 { 00375 TWERD *tessword; // converted word 00376 static TEXTROW tessrow; // dummy row 00377 00378 make_tess_row(denorm, &tessrow); // make dummy row 00379 tessword = make_tess_word (word, &tessrow); // make a word 00380 AdaptToWord(tessword, &tessrow, string, raw_string, rejmap); // adapt to it 00381 delete_word(tessword); // free it 00382 }
void tess_add_doc_word | ( | WERD_CHOICE * | word_choice | ) |
Add the given word to the document dictionary, tests acceptability.
word_choice | after context |
Definition at line 391 of file tessbox.cpp.
References add_document_word(), choicestruct::certainty, choicestruct::rating, and choicestruct::string.
Referenced by classify_word_pass1().
00393 { 00394 A_CHOICE choice; // after context 00395 00396 choice.rating = word_choice->rating (); 00397 choice.certainty = word_choice->certainty (); 00398 choice.string = (char *) word_choice->string ().string (); 00399 add_document_word(&choice); 00400 }
void tess_bn_matcher | ( | PBLOB * | pblob, | |
PBLOB * | blob, | |||
PBLOB * | nblob, | |||
WERD * | word, | |||
DENORM * | denorm, | |||
BLOB_CHOICE_LIST & | ratings | |||
) |
Match a blob using the Tess Baseline Normalized (adaptive) matcher only.
pblob | previous blob | |
blob | blob to match | |
nblob | next blob | |
word | word it came from | |
denorm | de-normaliser | |
ratings | list of results |
Definition at line 267 of file tessbox.cpp.
References AdaptiveClassifier(), convert_choice_list(), FALSE, free_blob(), make_tess_blob(), make_tess_row(), NULL, tess_bn_matching, tess_cn_matching, and TRUE.
00274 { 00275 LIST result; // tess output 00276 TBLOB *tessblob; // converted blob 00277 TEXTROW tessrow; // dummy row 00278 00279 tess_bn_matching = TRUE; // turn it on 00280 tess_cn_matching = FALSE; 00281 tessblob = make_tess_blob (blob, TRUE); // convert blob 00282 make_tess_row(denorm, &tessrow); // make dummy row 00283 result = AdaptiveClassifier (tessblob, NULL, &tessrow); // classify 00284 free_blob(tessblob); 00285 convert_choice_list(result, ratings); // make our format 00286 }
void tess_cn_matcher | ( | PBLOB * | pblob, | |
PBLOB * | blob, | |||
PBLOB * | nblob, | |||
WERD * | word, | |||
DENORM * | denorm, | |||
BLOB_CHOICE_LIST & | ratings | |||
) |
Match a blob using the Tess Char Normalized (non-adaptive) matcher only.
pblob | previous blob | |
blob | blob to match | |
nblob | next blob | |
word | word it came from | |
denorm | de-normaliser | |
ratings | list of results |
Definition at line 234 of file tessbox.cpp.
References AdaptiveClassifier(), convert_choice_list(), FALSE, free_blob(), make_tess_blob(), make_tess_row(), NULL, tess_bn_matching, tess_cn_matching, and TRUE.
00241 { 00242 LIST result; // tess output 00243 TBLOB *tessblob; // converted blob 00244 TEXTROW tessrow; // dummy row 00245 00246 tess_cn_matching = TRUE; //turn it on 00247 tess_bn_matching = FALSE; 00248 tessblob = make_tess_blob (blob, TRUE); // convert blob 00249 make_tess_row(denorm, &tessrow); // make dummy row 00250 result = AdaptiveClassifier (tessblob, NULL, &tessrow); // classify 00251 free_blob(tessblob); 00252 convert_choice_list(result, ratings); // make our format 00253 }
void tess_default_matcher | ( | PBLOB * | pblob, | |
PBLOB * | blob, | |||
PBLOB * | nblob, | |||
WERD * | word, | |||
DENORM * | denorm, | |||
BLOB_CHOICE_LIST & | ratings | |||
) |
Match a blob using the default functionality of the Tess matcher.
pblob | previous blob | |
blob | blob to match | |
nblob | next blob | |
word | word it came from | |
denorm | de-normaliser | |
ratings | list of results |
Definition at line 300 of file tessbox.cpp.
References AdaptiveClassifier(), convert_choice_list(), FALSE, free_blob(), make_tess_blob(), make_tess_row(), NULL, tess_bn_matching, tess_cn_matching, and TRUE.
Referenced by apply_box_testing(), classify_word_pass1(), and match_word_pass2().
00307 { 00308 LIST result; // tess output 00309 TBLOB *tessblob; // converted blob 00310 TEXTROW tessrow; // dummy row 00311 00312 tess_bn_matching = FALSE; // turn it off 00313 tess_cn_matching = FALSE; 00314 tessblob = make_tess_blob (blob, TRUE); // convert blob 00315 make_tess_row(denorm, &tessrow); // make dummy row 00316 result = AdaptiveClassifier (tessblob, NULL, &tessrow); // classify 00317 free_blob(tessblob); 00318 convert_choice_list(result, ratings); // make our format 00319 }
WERD_CHOICE* tess_segment_pass1 | ( | WERD * | word, | |
DENORM * | denorm, | |||
POLY_MATCHER | matcher, | |||
WERD_CHOICE *& | raw_choice, | |||
BLOB_CHOICE_LIST_CLIST * | blob_choices, | |||
WERD *& | outword | |||
) |
Segment a word (i.e., 'recognize' a word) using the pass1 conditions of the tess segmenter.
word | bln word to do | |
denorm | de-normaliser | |
matcher | matcher function | |
raw_choice | raw result //list of blob lists | |
blob_choices | list of blob lists | |
outword | bln word output |
Definition at line 41 of file tessbox.cpp.
References chop_enable, enable_assoc, FALSE, WERD::flag(), NULL, permute_only_top, recog_word(), set_pass1(), W_DONT_CHOP, and W_REP_CHAR.
Referenced by apply_box_testing(), and classify_word_pass1().
00048 { 00049 WERD_CHOICE *result; // return value 00050 int saved_enable_assoc = 0; 00051 int saved_chop_enable = 0; 00052 00053 if (word->flag (W_DONT_CHOP)) { 00054 saved_enable_assoc = enable_assoc; 00055 saved_chop_enable = chop_enable; 00056 enable_assoc = 0; 00057 chop_enable = 0; 00058 if (word->flag (W_REP_CHAR)) 00059 permute_only_top = 1; 00060 } 00061 set_pass1(); 00062 // tprintf("pass1 chop on=%d, seg=%d, onlytop=%d",chop_enable,enable_assoc,permute_only_top); 00063 result = recog_word (word, denorm, matcher, NULL, NULL, FALSE, 00064 raw_choice, blob_choices, outword); 00065 if (word->flag (W_DONT_CHOP)) { 00066 enable_assoc = saved_enable_assoc; 00067 chop_enable = saved_chop_enable; 00068 permute_only_top = 0; 00069 } 00070 return result; 00071 }
WERD_CHOICE* tess_segment_pass2 | ( | WERD * | word, | |
DENORM * | denorm, | |||
POLY_MATCHER | matcher, | |||
WERD_CHOICE *& | raw_choice, | |||
BLOB_CHOICE_LIST_CLIST * | blob_choices, | |||
WERD *& | outword | |||
) |
Segment a word (i.e., 'recognize' a word) using the pass2 conditions of the tess segmenter.
word | bln word to do | |
denorm | de-normaliser | |
matcher | matcher function | |
raw_choice | raw result //list of blob lists | |
blob_choices | list of blob lists | |
outword | bln word output |
Definition at line 87 of file tessbox.cpp.
References chop_enable, enable_assoc, FALSE, WERD::flag(), NULL, permute_only_top, recog_word(), set_pass2(), W_DONT_CHOP, and W_REP_CHAR.
Referenced by match_word_pass2().
00094 { 00095 WERD_CHOICE *result; // return value 00096 int saved_enable_assoc = 0; 00097 int saved_chop_enable = 0; 00098 00099 if (word->flag (W_DONT_CHOP)) { 00100 saved_enable_assoc = enable_assoc; 00101 saved_chop_enable = chop_enable; 00102 enable_assoc = 0; 00103 chop_enable = 0; 00104 if (word->flag (W_REP_CHAR)) 00105 permute_only_top = 1; 00106 } 00107 set_pass2(); 00108 result = recog_word (word, denorm, matcher, NULL, NULL, FALSE, 00109 raw_choice, blob_choices, outword); 00110 if (word->flag (W_DONT_CHOP)) { 00111 enable_assoc = saved_enable_assoc; 00112 chop_enable = saved_chop_enable; 00113 permute_only_top = 0; 00114 } 00115 return result; 00116 }
void tess_training_tester | ( | PBLOB * | blob, | |
DENORM * | denorm, | |||
BOOL8 | correct, | |||
char * | text, | |||
INT32 | count, | |||
BLOB_CHOICE_LIST * | ratings | |||
) |
Matcher tester function which actually trains tess.
blob | single blob | |
denorm | de-normaliser | |
correct | ly segmented ASCII char | |
text | correct ASCII character | |
count | chars in text, ASCII length | |
ratings | list of results |
Definition at line 335 of file tessbox.cpp.
References character, FALSE, free_blob(), LearnBlob(), make_tess_blob(), make_tess_row(), NormMethod, tess_bn_matching, tess_cn_matching, and TRUE.
Referenced by apply_box_training(), and match_word_pass2().
00342 { 00343 TBLOB *tessblob; // converted blob 00344 TEXTROW tessrow; // dummy row 00345 00346 if (correct) { 00347 NormMethod = character; // Force char norm spc 30/11/93 00348 tess_bn_matching = FALSE; // turn it off 00349 tess_cn_matching = FALSE; 00350 tessblob = make_tess_blob (blob, TRUE); // convert blob 00351 make_tess_row(denorm, &tessrow); // make dummy row 00352 LearnBlob(tessblob, &tessrow, text, count); // learn it 00353 free_blob(tessblob); 00354 } 00355 }
WERD_CHOICE* test_segment_pass2 | ( | WERD * | word, | |
DENORM * | denorm, | |||
POLY_MATCHER | matcher, | |||
POLY_TESTER | tester, | |||
WERD_CHOICE *& | raw_choice, | |||
BLOB_CHOICE_LIST_CLIST * | blob_choices, | |||
WERD *& | outword | |||
) |
Segment a word correctly using the pass2 conditions of the tess segmenter. Then call the tester on all words used by tess in its search. Do this only on words where the correct segmentation could be found.
word | bln word to do | |
denorm | de-normaliser | |
matcher | matcher function | |
tester | tester function | |
raw_choice | before context | |
blob_choices | list of blob lists | |
outword | bln word output |
Definition at line 165 of file tessbox.cpp.
References NULL, recog_word(), set_pass2(), and TRUE.
Referenced by match_word_pass2().
00173 { 00174 set_pass2(); 00175 return recog_word (word, denorm, matcher, tester, NULL, TRUE, 00176 raw_choice, blob_choices, outword); 00177 }