wordrec/badwords.cpp File Reference

#include "general.h"
#include "oldheap.h"
#include "callcpp.h"
#include <string.h>
#include <stdio.h>

Go to the source code of this file.

Defines

Functions

Variables


Define Documentation

#define MAX_NUM_BAD_WERDS   1000

Note:
File: badwords.cpp
Routines to keep the bad words in sorted order.
Author:
Dan Johnson
Date:
Thu Apr 25 08:40:19 1991, DSJ, Created.
 **	(c) Copyright Hewlett-Packard Company, 1988.
 ** 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 33 of file badwords.cpp.

Referenced by SaveBadWord().


Function Documentation

void PrintBadWords ( FILE *  File  ) 

Prints the bad words stored in BadWords to file ordered by certainty (worst certainty first).

Parameters:
File Open text file to print bad words to
Note:
Globals: BadWords Heap that bad words are stored in
Returns:
none
Note:
Exceptions: none
Date:
Thu Apr 25 08:57:08 1991, DSJ, Created.

Definition at line 59 of file badwords.cpp.

References BadWords, c_free_string(), HEAPENTRY::Data, EMPTY, GetTopOfHeap(), HEAPENTRY::Key, and NULL.

Referenced by dj_statistics().

00059                                { 
00060   HEAPENTRY NextWord;
00061 
00062   if (BadWords == NULL)
00063     return;
00064 
00065   fprintf (File, "\n");
00066   fprintf (File, "Bad Word         Certainty\n");
00067   fprintf (File, "---------------- ---------\n");
00068   while (GetTopOfHeap (BadWords, &NextWord) != EMPTY) {
00069     fprintf (File, "%16s %6.2f\n", (const char *) NextWord.Data,
00070       NextWord.Key);
00071     c_free_string ((char *) NextWord.Data);
00072   }
00073   fprintf (File, "\n");
00074 
00075 }                                /* PrintBadWords */

void SaveBadWord ( const char *  Word,
FLOAT32  Certainty 
)

Saves all words flagged as bad in a heap with the worst word on the top of the heap.

Parameters:
Word bad word to be saved
Certainty certainty of word
Note:
Globals: BadWords heap to keep bad words in
Returns:
none
The contents of this heap can be printed to a file by calling PrintBadWords (File).
Note:
Exceptions: none
Date:
Thu Apr 25 08:41:00 1991, DSJ, Created.

Definition at line 93 of file badwords.cpp.

References assert(), BadWords, c_alloc_string(), HEAPENTRY::Data, HeapFull, HeapStore(), InitHeap, HEAPENTRY::Key, MakeHeap(), MAX_NUM_BAD_WERDS, and NULL.

Referenced by classify_word_pass2().

00093                                                       { 
00094   HEAPENTRY NewWord;
00095 
00096   assert (Word != NULL);
00097 
00098   if (BadWords == NULL) {
00099     BadWords = MakeHeap (MAX_NUM_BAD_WERDS);
00100     InitHeap(BadWords); 
00101   } else if (HeapFull(BadWords)) {
00102     return;
00103   }
00104 
00105   NewWord.Key = Certainty;
00106   NewWord.Data = c_alloc_string (strlen (Word) + 1);
00107   strcpy ((char *) NewWord.Data, Word);
00108   HeapStore(BadWords, &NewWord); 
00109 
00110 }                                /* SaveBadWord */


Variable Documentation

HEAP* BadWords = NULL [static]

Definition at line 38 of file badwords.cpp.

Referenced by PrintBadWords(), and SaveBadWord().


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