#include #include #include main(int argc, char** argv) { FILE* fp_ref = fopen(argv[1], "r"); FILE* fp_hyp = fopen(argv[2], "r"); char buf_ref[999]; memset(buf_ref, 999, 0); char buf_hyp[999]; memset(buf_hyp, 999, 0); int num_data = 0; int num_correct = 0; while (fgets(buf_ref, 999, fp_ref) != (char*)NULL) { num_data++; memset(buf_hyp, 999, 0); fgets(buf_hyp, 999, fp_hyp); int class_ref = atoi(buf_ref); int class_hyp = atoi(buf_hyp); if (class_ref == class_hyp) { num_correct++; } else { printf("error on token no. %ld: ref = %ld, hyp = %ld\n", num_data, class_ref, class_hyp); } memset(buf_ref, 999, 0); } printf("(%ld correct out of %ld tokens; percent error = %7.2f%s)\n", num_correct, num_data, 100 - (float)num_correct/(float)num_data*100, "%"); fclose(fp_ref); fclose(fp_hyp); }