wordrec/tface.cpp File Reference

#include "tface.h"
#include "danerror.h"
#include "globals.h"
#include "tordvars.h"
#include "fxid.h"
#include "wordclass.h"
#include "bestfirst.h"
#include "context.h"
#include "gradechop.h"
#include "hyphen.h"
#include "msmenus.h"
#include "djmenus.h"
#include "tessinit.h"
#include "mfvars.h"
#include "variables.h"
#include "metrics.h"
#include "adaptmatch.h"
#include "matchtab.h"
#include "chopper.h"
#include "permdawg.h"
#include "permute.h"
#include "chop.h"
#include "callcpp.h"
#include "badwords.h"
#include <math.h>

Go to the source code of this file.

Functions

Variables


Function Documentation

CHOICES_LIST cc_recog ( TWERD tessword,
A_CHOICE best_choice,
A_CHOICE best_raw_choice,
BOOL8  tester,
BOOL8  trainer 
)

Recognize a word.

Definition at line 224 of file tface.cpp.

References acts, chop_word_main(), class_string, cprintf(), DebugWordChoices(), FXSELECT, init_match_table(), InitChoiceAccum(), MAX_FX, NULL, OCR, ReleaseErrorTrap(), reset_hyphen_word, and SetErrorTrap.

Referenced by recog_word_recursive().

00228                                      {
00229   int fx;
00230   CHOICES_LIST results;          /*matcher results */
00231 
00232   if (SetErrorTrap (NULL)) {
00233     cprintf ("Tess copped out!\n");
00234     ReleaseErrorTrap();
00235     class_string (best_choice) = NULL;
00236     return NULL;
00237   }
00238   InitChoiceAccum();
00239   init_match_table();
00240   for (fx = 0; fx < MAX_FX && (acts[OCR] & (FXSELECT << fx)) == 0; fx++);
00241   results =
00242     chop_word_main(tessword,
00243                    fx,
00244                    best_choice,
00245                    best_raw_choice,
00246                    tester,
00247                    trainer);
00248   DebugWordChoices();
00249   reset_hyphen_word();
00250   ReleaseErrorTrap();
00251   return results;
00252 }

int dict_word ( const char *  word  ) 

Test the dictionaries, returning NO_PERM (0) if not found, or one of the DAWG_PERM values if found, according to the dictionary.

Definition at line 260 of file tface.cpp.

References FREQ_DAWG_PERM, test_freq_words(), and valid_word().

Referenced by recog_word(), tilde_crunch(), and write_results().

00260                                 {
00261 
00262   if (test_freq_words (word))
00263     return FREQ_DAWG_PERM;
00264   else
00265     return valid_word (word);
00266 }

void edit_with_ocr ( const char *  imagename  ) 

Initialize all the things in the program needed before the classifier code is called.

Definition at line 118 of file tface.cpp.

References correct_fp, FILENAMESIZE, matcher_fp, open_file(), rawfile, textfile, write_output, and write_raw_output.

Referenced by program_editup2().

00118                                           {
00119   char name[FILENAMESIZE];       /*base name of file */
00120 
00121   if (write_output) {
00122     strcpy(name, imagename);
00123     strcat (name, ".txt");
00124                                  //xiaofan
00125     textfile = open_file (name, "w");
00126   }
00127   if (write_raw_output) {
00128     strcpy(name, imagename);
00129     strcat (name, ".raw");
00130     rawfile = open_file (name, "w");
00131   }
00132   if (record_matcher_output) {
00133     strcpy(name, imagename);
00134     strcat (name, ".mlg");
00135     matcher_fp = open_file (name, "w");
00136     strcpy(name, imagename);
00137     strcat (name, ".ctx");
00138     correct_fp = open_file (name, "r");
00139   }
00140 }

int end_recog (  ) 

Cleanup and exit the recog program.

Definition at line 147 of file tface.cpp.

References program_editdown().

Referenced by end_tesseract().

00147                 {
00148   program_editdown (0);
00149 
00150   return (0);
00151 }

void program_editdown ( INT32  elasped_time  ) 

This function holds any nessessary post processing for the Wise Owl program.

Definition at line 158 of file tface.cpp.

References close_choices(), cprintf(), display_text, dj_cleanup(), end_match_table(), end_metrics(), end_permdawg(), end_permute(), free_mem(), free_variables(), global_hash, InitChoiceAccum(), NO_BLOCK, NULL, rawfile, save_summary(), textfile, write_output, and write_raw_output.

Referenced by end_recog().

00158                                           {
00159   dj_cleanup(); 
00160   if (display_text)
00161     cprintf ("\n");
00162   if (!NO_BLOCK && write_output)
00163     fprintf (textfile, "\n");
00164   if (write_raw_output)
00165     fprintf (rawfile, "\n");
00166   if (write_output) {
00167     #ifdef __UNIX__
00168     fsync (fileno (textfile));
00169     #endif
00170     fclose(textfile);
00171   }
00172   if (write_raw_output) {
00173     #ifdef __UNIX__
00174     fsync (fileno (rawfile));
00175     #endif
00176     fclose(rawfile);
00177   }
00178   close_choices();
00179   if (tessedit_save_stats)
00180     save_summary (elasped_time);
00181   end_match_table();
00182   InitChoiceAccum();
00183   if (global_hash != NULL) {
00184     free_mem(global_hash);
00185     global_hash = NULL;
00186   }
00187   end_metrics();
00188   end_permute();
00189   end_permdawg();
00190   free_variables();
00191 }

void program_editup ( const char *  configfile  ) 

Initialize all the things in the program that need to be initialized.

Definition at line 76 of file tface.cpp.

References init_dj_debug(), init_ms_debug(), mfeature_init(), mfeature_variables(), NULL, program_init(), program_variables(), read_variables(), and setup_cp_maps().

Referenced by start_recog().

00076                                             {
00077   init_ms_debug();
00078   init_dj_debug();
00079 
00080   program_variables();
00081   mfeature_variables();
00082 
00083   if (configfile != NULL) {
00084     // cprintf ("Reading configuration from file '%s'\n", configfile);
00085     /* Read config file */
00086     read_variables(configfile);
00087   }
00088   /* Initialize subsystems */
00089   program_init();
00090   mfeature_init();
00091   setup_cp_maps();
00092 }

void program_editup2 ( const char *  textbase  ) 

program_editup2 ?

Definition at line 99 of file tface.cpp.

References edit_with_ocr(), imagefile, init_metrics(), NULL, num_seg_states, ok_split, pass2_ok_split, pass2_seg_states, and reset_width_tally().

Referenced by start_recog().

00099                                            { 
00100   if (textbase != NULL) {
00101     strcpy(imagefile, textbase);
00102     /* Read in data files */
00103     edit_with_ocr(textbase);
00104   }
00105 
00106   init_metrics();
00107   pass2_ok_split = ok_split;
00108   pass2_seg_states = num_seg_states;
00109   reset_width_tally();
00110 }

void set_pass1 (  ) 

Get ready to do some pass 1 stuff.

Definition at line 198 of file tface.cpp.

References blob_skip, FALSE, first_pass, num_seg_states, ok_split, and SettupPass1().

Referenced by tess_segment_pass1().

00198                  {
00199   blob_skip = FALSE;
00200   ok_split = 70.0;
00201   num_seg_states = 15;
00202   SettupPass1();
00203   first_pass = 1;
00204 }

void set_pass2 (  ) 

Get ready to do some pass 2 stuff.

Definition at line 211 of file tface.cpp.

References blob_skip, FALSE, first_pass, num_seg_states, ok_split, pass2_ok_split, pass2_seg_states, and SettupPass2().

Referenced by correct_segment_pass2(), tess_segment_pass2(), and test_segment_pass2().

00211                  {
00212   blob_skip = FALSE;
00213   ok_split = pass2_ok_split;
00214   num_seg_states = pass2_seg_states;
00215   SettupPass2();
00216   first_pass = 0;
00217 }

int start_recog ( const char *  configfile,
const char *  imagebase 
)

Startup recog program ready to recognize words.

Note:
File: tface.h
C side of the Tess/tessedit C/C++ interface.
Author:
Ray Smith
Date:
Mon Apr 27 11:57:06 BST 1992
 * (c) Copyright 1992, Hewlett-Packard Company.
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 ** http://www.apache.org/licenses/LICENSE-2.0
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.

Definition at line 64 of file tface.cpp.

References program_editup(), and program_editup2().

Referenced by init_tesseract().

00064                                                               {
00065 
00066   program_editup(configfile);
00067   program_editup2(textbase);
00068   return (0);
00069 }


Variable Documentation

int NO_BLOCK

Definition at line 53 of file output.cpp.

Referenced by output_pass(), program_editdown(), write_cooked_text(), and write_results().

PRIORITY pass2_ok_split [static]

Note:
File: tface.cpp (Formerly tface.c)
C side of the Tess/tessedit C/C++ interface.
Author:
Ray Smith
Date:
Mon Apr 27 11:57:06 BST 1992
 * (C) Copyright 1992, Hewlett-Packard Ltd.
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 ** http://www.apache.org/licenses/LICENSE-2.0
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.

Definition at line 54 of file tface.cpp.

Referenced by program_editup2(), and set_pass2().

int pass2_seg_states [static]

Definition at line 55 of file tface.cpp.

Referenced by program_editup2(), and set_pass2().


Generated on Wed Feb 28 19:49:29 2007 for Tesseract by  doxygen 1.5.1