source: _old/app/src/lib/word.h @ a6e708f

Last change on this file since a6e708f was a6e708f, checked in by tom <tom@…>, 13 years ago

ANULOWANIE POPRZEDNIEGO COMMITU

Revert "Replacing old implementation with working implementation"

This reverts commit 1e121f45e2d091fcd34a893291b8453e350d5884.

Please enter the commit message for your changes. Lines starting
with '#' will be ignored, and an empty message aborts the commit.

Committer: tom <tom@lim.(none)>

On branch master
Changes to be committed:

(use "git reset HEAD <file>..." to unstage)

modified: _old/app/Makefile
deleted: _old/app/conf/Makefile
deleted: _old/app/conf/compiledic.conf
deleted: _old/app/conf/cor.conf
deleted: _old/app/conf/dgc.conf
deleted: _old/app/conf/dgp.conf
deleted: _old/app/conf/gph.conf
deleted: _old/app/conf/grp.conf
deleted: _old/app/conf/gue.conf
deleted: _old/app/conf/kor.conf
deleted: _old/app/conf/lem.conf
deleted: _old/app/conf/mar.conf
deleted: _old/app/conf/ser.conf
deleted: _old/app/conf/utt.conf
modified: _old/app/src/common/Makefile
modified: _old/app/src/compiledic/Makefile
modified: _old/app/src/compiledic/aut2fsa.cc
modified: _old/app/src/cor/Makefile
modified: _old/app/src/dgp/Makefile
new file: _old/app/src/dgp/canonize
new file: _old/app/src/dgp/dgc
modified: _old/app/src/dgp/grammar.hh
modified: _old/app/src/dgp/mgraph.hh
modified: _old/app/src/dgp/sgraph.hh
modified: _old/app/src/dgp/thesymbols.hh
new file: _old/app/src/dgp/tre
modified: _old/app/src/gue/Makefile
modified: _old/app/src/gue/guess.cc
modified: _old/app/src/kor/Makefile
modified: _old/app/src/kor/corlist.cc
modified: _old/app/src/kor/corr.cc
new file: _old/app/src/kor/corr.hh
modified: _old/app/src/kor/main.cc
modified: _old/app/src/lem/Makefile
modified: _old/app/src/lem/lem.cc
modified: _old/app/src/lib/Makefile
modified: _old/app/src/lib/auttools.cc
modified: _old/app/src/lib/symtab.cc
modified: _old/app/src/lib/tft.h
modified: _old/app/src/lib/tfti.h
modified: _old/app/src/lib/ttrans.h
modified: _old/app/src/lib/word.cc
modified: _old/app/src/lib/word.h
modified: _old/app/src/tok.c/Makefile
modified: _old/app/src/tok.c/cmdline_tok.ggo
modified: _old/app/src/tok.c/common_tok.cc
modified: _old/app/src/tok/Makefile
modified: _old/nawszelkiwypadek/tools/aut2fsa
modified: _old/nawszelkiwypadek/tools/cor_dic/makeLabels.pl
modified: _old/nawszelkiwypadek/tools/cor_dic/prep.pl
modified: _old/nawszelkiwypadek/tools/fsm2aut
modified: _old/nawszelkiwypadek/tools/gue_dic/canon.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/compile_user_dict.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/count_prefs.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/cut_prefs.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/makeLabels.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/prep.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/prep_user_dict.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/rmDup.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/stat.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/stat_pre.pl
modified: _old/nawszelkiwypadek/tools/lem_dic/makeLabels.pl
modified: _old/nawszelkiwypadek/tools/lem_dic/prep.pl
modified: auto/defaults
modified: auto/options
modified: auto/output/Makefile
modified: auto/output/config_h
modified: auto/summary
modified: configure

  • Property mode set to 100644
File size: 4.2 KB
Line 
1//---------------------------------------------------------------------------
2#ifndef _Word_h
3#define _Word_h
4//---------------------------------------------------------------------------
5//#include "alphabet.h"
6//#include "erro.h"
7#include "const.h"
8#include <iostream>
9
10#include <string.h>
11
12#include <vector>
13//---------------------------------------------------------------------------
14
15using namespace std;
16
17
18
19class Word
20{
21public:
22  static const int MAXLEN=64;          // dac do global
23  static const int MAXDESCRLEN=80;     // dac do global
24
25private:
26  /// word form
27  char f[MAX_FORM];                // w wolnej chwili nazwy mozna zamienic na dluzsze
28
29  /// length
30  int _len_suf;  // dlugosc dopasowania koncowki...
31  //  int _len_pref; // ... i prefiksu
32
33  /// lemma
34  char l[MAX_FORM];
35
36  /// description
37  char d[MAX_DESC];
38
39  /// weight (probability)
40  float _w_suf; 
41  //  float _w_pref;
42public:
43  static bool cmp_w(Word a, Word b);
44  static bool cmp_w_rev(Word a, Word b);
45
46  Word() : _len_suf(-1) { *f='\0'; returned=0; };
47  Word(const char* fo, const char* des) : _len_suf(-1) { autodescr(fo,des); _w_suf=1.0; returned=0; };
48
49  Word(const Word& w);
50
51  char* form() { return f; }  // przywrocic const
52  char* lemma() { return l; } // przywrocic const
53  char* descr() { return d; }
54  float w_suf() { return _w_suf; };
55  int len_suf() { return _len_suf; }
56
57
58  void form(const char* s) { strcpy(f,s); }
59  void lemma(const char* s) { strcpy(l,s); }
60  void descr(const char* s) { strcpy(d,s); };
61  void w_suf(float x) { _w_suf=x; };
62  void len_suf(int n) { _len_suf=n; };
63
64  bool operator==(const Word& w);
65  bool operator!=(const Word& w);
66  int cmp(const Word&);
67  int cmpi(const Word&);
68
69  char* operator!() { return f; };
70
71  operator bool() { return _len_suf>0; };
72
73  char* str() { return f; }
74
75  void autodescr(const char* fo, const char* des);
76
77  friend istream& operator>>(istream& is, Word& m);
78  friend ostream& operator<<(ostream& os, Word& m);
79
80  bool returned;
81
82};
83
84
85inline Word::Word(const Word& word)
86{ strcpy(f,word.f); strcpy(l,word.l); strcpy(d,word.d); _len_suf=word._len_suf; _w_suf=word._w_suf; returned = 0; }
87
88//---------------------------------------------------------------------------
89
90inline bool Word::operator==(const Word& w)
91{return _len_suf==w._len_suf && 
92   !strcmp(f,w.f) && !strcmp(l,w.l) && !strcmp(d,w.d); }
93
94//---------------------------------------------------------------------------
95
96inline bool Word::operator!=(const Word& w)
97{return _len_suf!=w._len_suf || 
98   strcmp(f,w.f) || strcmp(l,w.l) || strcmp(d,w.d);}
99
100//---------------------------------------------------------------------------
101
102inline int Word::cmp(const Word& w) { return strcmp(f,w.f); }
103
104//---------------------------------------------------------------------------
105
106//inline int Word::cmpi(const Word& w) { return PL.cmpi(f,w.f); }
107
108//---------------------------------------------------------------------------
109
110
111
112
113bool cmp_w_fun(Word a, Word b);
114bool cmp_w_rev_fun(Word a, Word b);
115
116
117//---------------------------------------------------------------------------
118//---------------------------------------------------------------------------
119
120class Words
121{
122 private:
123  int find(const char* word);
124  int find(const char* word, const char* descr);
125 public:
126
127  static const int MAX=1024;
128
129  Words() : cnt(0) {tab.resize(MAX); };
130  ~Words();
131  Word& operator[](int i) { return tab[i]; }
132  int count() const { return cnt; }
133  void clear() { cnt=0; tab.clear(); }
134  int add(const char* fo);
135  int add(const char* fo, float weight);
136  int add(const char* fo, const char* des);
137
138  /* zwraca index nastepnego wyniku, podczas pierwszego wywolania
139   * zwraca index wyniku o najwiekszej wadze, przy drugim wywolaniu
140   * wynik z druga najwyzsza waga, itd.
141   * Jezeli nie ma juz wynikow - zwraca -1.
142   */
143  int next();
144
145  void sort();
146  void sort_rev();
147
148  void prn(ostream& os);
149
150//  friend class Lem;
151//  friend class AuxLem;
152  friend ostream& operator<<(ostream& os, Words& tab);
153  vector<Word> tab;
154  int cnt;
155
156};
157
158//---------------------------------------------------------------------------
159
160#endif
161
Note: See TracBrowser for help on using the repository browser.