Lines Matching refs:dict
168 hnj_get_state (HyphenDict *dict, HashTab *hashtab, const char *string) in hnj_get_state() argument
177 hnj_hash_insert (hashtab, string, dict->num_states); in hnj_get_state()
179 if (!(dict->num_states & (dict->num_states - 1))) in hnj_get_state()
181 dict->states = hnj_realloc (dict->states, in hnj_get_state()
182 (dict->num_states << 1) * in hnj_get_state()
185 dict->states[dict->num_states].match = NULL; in hnj_get_state()
186 dict->states[dict->num_states].repl = NULL; in hnj_get_state()
187 dict->states[dict->num_states].fallback_state = -1; in hnj_get_state()
188 dict->states[dict->num_states].num_trans = 0; in hnj_get_state()
189 dict->states[dict->num_states].trans = NULL; in hnj_get_state()
190 return dict->num_states++; in hnj_get_state()
196 hnj_add_trans (HyphenDict *dict, int state1, int state2, char ch) in hnj_add_trans() argument
200 num_trans = dict->states[state1].num_trans; in hnj_add_trans()
203 dict->states[state1].trans = hnj_malloc (sizeof(HyphenTrans)); in hnj_add_trans()
207 dict->states[state1].trans = hnj_realloc (dict->states[state1].trans, in hnj_add_trans()
211 dict->states[state1].trans[num_trans].ch = ch; in hnj_add_trans()
212 dict->states[state1].trans[num_trans].new_state = state2; in hnj_add_trans()
213 dict->states[state1].num_trans++; in hnj_add_trans()
272 HyphenDict *dict = hnj_hyphen_load_from_buffer(addr, sb.st_size); in hnj_hyphen_load() local
276 return dict; in hnj_hyphen_load()
282 HyphenDict *dict[2]; in hnj_hyphen_load_from_buffer() local
308 dict[k] = hnj_malloc (sizeof(HyphenDict)); in hnj_hyphen_load_from_buffer()
309 dict[k]->num_states = 1; in hnj_hyphen_load_from_buffer()
310 dict[k]->states = hnj_malloc (sizeof(HyphenState)); in hnj_hyphen_load_from_buffer()
311 dict[k]->states[0].match = NULL; in hnj_hyphen_load_from_buffer()
312 dict[k]->states[0].repl = NULL; in hnj_hyphen_load_from_buffer()
313 dict[k]->states[0].fallback_state = -1; in hnj_hyphen_load_from_buffer()
314 dict[k]->states[0].num_trans = 0; in hnj_hyphen_load_from_buffer()
315 dict[k]->states[0].trans = NULL; in hnj_hyphen_load_from_buffer()
316 dict[k]->nextlevel = NULL; in hnj_hyphen_load_from_buffer()
317 dict[k]->lhmin = 0; in hnj_hyphen_load_from_buffer()
318 dict[k]->rhmin = 0; in hnj_hyphen_load_from_buffer()
319 dict[k]->clhmin = 0; in hnj_hyphen_load_from_buffer()
320 dict[k]->crhmin = 0; in hnj_hyphen_load_from_buffer()
324 for (i=0;i<MAX_NAME;i++) dict[k]->cset[i]= 0; in hnj_hyphen_load_from_buffer()
325 get_line(dict[k]->cset, sizeof(dict[k]->cset), dict_contents, in hnj_hyphen_load_from_buffer()
328 if ((dict[k]->cset[i] == '\r') || (dict[k]->cset[i] == '\n')) in hnj_hyphen_load_from_buffer()
329 dict[k]->cset[i] = 0; in hnj_hyphen_load_from_buffer()
330 dict[k]->utf8 = (strcmp(dict[k]->cset, "UTF-8") == 0); in hnj_hyphen_load_from_buffer()
332 strcpy(dict[k]->cset, dict[0]->cset); in hnj_hyphen_load_from_buffer()
333 dict[k]->utf8 = dict[0]->utf8; in hnj_hyphen_load_from_buffer()
345 dict[k]->lhmin = atoi(buf + 13); in hnj_hyphen_load_from_buffer()
348 dict[k]->rhmin = atoi(buf + 14); in hnj_hyphen_load_from_buffer()
351 dict[k]->clhmin = atoi(buf + 21); in hnj_hyphen_load_from_buffer()
354 dict[k]->crhmin = atoi(buf + 22); in hnj_hyphen_load_from_buffer()
400 if (dict[k]->utf8) { in hnj_hyphen_load_from_buffer()
424 state_num = hnj_get_state (dict[k], hashtab, word); in hnj_hyphen_load_from_buffer()
425 dict[k]->states[state_num].match = hnj_strdup (pattern + i); in hnj_hyphen_load_from_buffer()
426 dict[k]->states[state_num].repl = repl; in hnj_hyphen_load_from_buffer()
427 dict[k]->states[state_num].replindex = replindex; in hnj_hyphen_load_from_buffer()
429 dict[k]->states[state_num].replcut = strlen(word); in hnj_hyphen_load_from_buffer()
431 dict[k]->states[state_num].replcut = replcut; in hnj_hyphen_load_from_buffer()
441 state_num = hnj_get_state (dict[k], hashtab, word); in hnj_hyphen_load_from_buffer()
442 hnj_add_trans (dict[k], state_num, last_state, ch); in hnj_hyphen_load_from_buffer()
477 dict[k]->states[e->val].fallback_state = state_num; in hnj_hyphen_load_from_buffer()
484 dict[k]->states[e->val].fallback_state); in hnj_hyphen_load_from_buffer()
485 for (j = 0; j < dict[k]->states[e->val].num_trans; j++) in hnj_hyphen_load_from_buffer()
486 printf (" %c->%d\n", dict[k]->states[e->val].trans[j].ch, in hnj_hyphen_load_from_buffer()
487 dict[k]->states[e->val].trans[j].new_state); in hnj_hyphen_load_from_buffer()
496 if (k == 2) dict[0]->nextlevel = dict[1]; in hnj_hyphen_load_from_buffer()
497 return dict[0]; in hnj_hyphen_load_from_buffer()
500 void hnj_hyphen_free (HyphenDict *dict) in hnj_hyphen_free() argument
505 for (state_num = 0; state_num < dict->num_states; state_num++) in hnj_hyphen_free()
507 hstate = &dict->states[state_num]; in hnj_hyphen_free()
515 if (dict->nextlevel) hnj_hyphen_free(dict->nextlevel); in hnj_hyphen_free()
517 hnj_free (dict->states); in hnj_hyphen_free()
519 hnj_free (dict); in hnj_hyphen_free()
524 int hnj_hyphen_hyphenate (HyphenDict *dict, in hnj_hyphen_hyphenate() argument
582 hstate = &dict->states[state]; in hnj_hyphen_hyphenate()
601 match = dict->states[state].match; in hnj_hyphen_hyphenate()
603 if (match && !dict->states[state].repl) in hnj_hyphen_hyphenate()
706 int hnj_hyphen_hyph_(HyphenDict *dict, const char *word, int word_size, in hnj_hyphen_hyph_() argument
782 hstate = &dict->states[state]; in hnj_hyphen_hyph_()
801 match = dict->states[state].match; in hnj_hyphen_hyph_()
802 repl = dict->states[state].repl; in hnj_hyphen_hyph_()
803 replindex = dict->states[state].replindex; in hnj_hyphen_hyph_()
804 replcut = dict->states[state].replcut; in hnj_hyphen_hyph_()
897 if (dict->nextlevel) { in hnj_hyphen_hyph_()
933 hnj_hyphen_hyph_(dict, prep_word + begin + 1, i - begin + 1 + hyph, in hnj_hyphen_hyph_()
966 hnj_hyphen_hyph_(dict->nextlevel, word, word_size, in hnj_hyphen_hyph_()
968 if (!lend) hnj_hyphen_lhmin(dict->utf8, word, word_size, hyphens, in hnj_hyphen_hyph_()
970 if (!rend) hnj_hyphen_rhmin(dict->utf8, word, word_size, hyphens, in hnj_hyphen_hyph_()
1045 int hnj_hyphen_hyphenate2 (HyphenDict *dict, in hnj_hyphen_hyphenate2() argument
1049 hnj_hyphen_hyph_(dict, word, word_size, hyphens, rep, pos, cut, in hnj_hyphen_hyphenate2()
1050 dict->clhmin, dict->crhmin, 1, 1); in hnj_hyphen_hyphenate2()
1051 hnj_hyphen_lhmin(dict->utf8, word, word_size, in hnj_hyphen_hyphenate2()
1052 hyphens, rep, pos, cut, (dict->lhmin > 0 ? dict->lhmin : 2)); in hnj_hyphen_hyphenate2()
1053 hnj_hyphen_rhmin(dict->utf8, word, word_size, in hnj_hyphen_hyphenate2()
1054 hyphens, rep, pos, cut, (dict->rhmin > 0 ? dict->rhmin : 2)); in hnj_hyphen_hyphenate2()
1056 if (dict->utf8) return hnj_hyphen_norm(word, word_size, hyphens, rep, pos, cut); in hnj_hyphen_hyphenate2()
1061 int hnj_hyphen_hyphenate3 (HyphenDict *dict, in hnj_hyphen_hyphenate3() argument
1066 lhmin = (lhmin > 0 ? lhmin : dict->lhmin); in hnj_hyphen_hyphenate3()
1067 rhmin = (rhmin > 0 ? rhmin : dict->rhmin); in hnj_hyphen_hyphenate3()
1068 hnj_hyphen_hyph_(dict, word, word_size, hyphens, rep, pos, cut, in hnj_hyphen_hyphenate3()
1070 hnj_hyphen_lhmin(dict->utf8, word, word_size, hyphens, in hnj_hyphen_hyphenate3()
1072 hnj_hyphen_rhmin(dict->utf8, word, word_size, hyphens, in hnj_hyphen_hyphenate3()
1075 if (dict->utf8) return hnj_hyphen_norm(word, word_size, hyphens, rep, pos, cut); in hnj_hyphen_hyphenate3()