Exemplo n.º 1
0
} END_TEST

START_TEST (precompute_creates_probabilities_for_each_token_in_the_pools) {
  precompute_tagger(tagger, random_background);
  assert_not_null(tagger->clues);
  assert_equal(542, tagger->clues->size);
} END_TEST
Exemplo n.º 2
0
} END_TEST

START_TEST (test_precomputing_a_tagger_with_no_probability_function_results_in_a_sequence_error) {
  tagger->probability_function = NULL;
  int rc = precompute_tagger(tagger, random_background);
  assert_equal(TAGGER_SEQUENCE_ERROR, rc);
} END_TEST
Exemplo n.º 3
0
} END_TEST

// TODO START_TEST (test_after_precompute_there_are_clues_for_every_token_in_the_pool) {
//  precompute_tagger(tagger, random_background);
//
//  sqlite3 *db;
//  sqlite3_stmt *stmt;
//  sqlite3_open_v2("fixtures/valid.db", &db, SQLITE_OPEN_READONLY, NULL);
//  sqlite3_prepare_v2(db, "select distinct token_id from entry_tokens where entry_id in (753459, 880389, 886294, 888769, 884409)", -1, &stmt, NULL);
//
//  int clues = 0;
//  while (SQLITE_ROW == sqlite3_step(stmt)) {
//    int token = sqlite3_column_int(stmt, 0);
//    Clue *clue = get_clue(tagger->clues, token);
//    if (clue) {
//      clues++;
//      // should be what is returned by the probability function
//      assert_equal_f(0.75, clue->probability);
//    }
//  }
//
//  assert_equal(542, clues);
//} END_TEST

START_TEST (test_precompute_clears_out_training) {
  precompute_tagger(tagger, random_background);
  assert_null(tagger->positive_pool);
  assert_null(tagger->negative_pool);
} END_TEST
Exemplo n.º 4
0
static void setup(void) {
  setup_fixture_path();
  read_document("fixtures/complete_tag.atom");
  random_background = new_pool();
  system("rm -Rf /tmp/valid-copy && cp -R fixtures/valid /tmp/valid-copy && chmod -R 755 /tmp/valid-copy");
  item_cache_create(&item_cache, "/tmp/valid-copy", &item_cache_options);

  tagger = build_tagger(document, item_cache);
  train_tagger(tagger, item_cache);
  tagger->probability_function = &naive_bayes_probability;
  tagger->classification_function = &mock_classify;
  precompute_tagger(tagger, random_background);
  assert_equal(TAGGER_PRECOMPUTED, tagger->state);

  classified_item = NULL;
  int freeit;
  item = item_cache_fetch_item(item_cache, (unsigned char*) "urn:peerworks.org:entry#709254", &freeit);
}
Exemplo n.º 5
0
} END_TEST

START_TEST (test_precompute_with_trained_tagger_sets_state_to_TAGGER_PRECOMPUTED) {
  precompute_tagger(tagger, random_background);
  assert_equal(TAGGER_PRECOMPUTED, tagger->state);
} END_TEST