00001
00020
00021
00022
00023 #include "general.h"
00024 #include "oldheap.h"
00025 #include "callcpp.h"
00026
00027 #include <string.h>
00028 #include <stdio.h>
00029 #ifdef __UNIX__
00030 #include <assert.h>
00031 #endif
00032
00033 #define MAX_NUM_BAD_WERDS 1000
00034
00035
00036
00037
00038 static HEAP *BadWords = NULL;
00039
00042 BOOL_VAR (tessedit_save_stats, FALSE, "Save final recognition statistics");
00045
00046
00047
00048
00059 void PrintBadWords(FILE *File) {
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 }
00076
00077
00078
00093 void SaveBadWord(const char *Word, FLOAT32 Certainty) {
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 }