- Timestamp:
- 04/11/08 12:48:20 (17 years ago)
- Branches:
- master, help
- Children:
- aa9f1bc
- Parents:
- 635ee52
- git-author:
- pawelk <pawelk@…> (04/11/08 12:48:20)
- git-committer:
- pawelk <pawelk@…> (04/11/08 12:48:20)
- Location:
- app/src/kor
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
app/src/kor/cmdline_cor.ggo
rac7d970 rb3179eb 4 4 option "dictionary-home" - "Dictionary home dir." string typestr="FILENAME" no hidden 5 5 option "dictionary" d "Dictionary" string typestr="FILENAME" default="cor.bin" no 6 option "distance" n"Maximal edit distance." int default="1" no6 option "distance" D "Maximal edit distance." int default="1" no 7 7 option "replace" r "Replace original form with corrected form, place original form in the cor field. This option has no effect in single mode" flag off 8 8 #option "single" - "Place all alternatives in the same line" flag off 9 9 option "weights" w "File with translation rules." string typestr="FILENAME" default="weight.cor" no 10 10 option "threshold" t "Edit distance threshold" float default="1" no 11 option "show-scores" - "Show scores" flag off 12 option "count" n "Print only count best results" int no 13 -
app/src/kor/common_cor.cc
rac7d970 rb3179eb 8 8 char file_weights[MAX_PATH_LENGTH]; 9 9 float threshold; 10 bool show_scores = false; 11 int result_count; 10 12 11 13 void process_cor_options(gengetopt_args_info* args) … … 25 27 26 28 threshold = args->threshold_arg; 29 30 show_scores = args->show_scores_flag; 31 32 if(args->count_given) { 33 result_count = args->count_arg; 34 } 35 else { 36 result_count = 0; 37 } 27 38 } -
app/src/kor/common_cor.h
rac7d970 rb3179eb 22 22 extern char file_weights[]; 23 23 extern float threshold; 24 extern bool show_scores; 25 extern int result_count; 24 26 25 27 #endif -
app/src/kor/main.cc
rac7d970 rb3179eb 77 77 tab.sort(); 78 78 79 int max_cnt = 0; 80 if(result_count < 1) { 81 max_cnt = tab.count(); 82 } 83 else { 84 max_cnt = (tab.count() < result_count) ? tab.count() : result_count; 85 } 86 79 87 if(args.replace_flag) 80 88 { … … 98 106 { 99 107 char* p=corfield; 100 for(int i=tab.count()-1; i >= 0; --i)108 for(int i=tab.count()-1; i >= tab.count()-max_cnt; --i) 101 109 { 102 110 if(tab[i].w_suf() > threshold) continue; 103 111 restorecasing(tab[i].form(),tab[i].form(),formcasing); 104 p += sprintf(p," %s%s,%1.2f",output_field_prefix,tab[i].form(),tab[i].w_suf()); 112 p += sprintf(p," %s%s",output_field_prefix,tab[i].form()); 113 if(show_scores) { 114 p += sprintf(p,",%1.2f",tab[i].w_suf()); 115 } 105 116 } 106 117 sprintf(p,"\n"); … … 115 126 char* p=corfield; 116 127 p += sprintf(p," %s",output_field_prefix); 117 for(int i=tab.count()-1; i >= 0; --i)128 for(int i=tab.count()-1; i >= tab.count()-max_cnt; --i) 118 129 { 119 130 if(tab[i].w_suf() > threshold) continue; 120 131 restorecasing(tab[i].form(),tab[i].form(),formcasing); 121 p += sprintf(p,(i==0)?"%s,%1.2f":";%s,%1.2f",tab[i].form(),tab[i].w_suf()); 132 p += sprintf(p,(i==0)?"%s":";%s",tab[i].form()); 133 if(show_scores) { 134 p += sprintf(p,",%1.2f",tab[i].w_suf()); 135 } 122 136 } 123 137 … … 131 145 else 132 146 { 133 for(int i=tab.count()-1; i >= 0; --i)147 for(int i=tab.count()-1; i >= tab.count()-max_cnt; --i) 134 148 { 135 149 if(tab[i].w_suf() > threshold) continue; 136 150 restorecasing(tab[i].form(),tab[i].form(),formcasing); 137 sprintf(corfield," %s%s,%1.2f\n",output_field_prefix,tab[i].form(),tab[i].w_suf()); 151 char* p = corfield; 152 p += sprintf(p," %s%s",output_field_prefix,tab[i].form()); 153 if(show_scores) { 154 p += sprintf(p,",%1.2f",tab[i].w_suf()); 155 } 156 p += sprintf(p, "\n"); 138 157 strcpy(outline,line); 139 158 outline[strlen(outline)-1]='\0';
Note: See TracChangeset
for help on using the changeset viewer.