Exemplo n.º 1
0
int
main(int argc, char *argv[])
{
    ngram_trie_t *t;
    dict_t *dict;
    bin_mdef_t *mdef;
    logmath_t *lmath;
    cmd_ln_t *config;
    FILE *arpafh;

    config = cmd_ln_init(NULL, ps_args(), TRUE,
                         "-hmm", TESTDATADIR "/hub4wsj_sc_8k",
                         "-dict", TESTDATADIR "/bn10000.homos.dic",
                         NULL);
    ps_init_defaults(config);

    lmath = logmath_init(cmd_ln_float32_r(config, "-logbase"),
                         0, FALSE);
    mdef = bin_mdef_read(config, cmd_ln_str_r(config, "-mdef"));
    dict = dict_init(config, mdef);

    t = ngram_trie_init(dict, lmath);
    arpafh = fopen(TESTDATADIR "/bn10000.3g.arpa", "r");
    ngram_trie_read_arpa(t, arpafh);
    fclose(arpafh);

    /* Test 1, 2, 3-gram probs without backoff. */
    test_lookups(t, lmath);

    arpafh = fopen("tmp.bn10000.3g.arpa", "w");
    ngram_trie_write_arpa(t, arpafh);
    fclose(arpafh);
    ngram_trie_free(t);

    t = ngram_trie_init(dict, lmath);
    arpafh = fopen("tmp.bn10000.3g.arpa", "r");
    ngram_trie_read_arpa(t, arpafh);
    fclose(arpafh);

    /* Test 1, 2, 3-gram probs without backoff. */
    test_lookups(t, lmath);

    /* Test adding nodes. */
    test_add_nodes(t, lmath);

    ngram_trie_free(t);

    dict_free(dict);
    logmath_free(lmath);
    bin_mdef_free(mdef);
    cmd_ln_free_r(config);

    return 0;
}
Exemplo n.º 2
0
int main(POSSIBLY_UNUSED(int argc), char **argv)
{
	EXPECT_ZERO(utility_ctx_init(argv[0])); /* for g_fast_log_mgr */
	EXPECT_ZERO(test_alloc_free());
	EXPECT_ZERO(test_lookups());
	EXPECT_ZERO(test_pack());

	process_ctx_shutdown();

	return EXIT_SUCCESS;
}