|
Packit |
1184b9 |
#ifndef _MYTHES_HXX_
|
|
Packit |
1184b9 |
#define _MYTHES_HXX_
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
// some maximum sizes for buffers
|
|
Packit |
1184b9 |
#define MAX_WD_LEN 200
|
|
Packit |
1184b9 |
#define MAX_LN_LEN 16384
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
// a meaning with definition, count of synonyms and synonym list
|
|
Packit |
1184b9 |
struct mentry {
|
|
Packit |
1184b9 |
char* defn;
|
|
Packit |
1184b9 |
int count;
|
|
Packit |
1184b9 |
char** psyns;
|
|
Packit |
1184b9 |
};
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
class MyThes
|
|
Packit |
1184b9 |
{
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
int nw; /* number of entries in thesaurus */
|
|
Packit |
1184b9 |
char** list; /* stores word list */
|
|
Packit |
1184b9 |
unsigned int* offst; /* stores offset list */
|
|
Packit |
1184b9 |
char * encoding; /* stores text encoding; */
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
FILE *pdfile;
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
// disallow copy-constructor and assignment-operator for now
|
|
Packit |
1184b9 |
MyThes();
|
|
Packit |
1184b9 |
MyThes(const MyThes &);
|
|
Packit |
1184b9 |
MyThes & operator = (const MyThes &);
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
public:
|
|
Packit |
1184b9 |
MyThes(const char* idxpath, const char* datpath);
|
|
Packit |
1184b9 |
~MyThes();
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
// lookup text in index and return number of meanings
|
|
Packit |
1184b9 |
// each meaning entry has a defintion, synonym count and pointer
|
|
Packit |
1184b9 |
// when complete return the *original* meaning entry and count via
|
|
Packit |
1184b9 |
// CleanUpAfterLookup to properly handle memory deallocation
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
int Lookup(const char * pText, int len, mentry** pme);
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
void CleanUpAfterLookup(mentry** pme, int nmean);
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
char* get_th_encoding();
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
private:
|
|
Packit |
1184b9 |
// Open index and dat files and load list array
|
|
Packit |
1184b9 |
int thInitialize (const char* indxpath, const char* datpath);
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
// internal close and cleanup dat and idx files
|
|
Packit |
1184b9 |
void thCleanup ();
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
// read a text line (\n terminated) stripping off line terminator
|
|
Packit |
1184b9 |
int readLine(FILE * pf, char * buf, int nc);
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
// binary search on null terminated character strings
|
|
Packit |
1184b9 |
int binsearch(char * wrd, char* list[], int nlst);
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
// string duplication routine
|
|
Packit |
1184b9 |
char * mystrdup(const char * p);
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
// remove cross-platform text line end characters
|
|
Packit |
1184b9 |
void mychomp(char * s);
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
// return index of char in string
|
|
Packit |
1184b9 |
int mystr_indexOfChar(const char * d, int c);
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
};
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
#endif
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
|
|
Packit |
1184b9 |
|