201 w = dict_add_word(d, wptr[0], p, nwd - 1);
221dict_write(
dict_t *dict,
char const *filename,
char const *format)
226 if ((fh = fopen(filename,
"w")) == NULL) {
227 E_ERROR_SYSTEM(
"Failed to open '%s'", filename);
230 for (i = 0; i < dict->
n_word; ++i) {
233 if (!dict_real_word(dict, i))
235 for (phlen = j = 0; j < dict_pronlen(dict, i); ++j)
236 phlen += strlen(dict_ciphone_str(dict, i, j)) + 1;
237 phones = ckd_calloc(1, phlen);
238 for (j = 0; j < dict_pronlen(dict, i); ++j) {
239 strcat(phones, dict_ciphone_str(dict, i, j));
240 if (j != dict_pronlen(dict, i) - 1)
243 fprintf(fh,
"%-30s %s\n", dict_wordstr(dict, i), phones);
259 char const *dictfile = NULL, *fillerfile = NULL;
262 dictfile = cmd_ln_str_r(config,
"-dict");
263 fillerfile = cmd_ln_str_r(config,
"_fdict");
274 if ((fp = fopen(dictfile,
"r")) == NULL) {
275 E_ERROR_SYSTEM(
"Failed to open dictionary file '%s' for reading", dictfile);
278 for (li = lineiter_start(fp); li; li = lineiter_next(li)) {
279 if (0 != strncmp(li->buf,
"##", 2)
280 && 0 != strncmp(li->buf,
";;", 2))
283 fseek(fp, 0L, SEEK_SET);
288 if ((fp2 = fopen(fillerfile,
"r")) == NULL) {
289 E_ERROR_SYSTEM(
"Failed to open filler dictionary file '%s' for reading", fillerfile);
293 for (li = lineiter_start(fp2); li; li = lineiter_next(li)) {
294 if (0 != strncmp(li->buf,
"##", 2)
295 && 0 != strncmp(li->buf,
";;", 2))
298 fseek(fp2, 0L, SEEK_SET);
308 (n + S3DICT_INC_SZ < MAX_S3WID) ? n + S3DICT_INC_SZ : MAX_S3WID;
309 if (n >= MAX_S3WID) {
310 E_ERROR(
"Number of words in dictionaries (%d) exceeds limit (%d)\n", n,
318 E_INFO(
"Allocating %d * %d bytes (%d KiB) for word entries\n",
324 d->
mdef = bin_mdef_retain(mdef);
327 if (config && cmd_ln_exists_r(config,
"-dictcase"))
328 d->nocase = cmd_ln_boolean_r(config,
"-dictcase");
333 E_INFO(
"Reading main dictionary: %s\n", dictfile);
336 E_INFO(
"%d words read\n", d->
n_word);
339 if (dict_wordid(d, S3_START_WORD) !=
BAD_S3WID) {
340 E_ERROR(
"Remove sentence start word '<s>' from the dictionary\n");
344 if (dict_wordid(d, S3_FINISH_WORD) !=
BAD_S3WID) {
345 E_ERROR(
"Remove sentence start word '</s>' from the dictionary\n");
349 if (dict_wordid(d, S3_SILENCE_WORD) !=
BAD_S3WID) {
350 E_ERROR(
"Remove silence word '<sil>' from the dictionary\n");
358 E_INFO(
"Reading filler dictionary: %s\n", fillerfile);
364 sil = bin_mdef_silphone(mdef);
367 if (dict_wordid(d, S3_START_WORD) ==
BAD_S3WID) {
368 dict_add_word(d, S3_START_WORD, &sil, 1);
370 if (dict_wordid(d, S3_FINISH_WORD) ==
BAD_S3WID) {
371 dict_add_word(d, S3_FINISH_WORD, &sil, 1);
373 if (dict_wordid(d, S3_SILENCE_WORD) ==
BAD_S3WID) {
374 dict_add_word(d, S3_SILENCE_WORD, &sil, 1);
380 d->
startwid = dict_wordid(d, S3_START_WORD);
381 d->
finishwid = dict_wordid(d, S3_FINISH_WORD);
382 d->
silwid = dict_wordid(d, S3_SILENCE_WORD);
385 || (!dict_filler_word(d, d->
silwid))) {
386 E_ERROR(
"Word '%s' must occur (only) in filler dictionary\n",