| 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 |
#include "swish.h" |
|---|
| 41 |
#include "check.h" |
|---|
| 42 |
#include "hash.h" |
|---|
| 43 |
#include "swstring.h" |
|---|
| 44 |
#include "mem.h" |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
int isokword(sw, word, indexf) |
|---|
| 57 |
SWISH *sw; |
|---|
| 58 |
char *word; |
|---|
| 59 |
IndexFILE *indexf; |
|---|
| 60 |
{ |
|---|
| 61 |
int i, |
|---|
| 62 |
same, |
|---|
| 63 |
hasnumber, |
|---|
| 64 |
hasvowel, |
|---|
| 65 |
hascons, |
|---|
| 66 |
numberrow, |
|---|
| 67 |
vowelrow, |
|---|
| 68 |
consrow, |
|---|
| 69 |
wordlen; |
|---|
| 70 |
char lastchar; |
|---|
| 71 |
|
|---|
| 72 |
if (word[0] == '\0') |
|---|
| 73 |
return 0; |
|---|
| 74 |
|
|---|
| 75 |
if ( is_word_in_hash_table( indexf->header.hashstoplist, word ) ) |
|---|
| 76 |
return 0; |
|---|
| 77 |
|
|---|
| 78 |
wordlen = strlen(word); |
|---|
| 79 |
if ((wordlen < indexf->header.minwordlimit) || (wordlen > indexf->header.maxwordlimit)) |
|---|
| 80 |
return 0; |
|---|
| 81 |
|
|---|
| 82 |
lastchar = '\0'; |
|---|
| 83 |
same = 0; |
|---|
| 84 |
hasnumber = hasvowel = hascons = 0; |
|---|
| 85 |
numberrow = vowelrow = consrow = 0; |
|---|
| 86 |
|
|---|
| 87 |
for (i = 0; word[i] != '\0'; i++) |
|---|
| 88 |
{ |
|---|
| 89 |
|
|---|
| 90 |
if (word[i] == lastchar) |
|---|
| 91 |
{ |
|---|
| 92 |
same++; |
|---|
| 93 |
if (same > IGNORESAME) |
|---|
| 94 |
return 0; |
|---|
| 95 |
} |
|---|
| 96 |
else |
|---|
| 97 |
same = 0; |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
if (isdigit((int) ( (unsigned char) word[i]))) |
|---|
| 101 |
{ |
|---|
| 102 |
hasnumber = 1; |
|---|
| 103 |
numberrow++; |
|---|
| 104 |
if (numberrow > IGNOREROWN) |
|---|
| 105 |
return 0; |
|---|
| 106 |
vowelrow = 0; |
|---|
| 107 |
consrow = 0; |
|---|
| 108 |
} |
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
else if (isvowel(sw, word[i])) |
|---|
| 112 |
{ |
|---|
| 113 |
hasvowel = 1; |
|---|
| 114 |
vowelrow++; |
|---|
| 115 |
if (vowelrow > IGNOREROWV) |
|---|
| 116 |
return 0; |
|---|
| 117 |
numberrow = 0; |
|---|
| 118 |
consrow = 0; |
|---|
| 119 |
} |
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
else if (!ispunct((int) ( (unsigned char) word[i]))) |
|---|
| 123 |
{ |
|---|
| 124 |
hascons = 1; |
|---|
| 125 |
consrow++; |
|---|
| 126 |
if (consrow > IGNOREROWC) |
|---|
| 127 |
return 0; |
|---|
| 128 |
numberrow = 0; |
|---|
| 129 |
vowelrow = 0; |
|---|
| 130 |
} |
|---|
| 131 |
lastchar = word[i]; |
|---|
| 132 |
} |
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
if (IGNOREALLV) |
|---|
| 136 |
if (hasvowel && !hascons) |
|---|
| 137 |
return 0; |
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
if (IGNOREALLC) |
|---|
| 141 |
if (hascons && !hasvowel) |
|---|
| 142 |
return 0; |
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
if (IGNOREALLN) |
|---|
| 146 |
if (hasnumber && !hasvowel && !hascons) |
|---|
| 147 |
return 0; |
|---|
| 148 |
|
|---|
| 149 |
return 1; |
|---|
| 150 |
} |
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
int getdoctype(char *filename, struct IndexContents *indexcontents) |
|---|
| 162 |
{ |
|---|
| 163 |
struct swline *swl; |
|---|
| 164 |
char *s, |
|---|
| 165 |
*fe; |
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
if (!indexcontents) |
|---|
| 169 |
return NODOCTYPE; |
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
fe = (filename + strlen(filename)); |
|---|
| 173 |
while (indexcontents) |
|---|
| 174 |
{ |
|---|
| 175 |
swl = indexcontents->patt; |
|---|
| 176 |
|
|---|
| 177 |
while (swl) |
|---|
| 178 |
{ |
|---|
| 179 |
s = fe - strlen(swl->line); |
|---|
| 180 |
if (s >= filename) |
|---|
| 181 |
{ |
|---|
| 182 |
if (!strcasecmp(swl->line, s)) |
|---|
| 183 |
{ |
|---|
| 184 |
return indexcontents->DocType;; |
|---|
| 185 |
} |
|---|
| 186 |
} |
|---|
| 187 |
swl = swl->next; |
|---|
| 188 |
} |
|---|
| 189 |
|
|---|
| 190 |
indexcontents = indexcontents->next; |
|---|
| 191 |
} |
|---|
| 192 |
|
|---|
| 193 |
return NODOCTYPE; |
|---|
| 194 |
} |
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
struct StoreDescription *hasdescription(int doctype, struct StoreDescription *sd) |
|---|
| 201 |
{ |
|---|
| 202 |
while (sd) |
|---|
| 203 |
{ |
|---|
| 204 |
if (sd->DocType == doctype) |
|---|
| 205 |
return sd; |
|---|
| 206 |
sd = sd->next; |
|---|
| 207 |
} |
|---|
| 208 |
return NULL; |
|---|
| 209 |
} |
|---|