static void setup_engine() { setup_fixture_path(); 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); item_cache_load(item_cache); tagger_cache = create_tagger_cache(item_cache, NULL); tagger_cache->tag_retriever = &fetch_url; ce = create_classification_engine(item_cache, tagger_cache, &opts); }
static void setup(void) { setup_fixture_path(); read_document("fixtures/complete_tag.atom"); 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 = &probability_function; assert_equal(TAGGER_TRAINED, tagger->state); random_background = new_pool(); }
static int start_classifier(char * corpus) { if (CLASSIFIER_OK != item_cache_create(&item_cache, corpus, &item_cache_options)) { fprintf(stderr, "Error opening classifier database file at %s: %s\n", corpus, item_cache_errmsg(item_cache)); free_item_cache(item_cache); return EXIT_FAILURE; } else { item_cache_load(item_cache); tagger_cache = create_tagger_cache(item_cache, &tagger_cache_options); tagger_cache->tag_retriever = &fetch_url; tagger_cache->tag_index_retriever = &fetch_url; engine = create_classification_engine(item_cache, tagger_cache, &ce_options); return !ce_start(engine); } }
} END_TEST /************************************************************************ * Initialization tests. ************************************************************************/ START_TEST(test_engine_initialization) { ItemCache *item_cache; item_cache_create(&item_cache, "/tmp/valid-copy", &item_cache_options); item_cache_load(item_cache); tagger_cache = create_tagger_cache(item_cache, NULL); ClassificationEngine *engine = create_classification_engine(item_cache, tagger_cache, &opts); assert_not_null(engine); assert_false(ce_is_running(engine)); free_classification_engine(engine); } END_TEST
static void read_document(void) { setup_fixture_path(); FILE *file; if (NULL != (file = fopen("fixtures/complete_tag.atom", "r"))) { fseek(file, 0, SEEK_END); int size = ftell(file); document = calloc(size, sizeof(char)); fseek(file, 0, SEEK_SET); fread(document, sizeof(char), size, file); document[size] = 0; fclose(file); } system("rm -Rf /tmp/valid-copy && cp -Rf fixtures/valid /tmp/valid-copy && chmod -R 755 /tmp/valid-copy"); item_cache_create(&item_cache, "/tmp/valid-copy", &item_cache_options); }
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); }
} END_TEST START_TEST(test_engine_starting_and_stopping) { ItemCache *item_cache; item_cache_create(&item_cache, "/tmp/valid-copy", &item_cache_options); item_cache_load(item_cache); tagger_cache = create_tagger_cache(item_cache, NULL); ClassificationEngine *engine = create_classification_engine(item_cache, tagger_cache, &opts); assert_not_null(engine); int start_code = ce_start(engine); assert_equal(1, start_code); assert_true(ce_is_running(engine)); assert_equal(0, ce_num_jobs_in_system(engine)); int stop_code = ce_stop(engine); assert_equal(1, stop_code); assert_false(ce_is_running(engine)); free_classification_engine(engine); } END_TEST