Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Attributes | Private Attributes
PfxEntry Class Reference

#include <affentry.hxx>

Inheritance diagram for PfxEntry:
Inheritance graph
[legend]
Collaboration diagram for PfxEntry:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PfxEntry (AffixMgr *pmgr, affentry *dp)
 ~PfxEntry ()
struct hentrycheck (const char *word, int len)
bool allowCross ()
unsigned char getFlag ()
const char * getKey ()
char * add (const char *word, int len)
PfxEntrygetNext ()
PfxEntrygetNextNE ()
PfxEntrygetNextEQ ()
PfxEntrygetFlgNxt ()
void setNext (PfxEntry *ptr)
void setNextNE (PfxEntry *ptr)
void setNextEQ (PfxEntry *ptr)
void setFlgNxt (PfxEntry *ptr)

Protected Attributes

char * appnd
char * strip
short appndl
short stripl
short numconds
short xpflg
char achar
char conds [SETSIZE]

Private Attributes

AffixMgrpmyMgr
PfxEntrynext
PfxEntrynexteq
PfxEntrynextne
PfxEntryflgnxt

Detailed Description

Definition at line 11 of file affentry.hxx.


Constructor & Destructor Documentation

PfxEntry::PfxEntry ( AffixMgr pmgr,
affentry dp 
)

Definition at line 15 of file affentry.cpp.

{
  // register affix manager
  pmyMgr = pmgr;

  // set up its intial values
  achar = dp->achar;         // char flag 
  strip = dp->strip;         // string to strip
  appnd = dp->appnd;         // string to append
  stripl = dp->stripl;       // length of strip string
  appndl = dp->appndl;       // length of append string
  numconds = dp->numconds;   // number of conditions to match
  xpflg = dp->xpflg;         // cross product flag
  // then copy over all of the conditions
  memcpy(&conds[0],&dp->conds[0],SETSIZE*sizeof(conds[0]));
  next = NULL;
  nextne = NULL;
  nexteq = NULL;
}

Here is the call graph for this function:

Definition at line 36 of file affentry.cpp.

{
    achar = '\0';
    if (appnd) free(appnd);
    if (strip)free(strip);
    pmyMgr = NULL;
    appnd = NULL;
    strip = NULL;    
}

Member Function Documentation

char * PfxEntry::add ( const char *  word,
int  len 
)

Definition at line 49 of file affentry.cpp.

{
    int                     cond;
    char              tword[MAXWORDLEN+1];

     /* make sure all conditions match */
     if ((len > stripl) && (len >= numconds)) {
            unsigned char * cp = (unsigned char *) word;
            for (cond = 0;  cond < numconds;  cond++) {
              if ((conds[*cp++] & (1 << cond)) == 0)
                 break;
            }
            if (cond >= numconds) {
             /* we have a match so add prefix */
              int tlen = 0;
              if (appndl) {
                 strcpy(tword,appnd);
                  tlen += appndl;
               } 
               char * pp = tword + tlen;
               strcpy(pp, (word + stripl));
               return mystrdup(tword);
           }
     }
     return NULL;    
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool PfxEntry::allowCross ( ) [inline]

Definition at line 27 of file affentry.hxx.

{ return ((xpflg & XPRODUCT) != 0); }

Here is the caller graph for this function:

struct hentry * PfxEntry::check ( const char *  word,
int  len 
) [read]

Definition at line 80 of file affentry.cpp.

{
    int                     cond;  // condition number being examined
    int                       tmpl;   // length of tmpword
    struct hentry *     he;     // hash entry of root word or NULL
    unsigned char *  cp;           
    char              tmpword[MAXWORDLEN+1];


    // on entry prefix is 0 length or already matches the beginning of the word.
    // So if the remaining root word has positive length
    // and if there are enough chars in root word and added back strip chars
    // to meet the number of characters conditions, then test it

     tmpl = len - appndl;

     if ((tmpl > 0) &&  (tmpl + stripl >= numconds)) {

           // generate new root word by removing prefix and adding
           // back any characters that would have been stripped

           if (stripl) strcpy (tmpword, strip);
           strcpy ((tmpword + stripl), (word + appndl));

            // now make sure all of the conditions on characters
            // are met.  Please see the appendix at the end of
            // this file for more info on exactly what is being
            // tested

           cp = (unsigned char *)tmpword;
           for (cond = 0;  cond < numconds;  cond++) {
              if ((conds[*cp++] & (1 << cond)) == 0) break;
           }

            // if all conditions are met then check if resulting
            // root word in the dictionary

           if (cond >= numconds) {
              tmpl += stripl;
              if ((he = pmyMgr->lookup(tmpword)) != NULL) {
                 if (TESTAFF(he->astr, achar, he->alen)) return he;
              }

              // prefix matched but no root word was found 
                // if XPRODUCT is allowed, try again but now 
                // ross checked combined with a suffix

              if (xpflg & XPRODUCT) {
                 he = pmyMgr->suffix_check(tmpword, tmpl, XPRODUCT, (AffEntry *)this);
                   if (he) return he;
              }
           }
     }
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned char PfxEntry::getFlag ( ) [inline]

Definition at line 28 of file affentry.hxx.

{ return achar;   }

Here is the caller graph for this function:

Definition at line 35 of file affentry.hxx.

{ return flgnxt; }
const char* PfxEntry::getKey ( ) [inline]

Definition at line 29 of file affentry.hxx.

{ return appnd;  } 

Here is the caller graph for this function:

PfxEntry* PfxEntry::getNext ( ) [inline]

Definition at line 32 of file affentry.hxx.

{ return next;   }

Here is the caller graph for this function:

Definition at line 34 of file affentry.hxx.

{ return nexteq; }

Here is the caller graph for this function:

Definition at line 33 of file affentry.hxx.

{ return nextne; }

Here is the caller graph for this function:

void PfxEntry::setFlgNxt ( PfxEntry ptr) [inline]

Definition at line 40 of file affentry.hxx.

{ flgnxt = ptr; }

Here is the caller graph for this function:

void PfxEntry::setNext ( PfxEntry ptr) [inline]

Definition at line 37 of file affentry.hxx.

{ next = ptr;   }

Here is the caller graph for this function:

void PfxEntry::setNextEQ ( PfxEntry ptr) [inline]

Definition at line 39 of file affentry.hxx.

{ nexteq = ptr; }

Here is the caller graph for this function:

void PfxEntry::setNextNE ( PfxEntry ptr) [inline]

Definition at line 38 of file affentry.hxx.

{ nextne = ptr; }

Here is the caller graph for this function:


Member Data Documentation

char AffEntry::achar [protected, inherited]

Definition at line 13 of file baseaffix.hxx.

char* AffEntry::appnd [protected, inherited]

Definition at line 7 of file baseaffix.hxx.

short AffEntry::appndl [protected, inherited]

Definition at line 9 of file baseaffix.hxx.

char AffEntry::conds[SETSIZE] [protected, inherited]

Definition at line 14 of file baseaffix.hxx.

Definition at line 18 of file affentry.hxx.

Definition at line 15 of file affentry.hxx.

Definition at line 16 of file affentry.hxx.

Definition at line 17 of file affentry.hxx.

short AffEntry::numconds [protected, inherited]

Definition at line 11 of file baseaffix.hxx.

Definition at line 13 of file affentry.hxx.

char* AffEntry::strip [protected, inherited]

Definition at line 8 of file baseaffix.hxx.

short AffEntry::stripl [protected, inherited]

Definition at line 10 of file baseaffix.hxx.

short AffEntry::xpflg [protected, inherited]

Definition at line 12 of file baseaffix.hxx.


The documentation for this class was generated from the following files: