diff --git a/app/TODO b/app/TODO index 1a9496c..2a4b8a4 100644 --- a/app/TODO +++ b/app/TODO @@ -1,5 +1,6 @@ BARDZO WAZNE: * przemyslec sposob wybierania jezyka / slownika po zainstalowaniu roznych dystrybucji [PK, TO] +* gue nie sortuje wynikow, opcja weights dziala na odwrot WAZNE: * zamienic kota na lepszego (Kubis) [TO] @@ -12,4 +13,3 @@ WAZNE: * przyspieszyc process_seg() -> obliczanie prefiksow pol z opcji -s i -S raz na poczatku programu, a nie w kolko * kor: nie dziala opcja distance * zunifikowac opcje cor i kor - diff --git a/app/conf/gue.conf b/app/conf/gue.conf index d15afc0..044cdd4 100644 --- a/app/conf/gue.conf +++ b/app/conf/gue.conf @@ -10,3 +10,5 @@ # All lines must looks like: # parameter_name [=] value # +dictionary-home = PATH_PREFIX/share/utt +process = W diff --git a/app/src/gue/common_guess.cc b/app/src/gue/common_guess.cc index d04f24f..d49debf 100644 --- a/app/src/gue/common_guess.cc +++ b/app/src/gue/common_guess.cc @@ -25,7 +25,7 @@ void process_guess_options(gengetopt_args_info* args) { char buf[255]; expand_path(args->dictionary_home_arg, buf); - sprintf(dictionary,"%s/%s/lem.bin",buf,args->language_arg); + sprintf(dictionary,"%s/%s/gue.bin",buf,args->language_arg); if(file_accessible(dictionary)!=0) { fprintf(stderr,"Cannot open the dictionary file: %s\nAborting.\n",dictionary); diff --git a/app/src/gue/main.cc b/app/src/gue/main.cc index 9afb96c..0f09a43 100644 --- a/app/src/gue/main.cc +++ b/app/src/gue/main.cc @@ -12,6 +12,7 @@ #define W_SUFF 0.6 #define W_PREF 0.4 + int main(int argc, char** argv) { // int non_standard_config=0; @@ -25,48 +26,6 @@ int main(int argc, char** argv) { process_common_options(&args,argv[0]); process_guess_options(&args); - - // PONIÅ»EJ POPRZEDNI KOD (JUSTYNY) -// //preliminary command-line parsing - for configuration file info only -// gengetopt_args_info pre_args; - -// if (cmdline_parser(argc, argv, &pre_args) != 0) -// exit(1); -// if(pre_args.config_given){ -// printf("podano config: %s\n",pre_args.config_arg); -// non_standard_config=1; -// } - - -// //configuration file 1 parsing -// struct cmdline_parser_params *params; -// params = cmdline_parser_params_init(); -// params->initialize = 1; -// if(cmdline_parser_config_file(CONFIGFILE1,&args, params)!=0){ -// printf("System-wide configuration file parsing error!\n"); -// exit(1); -// } - -// //configuration file 2 parsing-overriding -// params->initialize=0; -// params->override=1; -// char* config2=(non_standard_config)?pre_args.config_arg:CONFIGFILE2; -// if(cmdline_parser_config_file(config2,&args, params)!=0){ -// printf("User configuration file parsing error!\n"); -// return 1; -// } - -// params->initialize=0; -// params->override=1; -// //params->check_required=1; - -// free(params); - -// //command-line options parsing-overriding -// if (cmdline_parser(argc, argv, &args) != 0) -// exit(1); - - char line[MAX_LINE]; char outline[MAX_LINE]; char parms[MAX_LINE], desc[MAX_LINE], lemma[MAX_LINE]; @@ -83,7 +42,7 @@ int main(int argc, char** argv) { line_count++; int start, len; - line[strlen(line)-1] = '\0'; + // line[strlen(line)-1] = '\0'; if (!process_seg(line, args)) fputs(line,outputf); @@ -118,6 +77,8 @@ int main(int argc, char** argv) { char last_lemma[MAX_LINE]; count = 1; + + tab.sort(); while (count < tab.count() && count <= guess_count) if (first || tab[count].w_suf() >= cut_off && tab[count].w_suf() >= delta * last_weight) @@ -176,12 +137,13 @@ int main(int argc, char** argv) { } else { - for (int i=0; i< tab.count(); ++i) + for (int i=0; i< count; ++i) { // kolejne opisy - kolejne linie. char* descp=desc; - descp += sprintf(desc, " %s%s,%s\n", output_field_prefix, tab[i].lemma(), tab[i].descr()); + descp += sprintf(desc, " %s%s,%s", output_field_prefix, tab[i].lemma(), tab[i].descr()); if(weights) descp += sprintf(descp,":%d",(int)tab[i].w_suf()); + descp += sprintf(descp,"\n"); strcpy(outline,line); outline[strlen(outline)-1]='\0'; strcat(outline,desc); diff --git a/app/src/lib/word.cc b/app/src/lib/word.cc index f669327..f24f4fb 100644 --- a/app/src/lib/word.cc +++ b/app/src/lib/word.cc @@ -15,9 +15,9 @@ void Word::autodescr(const char* fo, const char* de) strncpy(lemd,de,i); lemd[i]='\0'; if(isdigit(lemd[0])) - fullform(f,lemd,l); // je¶li lemat zakodowany + fullform(f,lemd,l); // jeĀ¶li lemat zakodowany else - strcpy(l,lemd); // je¶li lemat w pe³nej postaci + strcpy(l,lemd); // jeĀ¶li lemat w peĀ³nej postaci strcpy(d,de+i+1); } @@ -26,6 +26,18 @@ bool Word::cmp_w(Word a, Word b) { return (a.w_suf() > b.w_suf()); } //--------------------------------------------------------------------------- +bool Word::cmp_w_rev(Word a, Word b) { + return (a.w_suf() < b.w_suf()); +} +//--------------------------------------------------------------------------- +bool cmp_w_fun(Word a, Word b) { + return (a.w_suf() > b.w_suf()); +} +//--------------------------------------------------------------------------- +bool cmp_w_rev_fun(Word a, Word b) { + return (a.w_suf() < b.w_suf()); +} +//--------------------------------------------------------------------------- istream& operator>>(istream& is, Word& w) { @@ -111,6 +123,11 @@ void Words::sort() { std::sort(tab.begin(), tab.end(), Word::cmp_w); } +//--------------------------------------------------------------------------- +void Words::sort_rev() { + std::sort(tab.begin(), tab.end(), cmp_w_rev_fun); +} + //--------------------------------------------------------------------------- int Words::add(const char* fo) diff --git a/app/src/lib/word.h b/app/src/lib/word.h index 0156d6d..774f62e 100644 --- a/app/src/lib/word.h +++ b/app/src/lib/word.h @@ -39,6 +39,7 @@ private: // float _w_pref; public: static bool cmp_w(Word a, Word b); + static bool cmp_w_rev(Word a, Word b); Word() : _len_suf(-1) { *f='\0'; returned=0; }; Word(const char* fo, const char* des) : _len_suf(-1) { autodescr(fo,des); _w_suf=1.0; returned=0; }; @@ -103,6 +104,14 @@ inline int Word::cmp(const Word& w) { return strcmp(f,w.f); } //inline int Word::cmpi(const Word& w) { return PL.cmpi(f,w.f); } //--------------------------------------------------------------------------- + + + + +bool cmp_w_fun(Word a, Word b); +bool cmp_w_rev_fun(Word a, Word b); + + //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- @@ -132,6 +141,7 @@ class Words int next(); void sort(); + void sort_rev(); void prn(ostream& os);