source: _old/app/src/lem/lem.cc @ 93afab8

Last change on this file since 93afab8 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: 3.0 KB
Line 
1#include "lem.h"
2
3#include <stdlib.h>
4#include <assert.h>
5
6
7/* Znajduje opisy slownikowe dla wyrazu.
8 * Parametry:
9 * form - wyraz,
10 * tab - referencja do tablicy Words (miejsce na wyniki)
11 * Wartosc:
12 * liczba dodanych opisow
13 */
14int Lem::ana(const char* form, Words& tab) {
15
16  // sprawdzamy czy parametry wywolania sa poprawne
17  assert(form && &tab);
18  int count0 = tab.count();
19  long l;
20  if ((l=_dict.next(_dict.gtra(0, form, FT::ftMAXPATH), ';'))>=0)
21    add_to_table(tab, form, l);
22  return tab.count()-count0;
23}
24
25
26/* Szukamy opisu slownikowego nastepnego wyrazu w buforze.
27 * Parametry:
28 * buf - bufor
29 * tab - miejsce na wyniki
30 * Wartosc:
31 * ilosc dodanych opisow
32 */
33int Lem::pref(char* buf, Words& tab) {
34
35  // sprawdzamy czy parametry wywolania sa poprawne
36  assert(buf && &tab);
37
38  int count0 = tab.count();
39  long l;
40  char* buf0 = buf;
41
42  if((l=_dict.pref(buf, ';'))>=0) {
43    char form[MAX_FORM];
44    int len=buf-buf0;
45    form[len]='\0';
46    add_to_table(tab,form,l);
47  }
48  return tab.count() - count0;
49}
50
51/* Dodaje kolejne opisy do tablicy wynikow.
52 * Parametry:
53 * tab - tablica wynikow,
54 * f - wyraz,
55 * s - stan, na ktorym zaczyna sie pierwszy opis
56 */
57void Lem::add_to_table(Words& tab, const char* f, long s) {
58
59  // sprawdzenie parametrow
60  assert(&tab);
61  assert(f);
62
63  char des[FT::ftMAXPATH];
64
65  while (_dict.cont(s, des)) {
66    char* des1;
67    if ((des1=strtok(des, ";")) != NULL)
68      do {
69        if (tab.count() >= MAX_ALT) break;
70        tab.add(f, des1);
71        des1=strtok(NULL, ";");
72      } while (des1!=NULL);
73    s=-1;
74  }
75}
76
77void Lem::prn_dict()
78{
79 
80  char des[FT::ftMAXPATH];
81
82  long s=0;
83
84  while (_dict.cont(s, des)) 
85    {
86      printf("%s\n",des);
87      s=-1;
88    }
89}
90
91
92AuxLem::AuxLem(const char* filename)
93        : Lem(), _dict(SIZE)
94{
95  FILE* f;
96  char buf[MAX_LINE+2];
97  f=fopen(filename,"r");
98  for(long i=0; i<SIZE; ++i) info[i]=(char*)NULL;
99  while(fgets(buf,MAX_LINE,f))
100  {
101    int l=strlen(buf);
102    if(l>=MAX_LINE-1) continue; // BEZ isalpha!
103    buf[l-1]='\0';
104    char* sep=strchr(buf,';');
105    if(sep==NULL) continue;
106    *sep='\0';
107    long formind=_dict.add(buf);
108    if(formind>=0)
109    {
110      char* desc=strdup(sep+1);
111      info[formind]=desc;
112    }
113    else
114      fprintf(stderr,"AuxLem: Form not added: %s;%s.\n", buf,sep+1);
115  }
116  fclose(f);
117};
118
119//---------------------------------------------------------------------------
120
121AuxLem::~AuxLem()
122{
123//  for(long i=0; i<_dict.count(); ++i)
124//    free(info[_dict.hashindex(i)]);
125  for(long i=0; i<SIZE; ++i)
126    if(info[i]) free(info[i]);
127}
128
129//---------------------------------------------------------------------------
130
131int AuxLem::ana(const char* form, Words& tab)
132{
133  if(!form) return 0;
134  int count0=tab.count();
135  char des[MAX_LINE];
136  long ind=_dict[form];
137  if(ind>=0)
138  {
139    strcpy(des,info[ind]);
140    char* des1;
141    if((des1=strtok(des,";"))!=NULL)
142      do
143      {
144        if(tab.cnt>=MAXALT) break;
145        tab.add(form,des1);
146        des1=strtok(NULL,";");
147      } while(des1!=NULL);
148  }
149  return tab.count()-count0;
150}
151
152//---------------------------------------------------------------------------
153
Note: See TracBrowser for help on using the repository browser.