Dolozylismy dwie opcje do kora: wyswietlanie lub nie wynikow oraz wyswietlanie liczby najlepszych zmian.
git-svn-id: svn://atos.wmid.amu.edu.pl/utt@27 e293616e-ec6a-49c2-aa92-f4a8b91c5d16
This commit is contained in:
parent
635ee52333
commit
b3179eb76e
@ -3,8 +3,11 @@ version "0.1"
|
||||
|
||||
option "dictionary-home" - "Dictionary home dir." string typestr="FILENAME" no hidden
|
||||
option "dictionary" d "Dictionary" string typestr="FILENAME" default="cor.bin" no
|
||||
option "distance" n "Maximal edit distance." int default="1" no
|
||||
option "distance" D "Maximal edit distance." int default="1" no
|
||||
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
|
||||
#option "single" - "Place all alternatives in the same line" flag off
|
||||
option "weights" w "File with translation rules." string typestr="FILENAME" default="weight.cor" no
|
||||
option "threshold" t "Edit distance threshold" float default="1" no
|
||||
option "threshold" t "Edit distance threshold" float default="1" no
|
||||
option "show-scores" - "Show scores" flag off
|
||||
option "count" n "Print only count best results" int no
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
char dictionary[MAX_PATH_LENGTH];
|
||||
char file_weights[MAX_PATH_LENGTH];
|
||||
float threshold;
|
||||
bool show_scores = false;
|
||||
int result_count;
|
||||
|
||||
void process_cor_options(gengetopt_args_info* args)
|
||||
{
|
||||
@ -24,4 +26,13 @@ void process_cor_options(gengetopt_args_info* args)
|
||||
expand_path(args->weights_arg, file_weights);
|
||||
|
||||
threshold = args->threshold_arg;
|
||||
|
||||
show_scores = args->show_scores_flag;
|
||||
|
||||
if(args->count_given) {
|
||||
result_count = args->count_arg;
|
||||
}
|
||||
else {
|
||||
result_count = 0;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ extern void process_cor_options(gengetopt_args_info* args);
|
||||
extern char dictionary[];
|
||||
extern char file_weights[];
|
||||
extern float threshold;
|
||||
extern bool show_scores;
|
||||
extern int result_count;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -76,6 +76,14 @@ int main(int argc, char** argv) {
|
||||
{
|
||||
tab.sort();
|
||||
|
||||
int max_cnt = 0;
|
||||
if(result_count < 1) {
|
||||
max_cnt = tab.count();
|
||||
}
|
||||
else {
|
||||
max_cnt = (tab.count() < result_count) ? tab.count() : result_count;
|
||||
}
|
||||
|
||||
if(args.replace_flag)
|
||||
{
|
||||
char corfield[128];
|
||||
@ -97,11 +105,14 @@ int main(int argc, char** argv) {
|
||||
if(one_line)
|
||||
{
|
||||
char* p=corfield;
|
||||
for(int i=tab.count()-1; i >= 0; --i)
|
||||
for(int i=tab.count()-1; i >= tab.count()-max_cnt; --i)
|
||||
{
|
||||
if(tab[i].w_suf() > threshold) continue;
|
||||
restorecasing(tab[i].form(),tab[i].form(),formcasing);
|
||||
p += sprintf(p," %s%s,%1.2f",output_field_prefix,tab[i].form(),tab[i].w_suf());
|
||||
p += sprintf(p," %s%s",output_field_prefix,tab[i].form());
|
||||
if(show_scores) {
|
||||
p += sprintf(p,",%1.2f",tab[i].w_suf());
|
||||
}
|
||||
}
|
||||
sprintf(p,"\n");
|
||||
|
||||
@ -114,11 +125,14 @@ int main(int argc, char** argv) {
|
||||
{
|
||||
char* p=corfield;
|
||||
p += sprintf(p," %s",output_field_prefix);
|
||||
for(int i=tab.count()-1; i >= 0; --i)
|
||||
for(int i=tab.count()-1; i >= tab.count()-max_cnt; --i)
|
||||
{
|
||||
if(tab[i].w_suf() > threshold) continue;
|
||||
restorecasing(tab[i].form(),tab[i].form(),formcasing);
|
||||
p += sprintf(p,(i==0)?"%s,%1.2f":";%s,%1.2f",tab[i].form(),tab[i].w_suf());
|
||||
p += sprintf(p,(i==0)?"%s":";%s",tab[i].form());
|
||||
if(show_scores) {
|
||||
p += sprintf(p,",%1.2f",tab[i].w_suf());
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(p,"\n");
|
||||
@ -130,11 +144,16 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i=tab.count()-1; i >= 0; --i)
|
||||
for(int i=tab.count()-1; i >= tab.count()-max_cnt; --i)
|
||||
{
|
||||
if(tab[i].w_suf() > threshold) continue;
|
||||
restorecasing(tab[i].form(),tab[i].form(),formcasing);
|
||||
sprintf(corfield," %s%s,%1.2f\n",output_field_prefix,tab[i].form(),tab[i].w_suf());
|
||||
char* p = corfield;
|
||||
p += sprintf(p," %s%s",output_field_prefix,tab[i].form());
|
||||
if(show_scores) {
|
||||
p += sprintf(p,",%1.2f",tab[i].w_suf());
|
||||
}
|
||||
p += sprintf(p, "\n");
|
||||
strcpy(outline,line);
|
||||
outline[strlen(outline)-1]='\0';
|
||||
strcat(outline,corfield);
|
||||
|
Loading…
Reference in New Issue
Block a user