53 bool word_ending,
WERD_CHOICE *word,
float certainties[],
float *limit,
54 WERD_CHOICE *best_choice,
int *attempts_left,
void *void_more_args) {
56 word_ending = (char_choice_index == char_choices.
size()-1);
57 int word_index = word->
length() - 1;
58 if (best_choice->
rating() < *limit)
return;
64 bool checked_unigrams =
false;
67 tprintf(
"checking unigrams in an ngram %s\n",
77 bool unigrams_ok =
true;
81 DawgArgs unigram_dawg_args(&unigram_active_dawgs,
82 &unigram_updated_dawgs,
85 for (
int i = 0; unigrams_ok && i < encoding.
size(); ++i) {
93 word_ending && i == encoding.
size() - 1);
98 unigrams_ok ?
"OK" :
"not OK");
105 checked_unigrams =
true;
122 if (output_ambig_words_file_ ==
nullptr) {
123 output_ambig_words_file_ =
125 if (output_ambig_words_file_ ==
nullptr) {
126 tprintf(
"Failed to open output_ambig_words_file %s\n",
133 fprintf(output_ambig_words_file_,
"%s", word_str.
string());
138 fprintf(output_ambig_words_file_,
"%s", word_str.
string());
150 prev_char_frag_info, word, certainties, limit,
151 best_choice, attempts_left, more_args);
158 tprintf(
"last unichar not OK at index %d in %s\n",
191 char_choices, 0,
nullptr, &word, certainties, &rating_limit, best_choice,
192 &attempts_left, &dawg_args);
193 delete[] active_dawgs;
206 int char_choice_index,
215 tprintf(
"%s permute_choices: char_choice_index=%d" 216 " limit=%g rating=%g, certainty=%g word=%s\n",
217 debug, char_choice_index, *limit, word->
rating(),
220 if (char_choice_index < char_choices.
length()) {
221 BLOB_CHOICE_IT blob_choice_it;
222 blob_choice_it.set_to_list(char_choices.
get(char_choice_index));
223 for (blob_choice_it.mark_cycle_pt(); !blob_choice_it.cycled_list();
224 blob_choice_it.forward()) {
227 char_choice_index, prev_char_frag_info, word,
228 certainties, limit, best_choice, attempts_left, more_args);
229 if (*attempts_left <= 0) {
230 if (debug)
tprintf(
"permute_choices(): attempts_left is 0\n");
249 int char_choice_index,
257 int word_ending = (char_choice_index == char_choices.
length() - 1);
262 blob_choice.
certainty(), prev_char_frag_info, debug,
263 word_ending, &char_frag_info)) {
267 if (char_frag_info.
unichar_id == INVALID_UNICHAR_ID) {
269 &char_frag_info, word, certainties, limit,
270 best_choice, attempts_left, more_args);
275 float old_rating = word->
rating();
277 uint8_t old_permuter = word->
permuter();
285 &char_frag_info, word_ending, word, certainties,
286 limit, best_choice, attempts_left, more_args);
321 float curr_rating,
float curr_certainty,
323 const char *debug,
int word_ending,
328 prev_char_frag_info !=
nullptr ? prev_char_frag_info->
fragment :
nullptr;
331 if (debug && (prev_fragment || this_fragment)) {
332 tprintf(
"%s check fragments: choice=%s word_ending=%d\n", debug,
344 char_frag_info->
fragment = this_fragment;
345 char_frag_info->
rating = curr_rating;
346 char_frag_info->
certainty = curr_certainty;
348 if (prev_fragment && !this_fragment) {
349 if (debug)
tprintf(
"Skip choice with incomplete fragment\n");
354 char_frag_info->
unichar_id = INVALID_UNICHAR_ID;
357 if (debug)
tprintf(
"Non-matching fragment piece\n");
365 tprintf(
"Built character %s from fragments\n",
370 if (debug)
tprintf(
"Record fragment continuation\n");
371 char_frag_info->
fragment = this_fragment;
375 prev_char_frag_info->
rating + curr_rating;
378 std::min(curr_certainty, prev_char_frag_info->
certainty);
381 if (debug)
tprintf(
"Record fragment beginning\n");
384 tprintf(
"Non-starting fragment piece with no prev_fragment\n");
390 if (word_ending && char_frag_info->
fragment) {
391 if (debug)
tprintf(
"Word can not end with a fragment\n");
bool is_beginning() const
bool fragment_state_okay(UNICHAR_ID curr_unichar_id, float curr_rating, float curr_certainty, const CHAR_FRAGMENT_INFO *prev_char_frag_info, const char *debug, int word_ending, CHAR_FRAGMENT_INFO *char_frag_info)
bool is_continuation_of(const CHAR_FRAGMENT *fragment) const
void append_unichar_id_space_allocated(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty)
const char * string() const
const UNICHARSET * unicharset() const
void init_active_dawgs(DawgPositionVector *active_dawgs, bool ambigs_mode) const
void append_unichar_id(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty)
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
static STRING to_string(const char *unichar, int pos, int total, bool natural)
void update_best_choice(const WERD_CHOICE &word, WERD_CHOICE *best_choice)
void make_bad()
Set the fields in this choice to be default (bad) values.
const char * get_unichar() const
char * output_ambig_words_file
const CHAR_FRAGMENT * fragment
void go_deeper_dawg_fxn(const char *debug, const BLOB_CHOICE_LIST_VECTOR &char_choices, int char_choice_index, const CHAR_FRAGMENT_INFO *prev_char_frag_info, bool word_ending, WERD_CHOICE *word, float certainties[], float *limit, WERD_CHOICE *best_choice, int *attempts_left, void *void_more_args)
void(Dict::* go_deeper_fxn_)(const char *debug, const BLOB_CHOICE_LIST_VECTOR &char_choices, int char_choice_index, const CHAR_FRAGMENT_INFO *prev_char_frag_info, bool word_ending, WERD_CHOICE *word, float certainties[], float *limit, WERD_CHOICE *best_choice, int *attempts_left, void *void_more_args)
Pointer to go_deeper function.
DawgPositionVector * updated_dawgs
UNICHAR_ID unichar_id(int index) const
DLLSYM void tprintf(const char *format,...)
void string_and_lengths(STRING *word_str, STRING *word_lengths_str) const
void remove_last_unichar_id()
void append_choices(const char *debug, const BLOB_CHOICE_LIST_VECTOR &char_choices, const BLOB_CHOICE &blob_choice, int char_choice_index, const CHAR_FRAGMENT_INFO *prev_char_frag_info, WERD_CHOICE *word, float certainties[], float *limit, WERD_CHOICE *best_choice, int *attempts_left, void *more_args)
const CHAR_FRAGMENT * get_fragment(UNICHAR_ID unichar_id) const
const STRING debug_string() const
int max_permuter_attempts
const char * id_to_unichar(UNICHAR_ID id) const
DawgPositionVector * active_dawgs
const UNICHARSET & getUnicharset() const
WERD_CHOICE * dawg_permute_and_select(const BLOB_CHOICE_LIST_VECTOR &char_choices, float rating_limit)
UNICHAR_ID unichar_id() const
void permute_choices(const char *debug, const BLOB_CHOICE_LIST_VECTOR &char_choices, int char_choice_index, const CHAR_FRAGMENT_INFO *prev_char_frag_info, WERD_CHOICE *word, float certainties[], float *limit, WERD_CHOICE *best_choice, int *attempts_left, void *more_args)
void set_certainty(float new_val)
int(Dict::* letter_is_okay_)(void *void_dawg_args, const UNICHARSET &unicharset, UNICHAR_ID unichar_id, bool word_end) const
void set_rating(float new_val)
void set_permuter(uint8_t perm)