Back to index

wims  3.65+svn20090927
Defines | Functions | Variables
suffix.c File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


#define suflim   256
#define sufbuflim   102400


int sufcomp (int t, const unsigned char *s2)
int suffix_list (void *list, int items, size_t item_size, const char *str)
void suffix_dic (char *sdicname)
void suffix_translate (char *p)
void suffix (char *p, char *sdicname)


int suffixcnt
struct {
unsigned char * original
int olen
unsigned char * replace
suf [suflim]
char * sufbuf
int sufwordlen
int sufminlen

Define Documentation

#define sufbuflim   102400

Definition at line 19 of file suffix.c.

#define suflim   256

Definition at line 18 of file suffix.c.

Function Documentation

int sufcomp ( int  t,
const unsigned char *  s2 

Definition at line 33 of file suffix.c.

    int k;
    for(k=0;k<suf[t].olen && k<sufwordlen
       && suf[t].original[k]==s2[sufwordlen-k-1];k++);
    if(k>=suf[t].olen) {
       if(sufwordlen>k) return -1; else return 0;
    else return suf[t].original[k]-s2[sufwordlen-k-1];

Here is the caller graph for this function:

void suffix ( char *  p,
char *  sdicname 

Definition at line 130 of file suffix.c.

    suffix_dic(sdicname); if(suffixcnt>0) suffix_translate(p);

Here is the call graph for this function:

Here is the caller graph for this function:

void suffix_dic ( char *  sdicname)

Definition at line 79 of file suffix.c.

    int i,l;
    FILE *suff;
    char *p1, *p2, *pp;
    long int flen;

    suffixcnt=0; sufminlen=100000;
    suff=fopen(sdicname,"r"); if(suff==NULL) return;
    fseek(suff,0,SEEK_END);flen=ftell(suff); fseek(suff,0,SEEK_SET);
    if(flen>sufbuflim) return;
    if(flen>0 && flen<sufbuflim) sufbuf[flen]=0;
    else return;
    for(i=0,p1=sufbuf;p1!=NULL && *p1!=0 && i<suflim;p1=p2) {
       p2=strchr(p1+1,'\n'); if(p2>p1) *p2++=0;
       pp=strchr(p1,':'); if(pp==NULL) continue;
       strip_trailing_spaces(p1); strip_trailing_spaces(pp);
       p1=find_word_start(p1); pp=find_word_start(pp);
       if(*p1==0) continue;
       suf[i].original=p1; suf[i].olen=l=strlen(p1);
       if(l<sufminlen) sufminlen=l;
       suf[i].replace=pp; i++;

Here is the call graph for this function:

Here is the caller graph for this function:

int suffix_list ( void *  list,
int  items,
size_t  item_size,
const char *  str 

Definition at line 48 of file suffix.c.

    int i1,i2,j,k,t,v;
    char c,d;
    if(items<=0) return -1;
    if(k==0) return 0; if(k>0) return -1;
    j=items-1; k=sufcomp(j,str);
    if(k==0) return j;
    if(k>0) for(i1=0,i2=j;i2>i1+1;) {
       j=i1+(i2-i1)/2;      k=sufcomp(j,str);
       if(k==0) return j;
       if(k>0) {i2=j; continue;}
       if(k<0) {i1=j; continue;}   
    if(k>0 && j>0) j--;
    v=j;for(t=0;t<suf[j].olen && t<sufwordlen
       && suf[j].original[t]==str[sufwordlen-t-1];t++);
    if(t<sufminlen) return -1; if(t>=suf[j].olen) return j;
       j>=0 && suf[j].original[0]==c && suf[j].olen>t
       && suf[j].original[t-1]==d;j--);
    if(j>=0 && suf[j].original[0]==c && 
      return j;
    else goto backcheck;

Here is the call graph for this function:

Here is the caller graph for this function:

void suffix_translate ( char *  p)

Definition at line 110 of file suffix.c.

    char *p1, *p2;
    int t;

       p1!=NULL && p1-p<MAX_LINELEN && *p1!=0;
       p1=p2) {
       if(!isalpha(*p1)) {p2=p1+1; continue;}
       if(*p2!=0 && strchr(" ,.?!'\"\n`:;()[]{}<>",*p2)==NULL) continue;
       if(t<0) continue;

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

struct { ... } suf[suflim]
char* sufbuf

Definition at line 28 of file suffix.c.

int suffixcnt

Definition at line 21 of file suffix.c.

int sufminlen

Definition at line 29 of file suffix.c.

Definition at line 29 of file suffix.c.