1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <ngram_model.h>
#include <logmath.h>
#include <strfuncs.h>
#include "test_macros.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
int
main(int argc, char *argv[])
{
logmath_t *lmath;
ngram_model_t *model;
/* Initialize a logmath object to pass to ngram_read */
lmath = logmath_init(1.0001, 0, 0);
/* Read a language model */
model = ngram_model_read(NULL, LMDIR "/100.lm.dmp", NGRAM_BIN, lmath);
TEST_ASSERT(model);
ngram_model_casefold(model, NGRAM_UPPER);
TEST_EQUAL(0, strcmp("</s>", ngram_word(model, 5)));
TEST_EQUAL(0, strcmp("BE", ngram_word(model, 42)));
TEST_EQUAL(0, strcmp("FLOORED", ngram_word(model, 130)));
TEST_EQUAL(0, strcmp("ZERO", ngram_word(model, 398)));
TEST_EQUAL(0, strcmp("~", ngram_word(model, 399)));
ngram_model_casefold(model, NGRAM_LOWER);
TEST_EQUAL(0, strcmp("</s>", ngram_word(model, 5)));
TEST_EQUAL(0, strcmp("be", ngram_word(model, 42)));
TEST_EQUAL(0, strcmp("floored", ngram_word(model, 130)));
TEST_EQUAL(0, strcmp("zero", ngram_word(model, 398)));
TEST_EQUAL(0, strcmp("~", ngram_word(model, 399)));
ngram_model_free(model);
logmath_free(lmath);
return 0;
}
|