1 #include <ngram_model.h>
5 #include "test_macros.h"
12 run_tests(logmath_t *lmath, ngram_model_t *model)
16 wid = ngram_model_add_word(model, "foobie", 1.0);
17 score = ngram_score(model, "foobie", NULL);
18 TEST_EQUAL_LOG(score, logmath_log(lmath, 1.0/400.0)); /* #unigrams */
20 wid = ngram_model_add_word(model, "quux", 0.5);
21 score = ngram_score(model, "quux", NULL);
22 TEST_EQUAL_LOG(score, logmath_log(lmath, 0.5/400.0)); /* #unigrams */
24 ngram_model_apply_weights(model, 1.0, 1.0, 0.9);
25 score = ngram_score(model, "quux", NULL);
26 TEST_EQUAL_LOG(score, logmath_log(lmath, 0.5/400.0*0.9 + 1.0/400.0*0.1));
28 wid = ngram_model_add_word(model, "bazbar", 0.5);
29 score = ngram_score(model, "bazbar", NULL);
30 TEST_EQUAL_LOG(score, logmath_log(lmath, 0.5/400.0*0.9 + 1.0/400.0*0.1));
34 main(int argc, char *argv[])
39 lmath = logmath_init(1.0001, 0, 0);
41 model = ngram_model_read(NULL, LMDIR "/100.arpa.DMP", NGRAM_DMP, lmath);
42 run_tests(lmath, model);
43 ngram_model_free(model);
45 model = ngram_model_read(NULL, LMDIR "/100.arpa.gz", NGRAM_ARPA, lmath);
46 run_tests(lmath, model);
47 ngram_model_free(model);