int main() { int option = 0; TREE *tree; tree = Tree_create(); /* Resgatar os dados do arquivo ao iniciar o programa */ resgatar_dados_arquivo(&(tree->root)); while(option != 6) { print_menu(); inserir_inteiro(&option); switch(option) { case 1: menu_cadastrar(&(tree->root)); break; case 2: menu_consultar(tree->root); break; case 3: menu_excluir(tree->root); break; case 4: menu_mostrar_relacao(tree->root); break; case 5: menu_gerar_relatorio(tree->root); break; case 6: destroy_all(tree->root); exit(EXIT_SUCCESS); break; default: printf("\nOpcao invalida!\n"); break; } } destroy_all(tree->root); return 0; }
int main(int argc, char** argv) { TNF_Index* index = (TNF_Index*)TNF_malloc(sizeof(TNF_Index)); TNF_Node* root = Tree_create(); TNF_Record* record = TNF_CreateFile(); index->tree = root; index->record = record; if (argc == 1){ // interactive mode } else if (argc == 2){ // file mode readFile(index, argv[1]); } else { fprintf(stderr, "ERROR: lispy need more arguments\n"); exit(0); } return 0; }
/* * Main method. * Read arguments, alphabet and samples. * Starts the BIC calculator. * Runs the champion trees selector. * Then runs the bootstrap method to return the selected Context Tree. */ int main(int argc, char** argv) { /* Parameters and defaults */ char* filename = NULL; unsigned int depth = 5; unsigned int size_resample_small = 30; unsigned int size_resample_large = 90; unsigned int number_resample_small = 10; unsigned int number_resample_large = 10; char *renewalstr = NULL; unsigned int seed = 0; char *c_method = NULL; int print_champs = 0; /* Process options */ int c, e = 0; while (1) { static struct option long_options[] = { {"file", required_argument, 0, 'f'}, {"depth", required_argument, 0, 'd'}, {"small-sample-percentage", required_argument, 0, 'p'}, {"large-sample-percentage", required_argument, 0, 'P'}, {"number-samples", required_argument, 0, 'n'}, {"number-large-samples", required_argument, 0, 'N'}, {"renewal-string", required_argument, 0, 'r'}, {"seed", required_argument, 0, 's'}, {"scale", required_argument, 0, 'k'}, {"champ-method", required_argument, 0, 'c'}, {"print-champs", no_argument, 0, 'C'}, {0, 0, 0, 0} }; int option_index = 0; c = getopt_long (argc, argv, "f:d:p:P:n:N:r:s:c:k:C", long_options, &option_index); if ( c == -1) break; switch ( c ) { SOPT('f', "filename", filename); IOPT('d', "depth", depth); IOPT('p', "small sample percentage", size_resample_small); IOPT('P', "large sample percentage", size_resample_large); IOPT('n', "small resample number", number_resample_small); IOPT('N', "large resample number", number_resample_large); IOPT('s', "seed", seed); FOPT('k', "scale", scale); SOPT('r', "renewal string", renewalstr); SOPT('c', "champ method", c_method); NOPT('C', print_champs); case '?': e = 1; } } DEB("file %s\ndepth %d\nsmall p %d\nlarge p %d\nsmall num %d\nlarge num %d\nseed %d\nren %s\n", filename,depth,size_resample_small,size_resample_large,number_resample_small,number_resample_large,seed,renewalstr); champ_method = !c_method || c_method[0] != 'o'; if(e){ usage(); exit(0); } if (optind < argc && !filename) filename = strdup(argv[optind]); if(!filename) fatal_error(MISSING_FILENAME); Tree_node prob_root = Tree_create(PROB); Tree_node bic_root = Tree_create(BIC); char** sample = read_lines(filename); setup_BIC(sample, depth, prob_root, bic_root); // pre calculations // champions set calculation Champion_item champion_bics = champion_set(bic_root, Max_c(prob_root), Eps(prob_root)); if (print_champs){ ITERA(Champion_item, champion_item, champion_bics, next) { printf("c=%f tree=[ ", champion_item->tau->c); print_Tau(champion_item->tau); printf("]\n"); } }