File: munch.h

package info (click to toggle)
myspell 1:3.0+pre3.1-24.2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 1,228 kB
  • ctags: 436
  • sloc: cpp: 5,985; sh: 1,250; ansic: 1,176; makefile: 222; perl: 81
file content (121 lines) | stat: -rw-r--r-- 2,446 bytes parent folder | download | duplicates (22)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* munch header file */

#define MAX_LN_LEN    200
#define MAX_WD_LEN    200
#define MAX_PREFIXES  256
#define MAX_SUFFIXES  256
#define MAX_ROOTS      20
#define MAX_WORDS     5000
 
#define ROTATE_LEN      5
 
#define ROTATE(v,q) \
   (v) = ((v) << (q)) | (((v) >> (32 - q)) & ((1 << (q))-1));

#define SET_SIZE      256

#define XPRODUCT  (1 << 0)

/* the affix table entry */

struct affent
{
    char *  appnd;
    char *  strip;
    short   appndl;
    short   stripl;
    char    achar;
    char    xpflg;   
    short   numconds;
    char    conds[SET_SIZE];
};


struct affixptr
{
    struct affent * aep;
    int		    num;
};

/* the prefix and suffix table */
int	numpfx;		/* Number of prefixes in table */
int     numsfx;		/* Number of suffixes in table */

/* the prefix table */
struct affixptr          ptable[MAX_PREFIXES];

/* the suffix table */
struct affixptr          stable[MAX_SUFFIXES];


/* data structure to store results of lookups */
struct matches
{
    struct hentry *	hashent;	/* hash table entry */
    struct affent *	prefix;		/* Prefix used, or NULL */
    struct affent *	suffix;		/* Suffix used, or NULL */
};

int    numroots;	          /* number of root words found */
struct matches  roots[MAX_ROOTS]; /* list of root words found */

/* hashing stuff */

struct hentry
{
  char * word;
  char * affstr;
  struct hentry * next;
  int keep;
};

 
int             tablesize;
struct hentry * tableptr;

/* unmunch stuff */

int    numwords;	          /* number of words found */
struct dwords
{
  char * word;
  int pallow;
};

struct dwords  wlist[MAX_WORDS]; /* list words found */


/* the routines */

void parse_aff_file(FILE* afflst);

void encodeit(struct affent * ptr, char * cs);

int load_tables(FILE * wrdlst);

int hash(const char *);

int add_word(char *);

struct hentry * lookup(const char *);

void aff_chk (const char * word, int len);

void pfx_chk (const char * word, int len, struct affent* ep, int num);

void suf_chk (const char * word, int len, struct affent * ep, int num, 
	      struct affent * pfxent, int cpflag);

void add_affix_char(struct hentry * hent, char ac);

int expand_rootword(const char *, int, const char*, int);

void pfx_add (const char * word, int len, struct affent* ep, int num);

void suf_add (const char * word, int len, struct affent * ep, int num);

char * mystrsep(char ** stringp, const char delim);

char * mystrdup(const char * s);

void mychomp(char * s);