/* funcao responsavel pela montagem do arquivo. Une todos processos. */ void mount(char* fileFrom, char* fileTo) { set_table s_table; label_table l_table = build_labels(fileFrom, &s_table); print_file(fileFrom, fileTo, l_table, s_table); free_tables(s_table, l_table); }
void Postagger::test(void) { const char * model_file = test_opt.model_file.c_str(); ifstream mfs(model_file, std::ifstream::binary); if (!mfs) { ERROR_LOG("Failed to load model"); return; } model = new Model; if (!model->load(mfs)) { ERROR_LOG("Failed to load model"); return; } TRACE_LOG("Number of labels [%d]", model->num_labels()); TRACE_LOG("Number of features [%d]", model->space.num_features()); TRACE_LOG("Number of dimension [%d]", model->space.dim()); const char * test_file = test_opt.test_file.c_str(); ifstream ifs(test_file); if (!ifs) { ERROR_LOG("Failed to open holdout file."); return; } decoder = new Decoder(model->num_labels()); PostaggerReader reader(ifs, true); PostaggerWriter writer(cout); Instance * inst = NULL; int num_recalled_tags = 0; int num_tags = 0; double before = get_time(); while ((inst = reader.next())) { int len = inst->size(); inst->tagsidx.resize(len); for (int i = 0; i < len; ++ i) { inst->tagsidx[i] = model->labels.index(inst->tags[i]); } extract_features(inst); calculate_scores(inst, true); decoder->decode(inst); build_labels(inst, inst->predicted_tags); writer.write(inst); num_recalled_tags += inst->num_corrected_predicted_tags(); num_tags += inst->size(); delete inst; } double after = get_time(); double p = (double)num_recalled_tags / num_tags; TRACE_LOG("P: %lf ( %d / %d )", p, num_recalled_tags, num_tags); TRACE_LOG("Eclipse time %lf", after - before); sleep(1000000); return; }