Blame view
tools/sctk-2.4.10/src/sclite/sctk.h
9.98 KB
8dcb6dfcb first commit |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
/* main include file for the Scoring ToolKit (SCTK) */ /* Created: Jul, 28, 1997 */ #define TK_VERSION "1.3" #include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <sys/stat.h> #include <sys/time.h> #include <time.h> #ifdef __cplusplus extern "C" { #endif #include "text.h" #include "booldef.h" #include "wtokstr1.h" #include "path.h" #include "proto.h" #include "order.h" #include "stm.h" #include "pad.h" #include "sgml.h" #include "alex.h" #include "netstr1.h" #include "llist.h" #define db_enter_msg(_s,_db) {if (_db < db_level) printf("DB: Entering %s ",_s);} #define db_leave_msg(_s,_db) {if (_db < db_level) printf("DB: Leaving %s ",_s);} #define strdup_safe(_s,_p) (char *)TEXT_strdup((TEXT *)_s) #define malloc_safe(_s,_p) malloc(_s) #define streq(cs,ct) (strcmp(cs,ct) == 0) #ifdef __STDC__ /* rsprinaztf.c */ char *rsprintf PROTO((char *format , ...)); #else /* rsprintf.c */ char *rsprintf PROTO((va_alist)); #endif #define F_ROUND(_n,_p) (((float)((int)((_n) * pow(10.0,(float)(_p)) + ((_n>0.0)?0.5:-0.5)))) / pow(10.0,(float)(_p))) #define F_CEIL(_n,_p) ( ((double)ceil((double)((_n) * pow(10.0,(double)(_p))))) / pow(10.0,(double)(_p))) #define pct(num,dem) (((dem)==0) ? 0 : (double)(num)/(double)(dem) * 100.0) #define form_feed(_f) fprintf(_f,""); #define TRUE 1 #define FALSE 0 /* bit field accessors, and query macros */ #define BF_isSET(_v,_f) (((_v) & (_f)) > 0) #define BF_notSET(_v,_f) (((_v) & (_f)) == 0) #define BF_SET(_v,_f) _v |= (_f) #define BF_FLIP(_v,_f) _v ^= (_f) #define BF_UNSET(_v,_f) _v &= ~(_f) #ifndef MAX #define MAX(_a,_b) (((_a) > (_b)) ? (_a) : (_b)) #endif #ifndef MIN #define MIN(_a,_b) (((_a) < (_b)) ? (_a) : (_b)) #endif #define MAX3(_a,_b,_c) (MAX(_a,(MAX(_b,_c)))) #ifndef M_LOG2E #define M_LOG2E 1.4426950408889634074 #endif /* using slope to linearly interprelate Based on: M = (y2 - y1) / (x2 - y2) (y2 - y1) / (x2 - y2) = (y2 - QY) / (x2 - PX) (x2 - PX) * (y2 - y1) / (x2 - y2) = (y2 - QY) y2 - ((x2 - PX) * (y2 - y1) / (x2 - x2)) = QY */ #define interpelate_y_from_x(_x1, _y1, _x2, _y2, _kn_X) \ (_y2 - ((_x2 - _kn_X) * (_y2 - _y1) / (_x2 - _x1))) #define SCREEN_WIDTH 80 #define FULL_SCREEN 132 #define INF_ASCII_TOO 1 #define CALI_ON 1 #define CALI_NOASCII 2 #define CALI_DELHYPHEN 4 #include "word.h" #include "cores.h" #include "memory.h" #include "rpg.h" typedef struct grp_score{ char *name; int corr; /* num correct words in sent */ int ins; /* num inserted words in sent */ int del; /* num deleted words in sent */ int sub; /* num substituted words in sent */ int merges; /* num of merges */ int splits; /* num of splits */ double weight_ref; /* weighted sum of reference words in sent */ double weight_corr; /* weighted sum of correct words in sent */ double weight_ins; /* weighted sum of inserted words in sent */ double weight_del; /* weighted sum of deleted words in sent */ double weight_sub; /* weighted sum of substituted words in sent */ double weight_merges; /* weighted sum of of merges */ double weight_splits; /* weighted sum of of splits */ int nsent; /* number of sentences, utts, ... */ int serr; /* number of sents with an error */ int max_path; /* Size of PATH array */ int num_path; /* number of PATH's in PATH array */ PATH **path; /* array of PATH pointers */ } GRP; typedef struct pathlabel_item_struct{ char *id; /* the label's id code */ char *title; /* Column heading title for the lable */ char *desc; /* Descriptive text for the label */ } PATHLABEL_ITEM; typedef struct category_item_struct{ char *id; /* the category's id code */ char *title; /* Column heading title for the category */ char *desc; /* Descriptive text for the catagory */ } CATEGORY_ITEM; typedef struct arbitrary_subset_label_struct{ int max_plab; /* max PATHLABEL_ITEMS in 'plab' array */ int num_plab; /* current number of items in 'plab' array */ PATHLABEL_ITEM *plab; /* list of path labels */ int max_cat; /* max CATEGORY_ITEMS in 'cat' array */ int num_cat; /* current number of items in 'cat' array */ CATEGORY_ITEM *cat; /* list of categories */ } ARB_SSET; typedef struct set_score{ char *title; /* the title to call the system in reports */ char *ref_fname; /* filename of the reference file */ char *hyp_fname; /* filename of the hypothesis file */ char *creation_date; /* creation date */ int frag_corr; /* if the comline fragment correct flag */ int opt_del; /* if the comline opt_del flag set */ int weight_ali; /* if the comline word weight alignment set */ char *weight_file; /* if the comline word weight alignment set, wwl filename */ int max_grp; /* maximum number of path groups (speakers) */ int num_grp; /* current number of path groups */ GRP *grp; /* a list of path groups */ ARB_SSET aset; /* struct of arbitrary labelling */ } SCORES; #if __STDC__ FILE * readpipe (char *progname, ...); #else FILE * readpipe (); #endif #include "corresp.h" #include "wwscr_f.h" SCORES *SCORES_init(char *name, int ngrp); void SCORES_free(SCORES *scor); int SCORES_get_grp(SCORES *sc, char *grpname); int find_PATHLABEL_id(SCORES *sc, char *id); int parse_input_comment_line(SCORES *sc, TEXT *buf); void load_comment_labels_from_file(SCORES *scor, char *labfile); void add_PATH_score(SCORES *sc, PATH *path, int grp, int keep_path); void dump_SCORES(SCORES *sc, FILE *fp); void dump_SCORES_alignments(SCORES *sc, FILE *fp, int lw, int full); void dump_SCORES_sgml(SCORES *sc, FILE *fp, TEXT *token_separator, TEXT *token_attribute_separator); int load_SCORES_sgml(FILE *fp, SCORES **scor, int *nscor, int maxscor); void print_system_summary(SCORES *sc, char *sys_root_name, int do_sm, int do_raw, int do_weighted, int feedback); void print_N_system_summary(SCORES *sc[], int nsc, char *out_root_name, char *test_name, int do_raw, int feedback); void print_N_system_executive_summary(SCORES *sc[], int nsc, char *out_root_name, char *test_name, int do_raw, int feedback); void print_SCORES_compare_matrix(SCORES *scor[], int nscor, int **winner, char *tname, char *matrix_name); void print_lur(SCORES *sc, char *sys_root_name, int feedback); void print_N_lur(SCORES *scor[], int nscor, char *outname, char *test_name, int feedback); void compute_SCORE_nce(SCORES *sc, double *nce_system, double *nce_a); void print_N_SCORE(SCORES *scor[], int nscor, char *outname, int max, int feedback, int score_diff); enum id_types {WSJ,RM,ATIS,SWB,SPUID,SP}; SCORES *align_trans_mode_dp(char *ref_file, char *hyp_file, char *title, int keep_path, int case_sense, int feedback, int char_align, enum id_types idt, int infer_word_seg, char *lexicon, int frag_correct, int opt_del, int inf_no_ascii, WWL *wwl, char *lm_file); SCORES *align_ctm_to_stm_dp(char *ref_file, char *hyp_file, char *set_title, int keep_path, int case_sense, int feedback, int char_align, enum id_types idt, int infer_word_seg, char *lexicon, int frag_correct, int opt_del, int inf_no_ascii, int reduce_ref, int reduce_hyp, int left_to_right, WWL *wwl, char *lm_file); SCORES *align_trans_mode_diff(char *ref_file, char *hyp_file, char *title, int keep_path, int case_sense, int feedback, enum id_types idt); SCORES *align_ctm_to_stm_diff(char *ref_file, char *hyp_file, char *set_title, int keep_path, int case_sense, int feedback, enum id_types idt); SCORES *align_text_to_stm(char *ref_file, char *hyp_file, char *set_title, int keep_path, int case_sense, int feedback, enum id_types idt); void expand_words_to_chars(ARC *arc, void *ptr); void decode_opt_del(ARC *arc, void *ptr); void decode_fragment(ARC *arc, void *ptr); PATH *network_dp_align_texts(TEXT *ref, NETWORK *rnet, TEXT *hyp, NETWORK *hnet, int char_align, int case_sense, char *id, int fcorr, int opt_del, int time_align, WWL *wwl, char *lm_file); PATH *infer_word_seg_algo1(TEXT *ref, TEXT *hyp, NETWORK *hnet, int case_sense,char *id, char *lex_fname, int fcorr, int opt_del, int no_ascii); PATH *infer_word_seg_algo2(TEXT *ref, TEXT *hyp, NETWORK *hnet, int case_sense,char *id, char *lex_fname, int fcorr, int opt_del, int flags); SCORES *align_ctm_to_ctm(char *hyp_file, char *ref_file, char *set_title, int feedback, int frag_corr, int opt_del, int case_sense, int time_align, int left_to_right, WWL *wwl, char *lm_file); double overlap(double s1_t1, double s1_t2, double s2_t1, double s2_t2); int score_dtl_sent(SCORES *scor, char *sys_root_name, int feedback); int score_dtl_spkr(SCORES *scor, char *sys_root_name, int feedback); int score_dtl_overall(SCORES *scor, char *sys_root_name, int feedback); char *get_date(void); int hyp_confidences_available(SCORES *scor); int make_SCORES_DET_curve(SCORES *scor[], int nscor, char *outroot, int feedback, char *test_name); int make_binned_confidence(SCORES *scor, char *outroot, int feedback); int make_scaled_binned_confidence(SCORES *scor, char *outroot, int bins, int feedback); int make_confidence_histogram(SCORES *scor, char *outroot, int feedback); /* debug levels */ /* level 1: print function entrances */ /* level 2: print function arguements */ /* level 5: intermediate status */ extern int db; #define LINE_LENGTH 500 #define INF_SEG_ALGO1 1 #define INF_SEG_ALGO2 2 #include "rank.h" #include "statdist.h" #define scfp stderr #ifdef MAIN int db=0, db_level; char *pdb=""; #else extern int db, db_level; extern char *pdb; #endif #ifdef DIFF_EXE #define DIFF_ENABLED 1 #define DIFF_PROGRAM DIFF_EXE #else #define DIFF_ENABLED 0 #define DIFF_PROGRAM "" #endif #ifdef WITH_SLM #include "slm_v2/include/SLM2.h" #endif #include "slm_intf.h" #ifdef __cplusplus } #endif |