Changeset b3179eb for app/src/kor


Ignore:
Timestamp:
04/11/08 12:48:20 (16 years ago)
Author:
pawelk <pawelk@…>
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)
Message:

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

Location:
app/src/kor
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • app/src/kor/cmdline_cor.ggo

    rac7d970 rb3179eb  
    44option "dictionary-home"        -       "Dictionary home dir." string typestr="FILENAME" no hidden 
    55option "dictionary"             d       "Dictionary" string typestr="FILENAME" default="cor.bin" no 
    6 option "distance"               n       "Maximal edit distance." int default="1" no 
     6option "distance"               D       "Maximal edit distance." int default="1" no 
    77option "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 
    88#option "single"                        -       "Place all alternatives in the same line" flag off 
    99option "weights"                w       "File with translation rules." string typestr="FILENAME" default="weight.cor" no 
    1010option "threshold"              t       "Edit distance threshold" float default="1" no 
     11option "show-scores"            -       "Show scores" flag off 
     12option  "count"                 n       "Print only count best results" int no 
     13 
  • app/src/kor/common_cor.cc

    rac7d970 rb3179eb  
    88char file_weights[MAX_PATH_LENGTH]; 
    99float threshold; 
     10bool show_scores = false; 
     11int result_count; 
    1012 
    1113void process_cor_options(gengetopt_args_info* args) 
     
    2527   
    2628  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  } 
    2738} 
  • app/src/kor/common_cor.h

    rac7d970 rb3179eb  
    2222extern char file_weights[]; 
    2323extern float threshold; 
     24extern bool show_scores; 
     25extern int result_count; 
    2426 
    2527#endif 
  • app/src/kor/main.cc

    rac7d970 rb3179eb  
    7777                      tab.sort(); 
    7878 
     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                 
    7987              if(args.replace_flag) 
    8088                { 
     
    98106                    { 
    99107                      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) 
    101109                        { 
    102110                          if(tab[i].w_suf() > threshold) continue; 
    103111                          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                          } 
    105116                        } 
    106117                      sprintf(p,"\n"); 
     
    115126                      char* p=corfield; 
    116127                      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) 
    118129                        { 
    119130                          if(tab[i].w_suf() > threshold) continue; 
    120131                          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                          } 
    122136                        } 
    123137                       
     
    131145                  else 
    132146                    { 
    133                       for(int i=tab.count()-1; i >= 0; --i) 
     147                      for(int i=tab.count()-1; i >= tab.count()-max_cnt; --i) 
    134148                        { 
    135149                          if(tab[i].w_suf() > threshold) continue; 
    136150                          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"); 
    138157                          strcpy(outline,line); 
    139158                          outline[strlen(outline)-1]='\0'; 
Note: See TracChangeset for help on using the changeset viewer.