//--------------------------------------------------------------------------- #include "word.h" #include "auttools.h" #include //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void Word::autodescr(const char* fo, const char* de) { strcpy(f,fo); // len=strlen(f); char lemd[MAXDESCRLEN]; int i=strcspn(de,","); strncpy(lemd,de,i); lemd[i]='\0'; if(isdigit(lemd[0])) fullform(f,lemd,l); // jeśli lemat zakodowany else strcpy(l,lemd); // jeśli lemat w pełnej postaci strcpy(d,de+i+1); } //--------------------------------------------------------------------------- int Word::cmp_w(Word a, Word b) { return (a.w_suf() > b.w_suf()); } //--------------------------------------------------------------------------- istream& operator>>(istream& is, Word& w) { char temp[Word::MAXLEN+1]; char c; int i=0; while(i'; return os; } //--------------------------------------------------------------------------- Words::~Words() { // for (int i=0; imax && !tab[i].returned) { max = w; result = i; } } if (result != -1) tab[result].returned = 1; return result; } //--------------------------------------------------------------------------- void Words::sort() { std::sort(tab.begin(), tab.end(), Word::cmp_w); } //--------------------------------------------------------------------------- int Words::add(const char* fo) { int i = find(fo); if(i!=-1) { return i; } if (cnt>=tab.capacity()-1) tab.resize(tab.size()*2); tab[cnt].form(fo); tab[cnt].w_suf(0.0); // if(cntform(fo); tab[cnt]->w_suf(0.0); tab[cnt]->w_pref(0.0);*/ return cnt++; // } //return -1; } //--------------------------------------------------------------------------- int Words::add(const char* fo, const char* des) { char d[Word::MAXDESCRLEN]; int l=strcspn(des,","); int ok=1; if( *(des+l) == ',' ) { strcpy(d,des+l+1); // printf("\t%s->%s,\n", des, d); int i=find(fo, d); if(i!=-1) return i; } else ok=0; if (cnt>=tab.capacity()-1) tab.resize(tab.size()*2); tab[cnt].form(fo); if(ok) tab[cnt].autodescr(fo, des); else tab[cnt].autodescr(fo, "?,?"); tab[cnt].w_suf(0.0); tab[cnt].returned = 0; /* // if(cntform(fo); tab[cnt]->autodescr(fo,des); tab[cnt]->w_suf(0.0); tab[cnt]->w_pref(0.0); // printf("ok!\n");*/ return cnt++; // } // printf("hm\n"); return -1; } //--------------------------------------------------------------------------- void Words::prn(ostream& os) { for(int i=0; i"; } //--------------------------------------------------------------------------- ostream& operator<<(ostream& os, Words& tab) { /* for(int i=0; i