48 static const float kPermDawgRatingPad = 5.0;
70 bool word_ending,
WERD_CHOICE *word,
float certainties[],
float *limit,
71 WERD_CHOICE *best_choice,
int *attempts_left,
void *void_more_args) {
74 int word_index = word->
length() - 1;
77 if (best_choice->
rating() < *limit)
return;
83 float permdawg_limit = more_args->
rating_array[word_index] *
85 if (permdawg_limit < word->rating()) {
87 tprintf(
"early pruned word rating=%4.2f,"
88 " permdawg_limit=%4.2f, word=%s\n", word->
rating(),
102 for (
int i = 0; i < active_dawgs.
size(); ++i) {
104 clean_active_dawgs += active_dawgs[i];
107 if (clean_active_dawgs.
size() > 0) {
124 bool checked_unigrams =
false;
127 tprintf(
"checking unigrams in an ngram %s\n",
131 int num_unigrams = 0;
134 const char *ngram_str_end = ngram_str + strlen(ngram_str);
135 const char *ngram_ptr = ngram_str;
136 bool unigrams_ok =
true;
142 DawgArgs unigram_dawg_args(&unigram_active_dawgs,
143 &unigram_constraints,
144 &unigram_updated_active_dawgs,
145 &unigram_updated_constraints, 0.0,
150 while (unigrams_ok && ngram_ptr < ngram_str_end) {
152 UNICHAR_ID uch_id = (step <= 0) ? INVALID_UNICHAR_ID :
160 word_ending && (ngram_ptr == ngram_str_end));
168 unigrams_ok ?
"OK" :
"not OK");
174 orig_uch_id, orig_num_fragments, 0.0, 0.0);
176 checked_unigrams =
true;
188 more_args, word->
unichar_id(word_index), word_ending)) {
196 if (output_ambig_words_file_ ==
NULL) {
197 output_ambig_words_file_ =
199 if (output_ambig_words_file_ ==
NULL) {
200 tprintf(
"Failed to open output_ambig_words_file %s\n",
208 fprintf(output_ambig_words_file_, word_str.
string());
213 hyphen_tail_word = *word;
215 adjusted_word = &hyphen_tail_word;
232 prev_char_frag_info, word, certainties, limit,
233 best_choice, attempts_left, more_args);
242 tprintf(
"last unichar not OK at index %d in %s\n",
265 int sought_word_length,
int start_char_choice_index) {
269 if (char_choices.
length() == 0)
return best_choice;
275 int end_char_choice_index = (sought_word_length == kAnyWordLength) ?
276 char_choices.
length()-1 : start_char_choice_index+sought_word_length-1;
282 if (sought_word_length != kAnyWordLength ||
284 DawgArgs dawg_args(&(active_dawgs[0]), &(constraints[0]),
285 &(active_dawgs[1]), &(constraints[1]),
288 NO_PERM, sought_word_length, end_char_choice_index);
295 delete[] active_dawgs;
296 delete[] constraints;
303 "permute_dawg_debug" :
NULL,
304 char_choices, start_char_choice_index, NULL, &word,
305 certainties, &rating_limit, best_choice, &attempts_left,
307 delete[] active_dawgs;
308 delete[] constraints;