gue wreszcie dziala, tylko nie sortuje wynikow

git-svn-id: svn://atos.wmid.amu.edu.pl/utt@50 e293616e-ec6a-49c2-aa92-f4a8b91c5d16
This commit is contained in:
obrebski 2008-05-09 10:42:32 +00:00
parent 3748bd1db4
commit 6ac84d8bba
6 changed files with 40 additions and 49 deletions

View File

@ -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

View File

@ -10,3 +10,5 @@
# All lines must looks like:
# parameter_name [=] value
#
dictionary-home = PATH_PREFIX/share/utt
process = W

View File

@ -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);

View File

@ -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);

View File

@ -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); // jeli 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)

View File

@ -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);