Fix DJGPP build

This commit is contained in:
Stas Degteff
2006-05-14 18:37:26 +00:00
parent 717827510e
commit b322344dae
13 changed files with 452 additions and 430 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -63,20 +63,20 @@ Hunspell::~Hunspell()
// make a copy of src at destination while removing all leading
// blanks and removing any trailing periods after recording
// their presence with the abbreviation flag
// also since already going through character by character,
// also since already going through character by character,
// set the capitalization type
// return the length of the "cleaned" (and UTF-8 encoded) word
int Hunspell::cleanword2(char * dest, const char * src,
int Hunspell::cleanword2(char * dest, const char * src,
w_char * dest_utf, int * nc, int * pcaptype, int * pabbrev)
{
{
unsigned char * p = (unsigned char *) dest;
const unsigned char * q = (const unsigned char * ) src;
int firstcap = 0;
// first skip over any leading blanks
while ((*q != '\0') && (*q == ' ')) q++;
// now strip off any trailing periods (recording their presence)
*pabbrev = 0;
int nl = strlen((const char *)q);
@@ -84,9 +84,9 @@ int Hunspell::cleanword2(char * dest, const char * src,
nl--;
(*pabbrev)++;
}
// if no characters are left it can't be capitalized
if (nl <= 0) {
if (nl <= 0) {
*pcaptype = NOCAP;
*p = '\0';
return 0;
@@ -141,18 +141,18 @@ int Hunspell::cleanword2(char * dest, const char * src,
*pcaptype = HUHCAP;
}
return strlen(dest);
}
}
int Hunspell::cleanword(char * dest, const char * src,
int Hunspell::cleanword(char * dest, const char * src,
int * pcaptype, int * pabbrev)
{
{
unsigned char * p = (unsigned char *) dest;
const unsigned char * q = (const unsigned char * ) src;
int firstcap = 0;
// first skip over any leading blanks
while ((*q != '\0') && (*q == ' ')) q++;
// now strip off any trailing periods (recording their presence)
*pabbrev = 0;
int nl = strlen((const char *)q);
@@ -160,9 +160,9 @@ int Hunspell::cleanword(char * dest, const char * src,
nl--;
(*pabbrev)++;
}
// if no characters are left it can't be capitalized
if (nl <= 0) {
if (nl <= 0) {
*pcaptype = NOCAP;
*p = '\0';
return 0;
@@ -213,8 +213,8 @@ int Hunspell::cleanword(char * dest, const char * src,
*pcaptype = HUHCAP;
}
return strlen(dest);
}
}
void Hunspell::mkallcap(char * p)
{
@@ -231,7 +231,7 @@ void Hunspell::mkallcap(char * p)
}
u16_u8(p, MAXWORDUTF8LEN, u, nc);
} else {
while (*p != '\0') {
while (*p != '\0') {
*p = csconv[((unsigned char) *p)].cupper;
p++;
}
@@ -250,9 +250,9 @@ int Hunspell::mkallcap2(char * p, w_char * u, int nc)
}
}
u16_u8(p, MAXWORDUTF8LEN, u, nc);
return strlen(p);
return strlen(p);
} else {
while (*p != '\0') {
while (*p != '\0') {
*p = csconv[((unsigned char) *p)].cupper;
p++;
}
@@ -263,7 +263,7 @@ int Hunspell::mkallcap2(char * p, w_char * u, int nc)
void Hunspell::mkallsmall(char * p)
{
while (*p != '\0') {
while (*p != '\0') {
*p = csconv[((unsigned char) *p)].clower;
p++;
}
@@ -283,7 +283,7 @@ int Hunspell::mkallsmall2(char * p, w_char * u, int nc)
u16_u8(p, MAXWORDUTF8LEN, u, nc);
return strlen(p);
} else {
while (*p != '\0') {
while (*p != '\0') {
*p = csconv[((unsigned char) *p)].clower;
p++;
}
@@ -308,10 +308,10 @@ hentry * Hunspell::spellsharps(char * base, char * pos, int n, int repnum, char
hentry * h;
*pos = '<EFBFBD>';
*(pos + 1) = '<EFBFBD>';
if (h = spellsharps(base, pos + 2, n + 1, repnum + 1, tmp)) return h;
if ((h = spellsharps(base, pos + 2, n + 1, repnum + 1, tmp))) return h;
*pos = 's';
*(pos + 1) = 's';
if (h = spellsharps(base, pos + 2, n + 1, repnum, tmp)) return h;
if ((h = spellsharps(base, pos + 2, n + 1, repnum, tmp))) return h;
} else if (repnum > 0) {
if (utf8) return check(base);
return check(sharps_u8_l1(tmp, base));
@@ -347,7 +347,7 @@ int Hunspell::spell(const char * word)
char wspace[MAXWORDUTF8LEN + 4];
w_char unicw[MAXWORDLEN + 1];
int nc = strlen(word);
int wl2;
int wl2=0;
if (utf8) {
if (nc >= MAXWORDUTF8LEN) return 0;
} else {
@@ -363,11 +363,11 @@ int Hunspell::spell(const char * word)
enum { NBEGIN, NNUM, NSEP };
int nstate = NBEGIN;
int i;
for (i = 0; (i < wl) &&
for (i = 0; (i < wl) &&
(((cw[i] <= '9') && (cw[i] >= '0') && (nstate = NNUM)) ||
((nstate == NNUM) && ((cw[i] == ',') ||
(cw[i] == '.') || (cw[i] == '-')) && (nstate = NSEP))); i++);
(cw[i] == '.') || (cw[i] == '-')) && (nstate = NSEP))); i++);
if ((i == wl) && (nstate == NNUM)) return 1;
// LANG_hu section: number(s) + (percent or degree) with suffixes
@@ -377,10 +377,10 @@ int Hunspell::spell(const char * word)
// END of LANG_hu section
switch(captype) {
case HUHCAP:
case HUHINITCAP:
case NOCAP: {
rv = check(cw);
case HUHCAP:
case HUHINITCAP:
case NOCAP: {
rv = check(cw);
if ((abbv) && !(rv)) {
memcpy(wspace,cw,wl);
*(wspace+wl) = '.';
@@ -422,14 +422,14 @@ int Hunspell::spell(const char * word)
if (rv) break;
}
}
case INITCAP: {
case INITCAP: {
wl = mkallsmall2(cw, unicw, nc);
memcpy(wspace,cw,(wl+1));
memcpy(wspace,cw,(wl+1));
rv = check(wspace);
if (!rv || (is_keepcase(rv) && !((captype == INITCAP) &&
// if CHECKSHARPS: KEEPCASE words with <20> are allowed
// in INITCAP form, too.
pAMgr->get_checksharps() && ((utf8 && strstr(wspace, "ß")) ||
pAMgr->get_checksharps() && ((utf8 && strstr(wspace, "ß")) ||
(!utf8 && strchr(wspace, '<EFBFBD>')))))) {
wl2 = mkinitcap2(cw, unicw, nc);
rv = check(cw);
@@ -448,9 +448,9 @@ int Hunspell::spell(const char * word)
}
}
break;
}
}
}
if (rv) return 1;
// recursive breaking at break points (not good for morphological analysis)
@@ -458,7 +458,7 @@ int Hunspell::spell(const char * word)
char * s;
char r;
for (int i = 0; i < pAMgr->get_numbreak(); i++) {
if (s=(char *) strstr(cw, wordbreak[i])) {
if ((s=(char *) strstr(cw, wordbreak[i]))) {
r = *s;
*s = '\0';
// examine 2 sides of the break point
@@ -488,7 +488,7 @@ int Hunspell::spell(const char * word)
*dash = '<EFBFBD>';
}
if ((dash=(char *) strchr(cw,'-'))) {
*dash='\0';
*dash='\0';
// examine 2 sides of the dash
if (dash[1] == '\0') { // base word ending with dash
if (spell(cw)) return 1;
@@ -581,17 +581,17 @@ struct hentry * Hunspell::check(const char * w)
}
prevroot = he->word;
} else if (pAMgr->get_compound()) {
he = pAMgr->compound_check(word, len,
he = pAMgr->compound_check(word, len,
0,0,100,0,NULL,0,NULL,NULL,0);
// LANG_hu section: `moving rule' with last dash
if ((!he) && (langnum == LANG_hu) && (word[len-1]=='-')) {
char * dup = mystrdup(word);
dup[len-1] = '\0';
he = pAMgr->compound_check(dup, len-1,
he = pAMgr->compound_check(dup, len-1,
-5,0,100,0,NULL,1,NULL,NULL,0);
free(dup);
}
// end of LANG speficic region
// end of LANG speficic region
if (he) {
prevroot = he->word;
prevcompound = 1;
@@ -625,12 +625,12 @@ int Hunspell::suggest(char*** slst, const char * word)
int ngramsugs = 0;
switch(captype) {
case NOCAP: {
case NOCAP: {
ns = pSMgr->suggest(slst, cw, ns);
break;
}
case INITCAP: {
case INITCAP: {
capwords = 1;
ns = pSMgr->suggest(slst, cw, ns);
if (ns == -1) break;
@@ -641,7 +641,7 @@ int Hunspell::suggest(char*** slst, const char * word)
}
case HUHINITCAP:
capwords = 1;
case HUHCAP: {
case HUHCAP: {
ns = pSMgr->suggest(slst, cw, ns);
if (ns != -1) {
int prevns;
@@ -664,7 +664,7 @@ int Hunspell::suggest(char*** slst, const char * word)
// aNew -> "a New" (instead of "a new")
for (int j = prevns; j < ns; j++) {
char * space;
if (space = strchr((*slst)[j],' ')) {
if ( (space = strchr((*slst)[j],' ')) ) {
int slen = strlen(space + 1);
// different case after space (need capitalisation)
if ((slen < wl) && strcmp(cw + wl - slen, space + 1)) {
@@ -683,7 +683,7 @@ int Hunspell::suggest(char*** slst, const char * word)
break;
}
case ALLCAP: {
case ALLCAP: {
memcpy(wspace, cw, (wl+1));
mkallsmall2(wspace, unicw, nc);
ns = pSMgr->suggest(slst, wspace, ns);
@@ -696,12 +696,12 @@ int Hunspell::suggest(char*** slst, const char * word)
if (pAMgr && pAMgr->get_checksharps()) {
char * pos;
if (utf8) {
while (pos = strstr((*slst)[j], "ß")) {
while ( (pos = strstr((*slst)[j], "ß")) ) {
*pos = 'S';
*(pos+1) = 'S';
}
} else {
while (pos = strchr((*slst)[j], '<EFBFBD>')) {
while ( (pos = strchr((*slst)[j], '<EFBFBD>')) ) {
(*slst)[j] = (char *) realloc((*slst)[j], strlen((*slst)[j]) + 2);
mystrrep((*slst)[j], "<EFBFBD>", "SS");
}
@@ -735,7 +735,7 @@ int Hunspell::suggest(char*** slst, const char * word)
ns = pSMgr->ngsuggest(*slst, wspace, pHMgr);
break;
}
case INITCAP: {
case INITCAP: {
capwords = 1;
memcpy(wspace,cw,(wl+1));
mkallsmall2(wspace, unicw, nc);
@@ -746,7 +746,7 @@ int Hunspell::suggest(char*** slst, const char * word)
memcpy(wspace,cw,(wl+1));
mkallsmall2(wspace, unicw, nc);
ns = pSMgr->ngsuggest(*slst, wspace, pHMgr);
for (int j=0; j < ns; j++)
for (int j=0; j < ns; j++)
mkallcap((*slst)[j]);
break;
}
@@ -790,13 +790,13 @@ int Hunspell::suggest(char*** slst, const char * word)
strcpy(s, (*slst)[j]);
len = strlen(s);
}
int wl = mkallsmall2(s, w, len);
free((*slst)[j]);
mkallsmall2(s, w, len);
free((*slst)[j]);
if (spell(s)) {
(*slst)[l] = mystrdup(s);
l++;
} else {
int wl = mkinitcap2(s, w, len);
mkinitcap2(s, w, len);
if (spell(s)) {
(*slst)[l] = mystrdup(s);
l++;
@@ -805,7 +805,7 @@ int Hunspell::suggest(char*** slst, const char * word)
} else {
(*slst)[l] = (*slst)[j];
l++;
}
}
}
ns = l;
}
@@ -845,15 +845,15 @@ int Hunspell::suggest_auto(char*** slst, const char * word)
if (wl == 0) return 0;
int ns = 0;
*slst = NULL; // HU, nsug in pSMgr->suggest
switch(captype) {
case NOCAP: {
case NOCAP: {
ns = pSMgr->suggest_auto(slst, cw, ns);
if (ns>0) break;
break;
}
case INITCAP: {
case INITCAP: {
memcpy(wspace,cw,(wl+1));
mkallsmall(wspace);
ns = pSMgr->suggest_auto(slst, wspace, ns);
@@ -861,10 +861,10 @@ int Hunspell::suggest_auto(char*** slst, const char * word)
mkinitcap((*slst)[j]);
ns = pSMgr->suggest_auto(slst, cw, ns);
break;
}
case HUHCAP: {
case HUHCAP: {
ns = pSMgr->suggest_auto(slst, cw, ns);
if (ns == 0) {
memcpy(wspace,cw,(wl+1));
@@ -874,7 +874,7 @@ int Hunspell::suggest_auto(char*** slst, const char * word)
break;
}
case ALLCAP: {
case ALLCAP: {
memcpy(wspace,cw,(wl+1));
mkallsmall(wspace);
ns = pSMgr->suggest_auto(slst, wspace, ns);
@@ -929,14 +929,14 @@ int Hunspell::stem(char*** slst, const char * word)
int abbv = 0;
wl = cleanword(cw, word, &captype, &abbv);
if (wl == 0) return 0;
int ns = 0;
*slst = NULL; // HU, nsug in pSMgr->suggest
switch(captype) {
case HUHCAP:
case NOCAP: {
case NOCAP: {
ns = pSMgr->suggest_stems(slst, cw, ns);
if ((abbv) && (ns == 0)) {
@@ -949,7 +949,7 @@ int Hunspell::stem(char*** slst, const char * word)
break;
}
case INITCAP: {
case INITCAP: {
ns = pSMgr->suggest_stems(slst, cw, ns);
@@ -967,15 +967,15 @@ int Hunspell::stem(char*** slst, const char * word)
*(wspace+wl+1) = '\0';
ns = pSMgr->suggest_stems(slst, wspace, ns);
}
break;
}
case ALLCAP: {
case ALLCAP: {
ns = pSMgr->suggest_stems(slst, cw, ns);
if (ns != 0) break;
memcpy(wspace,cw,(wl+1));
mkallsmall(wspace);
ns = pSMgr->suggest_stems(slst, wspace, ns);
@@ -997,7 +997,7 @@ int Hunspell::stem(char*** slst, const char * word)
break;
}
}
return ns;
}
@@ -1016,14 +1016,14 @@ int Hunspell::suggest_pos_stems(char*** slst, const char * word)
int abbv = 0;
wl = cleanword(cw, word, &captype, &abbv);
if (wl == 0) return 0;
int ns = 0; // ns=0 = normalized input
*slst = NULL; // HU, nsug in pSMgr->suggest
switch(captype) {
case HUHCAP:
case NOCAP: {
case NOCAP: {
ns = pSMgr->suggest_pos_stems(slst, cw, ns);
if ((abbv) && (ns == 0)) {
@@ -1036,7 +1036,7 @@ int Hunspell::suggest_pos_stems(char*** slst, const char * word)
break;
}
case INITCAP: {
case INITCAP: {
ns = pSMgr->suggest_pos_stems(slst, cw, ns);
@@ -1045,15 +1045,15 @@ int Hunspell::suggest_pos_stems(char*** slst, const char * word)
mkallsmall(wspace);
ns = pSMgr->suggest_pos_stems(slst, wspace, ns);
}
break;
}
case ALLCAP: {
case ALLCAP: {
ns = pSMgr->suggest_pos_stems(slst, cw, ns);
if (ns != 0) break;
memcpy(wspace,cw,(wl+1));
mkallsmall(wspace);
ns = pSMgr->suggest_pos_stems(slst, wspace, ns);
@@ -1206,7 +1206,7 @@ char * Hunspell::morph(const char * word)
char result[MAXLNLEN];
char * st = NULL;
*result = '\0';
int n = 0;
@@ -1216,11 +1216,11 @@ char * Hunspell::morph(const char * word)
// test numbers
// LANG_hu section: set dash information for suggestions
if (langnum == LANG_hu) {
while ((n < wl) &&
while ((n < wl) &&
(((cw[n] <= '9') && (cw[n] >= '0')) || (((cw[n] == '.') || (cw[n] == ',')) && (n > 0)))) {
n++;
if ((cw[n] == '.') || (cw[n] == ',')) {
if (((n2 == 0) && (n > 3)) ||
if (((n2 == 0) && (n > 3)) ||
((n2 > 0) && ((cw[n-1] == '.') || (cw[n-1] == ',')))) break;
n2++;
n3 = n;
@@ -1257,9 +1257,9 @@ char * Hunspell::morph(const char * word)
}
}
// END OF LANG_hu section
switch(captype) {
case NOCAP: {
case NOCAP: {
st = pSMgr->suggest_morph(cw);
if (st) {
strcat(result, st);
@@ -1278,14 +1278,14 @@ char * Hunspell::morph(const char * word)
}
break;
}
case INITCAP: {
case INITCAP: {
memcpy(wspace,cw,(wl+1));
mkallsmall(wspace);
st = pSMgr->suggest_morph(wspace);
if (st) {
strcat(result, st);
free(st);
}
}
st = pSMgr->suggest_morph(cw);
if (st) {
if (*result) strcat(result, "\n");
@@ -1313,7 +1313,7 @@ char * Hunspell::morph(const char * word)
}
break;
}
case HUHCAP: {
case HUHCAP: {
st = pSMgr->suggest_morph(cw);
if (st) {
strcat(result, st);
@@ -1331,13 +1331,13 @@ char * Hunspell::morph(const char * word)
#endif
break;
}
case ALLCAP: {
case ALLCAP: {
memcpy(wspace,cw,(wl+1));
st = pSMgr->suggest_morph(wspace);
if (st) {
strcat(result, st);
free(st);
}
}
mkallsmall(wspace);
st = pSMgr->suggest_morph(wspace);
if (st) {
@@ -1361,7 +1361,7 @@ char * Hunspell::morph(const char * word)
if (st) {
strcat(result, st);
free(st);
}
}
mkallsmall(wspace);
st = pSMgr->suggest_morph(wspace);
if (st) {
@@ -1394,7 +1394,7 @@ char * Hunspell::morph(const char * word)
int nresult = 0;
// LANG_hu section: set dash information for suggestions
if ((langnum == LANG_hu) && (dash=(char *) strchr(cw,'-'))) {
*dash='\0';
*dash='\0';
// examine 2 sides of the dash
if (dash[1] == '\0') { // base word ending with dash
if (spell(cw)) return pSMgr->suggest_morph(cw);
@@ -1438,7 +1438,7 @@ char * Hunspell::morph(const char * word)
}
}
// affixed number in correct word
if (nresult && (dash > cw) && (((*(dash-1)<='9') &&
if (nresult && (dash > cw) && (((*(dash-1)<='9') &&
(*(dash-1)>='0')) || (*(dash-1)=='.'))) {
*dash='-';
n = 1;
@@ -1487,12 +1487,12 @@ char * Hunspell::morph_with_correction(const char * word)
char result[MAXLNLEN];
char * st = NULL;
*result = '\0';
switch(captype) {
case NOCAP: {
case NOCAP: {
st = pSMgr->suggest_morph_for_spelling_error(cw);
if (st) {
strcat(result, st);
@@ -1511,14 +1511,14 @@ char * Hunspell::morph_with_correction(const char * word)
}
break;
}
case INITCAP: {
case INITCAP: {
memcpy(wspace,cw,(wl+1));
mkallsmall(wspace);
st = pSMgr->suggest_morph_for_spelling_error(wspace);
if (st) {
strcat(result, st);
free(st);
}
}
st = pSMgr->suggest_morph_for_spelling_error(cw);
if (st) {
if (*result) strcat(result, "\n");
@@ -1546,7 +1546,7 @@ char * Hunspell::morph_with_correction(const char * word)
}
break;
}
case HUHCAP: {
case HUHCAP: {
st = pSMgr->suggest_morph_for_spelling_error(cw);
if (st) {
strcat(result, st);
@@ -1559,16 +1559,16 @@ char * Hunspell::morph_with_correction(const char * word)
if (*result) strcat(result, "\n");
strcat(result, st);
free(st);
}
}
break;
}
case ALLCAP: {
case ALLCAP: {
memcpy(wspace,cw,(wl+1));
st = pSMgr->suggest_morph_for_spelling_error(wspace);
if (st) {
strcat(result, st);
free(st);
}
}
mkallsmall(wspace);
st = pSMgr->suggest_morph_for_spelling_error(wspace);
if (st) {
@@ -1592,7 +1592,7 @@ char * Hunspell::morph_with_correction(const char * word)
if (st) {
strcat(result, st);
free(st);
}
}
mkallsmall(wspace);
st = pSMgr->suggest_morph_for_spelling_error(wspace);
if (st) {
@@ -1617,7 +1617,7 @@ char * Hunspell::morph_with_correction(const char * word)
}
/* analyze word
* return line count
* return line count
* XXX need a better data structure for morphological analysis */
int Hunspell::analyze(char ***out, const char *word) {
int n = 0;
@@ -1635,7 +1635,7 @@ int Hunspell::analyze(char ***out, const char *word) {
strncpy((*out)[n++], m + p, i - p + 1);
if (m[i] == '\n') (*out)[n++][i - p] = '\0';
if(!m[i+1]) break;
p = i + 1;
p = i + 1;
}
}
free(m);

View File

@@ -13,11 +13,11 @@ using namespace std;
#endif
SuggestMgr::SuggestMgr(const char * tryme, int maxn,
SuggestMgr::SuggestMgr(const char * tryme, int maxn,
AffixMgr * aptr)
{
// register affix manager and check in string of chars to
// register affix manager and check in string of chars to
// try when building candidate suggestions
pAMgr = aptr;
@@ -44,9 +44,9 @@ SuggestMgr::SuggestMgr(const char * tryme, int maxn,
complexprefixes = pAMgr->get_complexprefixes();
}
if (tryme) {
if (tryme) {
if (utf8) {
w_char t[MAXSWL];
w_char t[MAXSWL];
ctryl = u8_u16(t, MAXSWL, tryme);
ctry_utf = (w_char *) malloc(ctryl * sizeof(w_char));
memcpy(ctry_utf, t, ctryl * sizeof(w_char));
@@ -77,9 +77,9 @@ SuggestMgr::~SuggestMgr()
int SuggestMgr::suggest(char*** slst, const char * w, int nsug)
{
int nocompoundtwowords = 0;
char ** wlst;
char ** wlst;
w_char word_utf[MAXSWL];
int wl;
int wl=0;
char w2[MAXWORDUTF8LEN];
const char * word = w;
@@ -90,7 +90,7 @@ int SuggestMgr::suggest(char*** slst, const char * w, int nsug)
if (utf8) reverseword_utf(w2); else reverseword(w2);
word = w2;
}
if (*slst) {
wlst = *slst;
} else {
@@ -98,7 +98,7 @@ int SuggestMgr::suggest(char*** slst, const char * w, int nsug)
if (wlst == NULL) return -1;
for (int i = 0; i < maxSug; i++) wlst[i] = NULL;
}
if (utf8) {
wl = u8_u16(word_utf, MAXSWL, word);
}
@@ -201,7 +201,7 @@ int SuggestMgr::suggest_auto(char*** slst, const char * w, int nsug)
if ((nsug < maxSug) && (nsug > -1) && check_forbidden(word, strlen(word))) {
nsug = twowords(wlst, word, nsug, cpdsuggest);
}
} // repeating ``for'' statement compounding support
if (nsug < 0) {
@@ -221,7 +221,7 @@ int SuggestMgr::mapchars(char** wlst, const char * word, int ns, int cpdsuggest)
{
time_t timelimit;
int timer;
int wl = strlen(word);
if (wl < 2 || ! pAMgr) return ns;
@@ -242,13 +242,13 @@ int SuggestMgr::mapchars(char** wlst, const char * word, int ns, int cpdsuggest)
int SuggestMgr::map_related(const char * word, int i, char** wlst, int ns,
const mapentry* maptable, int nummap, int * timer, time_t * timelimit)
{
char c = *(word + i);
char c = *(word + i);
if (c == 0) {
int cwrd = 1;
int wl;
for (int m=0; m < ns; m++)
if (strcmp(word,wlst[m]) == 0) cwrd = 0;
if ((cwrd) && (wl = strlen(word)) && (check(word, wl, 0, timer, timelimit) ||
if ((cwrd) && (wl = strlen(word)) && (check(word, wl, 0, timer, timelimit) ||
check(word, wl, 1, timer, timelimit))) {
if (ns < maxSug) {
wlst[ns] = mystrdup(word);
@@ -257,7 +257,7 @@ int SuggestMgr::map_related(const char * word, int i, char** wlst, int ns,
}
}
return ns;
}
}
int in_map = 0;
for (int j = 0; j < nummap; j++) {
if (strchr(maptable[j].set,c) != 0) {
@@ -279,7 +279,7 @@ int SuggestMgr::map_related(const char * word, int i, char** wlst, int ns,
}
int SuggestMgr::map_related_utf(w_char * word, int len, int i, char** wlst, int ns,
const mapentry* maptable, int nummap, int * timer, time_t * timelimit)
const mapentry* maptable, int nummap, int * timer, time_t * timelimit)
{
if (i == len) {
int cwrd = 1;
@@ -288,7 +288,7 @@ int SuggestMgr::map_related_utf(w_char * word, int len, int i, char** wlst, int
u16_u8(s, MAXSWUTF8L, word, len);
for (int m=0; m < ns; m++)
if (strcmp(s,wlst[m]) == 0) cwrd = 0;
if ((cwrd) && (wl = strlen(s)) && (check(s, wl, 0, timer, timelimit) ||
if ((cwrd) && (wl = strlen(s)) && (check(s, wl, 0, timer, timelimit) ||
check(s, wl, 1, timer, timelimit))) {
if (ns < maxSug) {
wlst[ns] = mystrdup(s);
@@ -297,7 +297,7 @@ int SuggestMgr::map_related_utf(w_char * word, int len, int i, char** wlst, int
}
}
return ns;
}
}
int in_map = 0;
unsigned short c = *((unsigned short *) word + i);
for (int j = 0; j < nummap; j++) {
@@ -449,7 +449,7 @@ int SuggestMgr::badchar_utf(char ** wlst, const w_char * word, int wl, int ns, i
int cwrd;
time_t timelimit = time(NULL);
int timer = MINTIMER;
memcpy(candidate_utf, word, wl * sizeof(w_char));
// swap out each char one by one and try all the tryme
@@ -477,7 +477,7 @@ int SuggestMgr::badchar_utf(char ** wlst, const w_char * word, int wl, int ns, i
return ns;
}
// error is word has an extra letter it does not need
// error is word has an extra letter it does not need
int SuggestMgr::extrachar_utf(char** wlst, const w_char * word, int wl, int ns, int cpdsuggest)
{
char candidate[MAXSWUTF8L];
@@ -493,7 +493,7 @@ int SuggestMgr::extrachar_utf(char** wlst, const w_char * word, int wl, int ns,
memcpy(candidate_utf, word + 1, (wl - 1) * sizeof(w_char));
for (p = word, r = candidate_utf; p < word + wl; ) {
cwrd = 1;
u16_u8(candidate, MAXSWUTF8L, candidate_utf, wl - 1);
u16_u8(candidate, MAXSWUTF8L, candidate_utf, wl - 1);
for (int k=0; k < ns; k++)
if (strcmp(candidate,wlst[k]) == 0) cwrd = 0;
if ((cwrd) && check(candidate, strlen(candidate), cpdsuggest, NULL, NULL)) {
@@ -501,14 +501,14 @@ int SuggestMgr::extrachar_utf(char** wlst, const w_char * word, int wl, int ns,
wlst[ns] = mystrdup(candidate);
if (wlst[ns] == NULL) return -1;
ns++;
} else return ns;
} else return ns;
}
*r++ = *p++;
}
return ns;
}
// error is word has an extra letter it does not need
// error is word has an extra letter it does not need
int SuggestMgr::extrachar(char** wlst, const char * word, int ns, int cpdsuggest)
{
char candidate[MAXSWUTF8L];
@@ -530,7 +530,7 @@ int SuggestMgr::extrachar(char** wlst, const char * word, int ns, int cpdsuggest
wlst[ns] = mystrdup(candidate);
if (wlst[ns] == NULL) return -1;
ns++;
} else return ns;
} else return ns;
}
*r++ = *p++;
}
@@ -563,7 +563,7 @@ int SuggestMgr::forgotchar(char ** wlst, const char * word, int ns, int cpdsugge
wlst[ns] = mystrdup(candidate);
if (wlst[ns] == NULL) return -1;
ns++;
} else return ns;
} else return ns;
}
if (!timelimit) return ns;
}
@@ -612,7 +612,7 @@ int SuggestMgr::forgotchar_utf(char ** wlst, const w_char * word, int wl, int ns
wlst[ns] = mystrdup(candidate);
if (wlst[ns] == NULL) return -1;
ns++;
} else return ns;
} else return ns;
}
if (!timelimit) return ns;
}
@@ -648,7 +648,7 @@ int SuggestMgr::twowords(char ** wlst, const char * word, int ns, int cpdsuggest
int wl=strlen(word);
if (wl < 3) return ns;
if (pAMgr->get_langnum() == LANG_hu) forbidden = check_forbidden(word, wl);
strcpy(candidate + 1, word);
@@ -797,13 +797,13 @@ int SuggestMgr::ngsuggest(char** wlst, char * w, HashMgr* pHMgr)
int col = -1;
while ((hp = pHMgr->walk_hashtable(col, hp))) {
// check forbidden words
if ((hp->astr) && (pAMgr) &&
if ((hp->astr) && (pAMgr) &&
(TESTAFF(hp->astr, pAMgr->get_forbiddenword(), hp->alen) ||
TESTAFF(hp->astr, pAMgr->get_nosuggest(), hp->alen) ||
TESTAFF(hp->astr, pAMgr->get_onlyincompound(), hp->alen))) continue;
sc = ngram(3, word, hp->word, NGRAM_LONGER_WORSE);
if (sc > scores[lp]) {
scores[lp] = sc;
scores[lp] = sc;
roots[lp] = hp;
int lval = sc;
for (j=0; j < MAX_ROOTS; j++)
@@ -811,7 +811,7 @@ int SuggestMgr::ngsuggest(char** wlst, char * w, HashMgr* pHMgr)
lp = j;
lval = scores[j];
}
}
}
}
// find minimum threshhold for a passable suggestion
@@ -868,7 +868,7 @@ int SuggestMgr::ngsuggest(char** wlst, char * w, HashMgr* pHMgr)
lp = j;
lval = gscore[j];
}
} else free (glst[k].word);
} else free (glst[k].word);
} else free(glst[k].word);
}
}
@@ -877,7 +877,7 @@ int SuggestMgr::ngsuggest(char** wlst, char * w, HashMgr* pHMgr)
// now we are done generating guesses
// sort in order of decreasing score
bubblesort(&guess[0], &gscore[0], MAX_GUESS);
// weight suggestions with a similarity index, based on
@@ -907,7 +907,7 @@ int SuggestMgr::ngsuggest(char** wlst, char * w, HashMgr* pHMgr)
gscore[i] += 2000;
break;
}
// heuristic weigthing of ngram scores
gscore[i] +=
// length of longest common subsequent minus lenght difference
@@ -935,7 +935,7 @@ int SuggestMgr::ngsuggest(char** wlst, char * w, HashMgr* pHMgr)
if (gscore[i] > 1000) same = 1;
for (j=0; j < ns; j++)
// don't suggest previous suggestions or a previous suggestion with prefixes or affixes
if (strstr(guess[i], wlst[j]) ||
if (strstr(guess[i], wlst[j]) ||
// check forbidden words
!check(guess[i], strlen(guess[i]), 0, NULL, NULL)) unique = 0;
if (unique) wlst[ns++] = guess[i]; else free(guess[i]);
@@ -957,7 +957,7 @@ int SuggestMgr::check(const char * word, int len, int cpdsuggest, int * timer, t
{
struct hentry * rv=NULL;
int nosuffix = 0;
// check time limit
if (timer) {
(*timer)--;
@@ -969,8 +969,8 @@ int SuggestMgr::check(const char * word, int len, int cpdsuggest, int * timer, t
*timer = MAXPLUSTIMER;
}
}
if (pAMgr) {
if (pAMgr) {
if (cpdsuggest==1) {
if (pAMgr->get_compound()) {
rv = pAMgr->compound_check(word,len,0,0,0,0,NULL,0,NULL,NULL,1);
@@ -987,7 +987,7 @@ int SuggestMgr::check(const char * word, int len, int cpdsuggest, int * timer, t
if (rv->astr && (TESTAFF(rv->astr,pAMgr->get_pseudoroot(),rv->alen) ||
TESTAFF(rv->astr,pAMgr->get_onlyincompound(),rv->alen))) rv = NULL;
} else rv = pAMgr->prefix_check(word, len, 0); // only prefix, and prefix + suffix XXX
if (rv) {
nosuffix=1;
} else {
@@ -1004,9 +1004,9 @@ int SuggestMgr::check(const char * word, int len, int cpdsuggest, int * timer, t
|| TESTAFF(rv->astr,pAMgr->get_nosuggest(),rv->alen) ||
TESTAFF(rv->astr,pAMgr->get_onlyincompound(),rv->alen))) return 0;
if (rv) { // XXX obsolote
if ((pAMgr->get_compoundflag()) &&
TESTAFF(rv->astr, pAMgr->get_compoundflag(), rv->alen)) return 2 + nosuffix;
if (rv) { // XXX obsolote
if ((pAMgr->get_compoundflag()) &&
TESTAFF(rv->astr, pAMgr->get_compoundflag(), rv->alen)) return 2 + nosuffix;
return 1;
}
}
@@ -1017,7 +1017,7 @@ int SuggestMgr::check_forbidden(const char * word, int len)
{
struct hentry * rv = NULL;
if (pAMgr) {
if (pAMgr) {
rv = pAMgr->lookup(word);
if (rv && rv->astr && (TESTAFF(rv->astr,pAMgr->get_pseudoroot(),rv->alen) ||
TESTAFF(rv->astr,pAMgr->get_onlyincompound(),rv->alen))) rv = NULL;
@@ -1033,7 +1033,7 @@ int SuggestMgr::check_forbidden(const char * word, int len)
int SuggestMgr::suggest_stems(char*** slst, const char * w, int nsug)
{
char buf[MAXSWUTF8L];
char ** wlst;
char ** wlst;
int prevnsug = nsug;
char w2[MAXWORDUTF8LEN];
@@ -1054,7 +1054,7 @@ int SuggestMgr::suggest_stems(char*** slst, const char * w, int nsug)
}
// perhaps there are a fix stem in the dictionary
if ((nsug < maxSug) && (nsug > -1)) {
nsug = fixstems(wlst, word, nsug);
if (nsug == prevnsug) {
char * s = mystrdup(word);
@@ -1080,7 +1080,7 @@ int SuggestMgr::suggest_stems(char*** slst, const char * w, int nsug)
free(s);
}
}
if (nsug < 0) {
for (int i=0;i<maxSug; i++)
if (wlst[i] != NULL) free(wlst[i]);
@@ -1110,12 +1110,12 @@ int SuggestMgr::fixstems(char ** wlst, const char * word, int ns)
int cmpdstemnum;
int cmpdstem[MAXCOMPOUND];
if (pAMgr) {
if (pAMgr) {
rv = pAMgr->lookup(word);
if (rv) {
dicstem = 0;
} else {
// try stripping off affixes
// try stripping off affixes
rv = pAMgr->affix_check(word, wl);
// else try check compound word
@@ -1139,7 +1139,7 @@ int SuggestMgr::fixstems(char ** wlst, const char * word, int ns)
}
// XXX obsolote, will be a general solution for stemming
if ((prefix) && (strncmp(prefix, "leg", 3)==0)) prefix[0] = '\0'; // (HU)
if ((prefix) && (strncmp(prefix, "leg", 3)==0)) prefix[0] = '\0'; // (HU)
}
}
@@ -1147,10 +1147,10 @@ int SuggestMgr::fixstems(char ** wlst, const char * word, int ns)
if ((rv) && (ns < maxSug)) {
// check fixstem flag and not_valid_stem flag
// first word
if ((ns < maxSug) && (dicstem < 2)) {
if ((ns < maxSug) && (dicstem < 2)) {
strcpy(buf, prefix);
if ((dicstem > 0) && pAMgr->get_derived()) {
// XXX obsolote
@@ -1162,7 +1162,7 @@ int SuggestMgr::fixstems(char ** wlst, const char * word, int ns)
} else {
// special stem in affix description
const char * wordchars = pAMgr->get_wordchars();
if (rv->description &&
if (rv->description &&
(strchr(wordchars, *(rv->description)))) {
char * desc = (rv->description) + 1;
while (strchr(wordchars, *desc)) desc++;
@@ -1190,7 +1190,7 @@ int SuggestMgr::fixstems(char ** wlst, const char * word, int ns)
} else {
// special stem in affix description
const char * wordchars = pAMgr->get_wordchars();
if (rv->description &&
if (rv->description &&
(strchr(wordchars, *(rv->description)))) {
char * desc = (rv->description) + 1;
while (strchr(wordchars, *desc)) desc++;
@@ -1243,19 +1243,19 @@ while (rv) {
rv = rv2;
} else return ns;
} else return ns;
} else {
strcpy(fix, "__");
strcat(fix, rv->word);
rv = NULL;
rv2 = pAMgr->lookup(fix);
if ((rv2) && (rv2->astr) && (ns < maxSug))
if ((rv2) && (rv2->astr) && (ns < maxSug))
if ((rv2) && (rv2->astr) && (ns < maxSug))
if ((rv2) && (rv2->astr) && (ns < maxSug))
if (0) {
char buf2[MAXSWUTF8L];
strcpy(buf2, prefix);
if (*(rv2->astr) == '-') {
strcat(buf2, "");
} else {
@@ -1325,7 +1325,7 @@ return ns;
// suggest possible stems
int SuggestMgr::suggest_pos_stems(char*** slst, const char * w, int nsug)
{
char ** wlst;
char ** wlst;
struct hentry * rv = NULL;
@@ -1386,12 +1386,12 @@ char * SuggestMgr::suggest_morph(const char * w)
}
rv = pAMgr->lookup(word);
while (rv) {
if ((!rv->astr) || !(TESTAFF(rv->astr, pAMgr->get_forbiddenword(), rv->alen) ||
TESTAFF(rv->astr, pAMgr->get_pseudoroot(), rv->alen) ||
TESTAFF(rv->astr,pAMgr->get_onlyincompound(),rv->alen))) {
if (rv->description && ((!rv->astr) ||
if (rv->description && ((!rv->astr) ||
!TESTAFF(rv->astr, pAMgr->get_lemma_present(), rv->alen)))
strcat(result, word);
if (rv->description) strcat(result, rv->description);
@@ -1399,7 +1399,7 @@ char * SuggestMgr::suggest_morph(const char * w)
}
rv = rv->next_homonym;
}
st = pAMgr->affix_check_morph(word,strlen(word));
if (st) {
strcat(result, st);
@@ -1409,7 +1409,7 @@ char * SuggestMgr::suggest_morph(const char * w)
if (pAMgr->get_compound() && (*result == '\0'))
pAMgr->compound_check_morph(word, strlen(word),
0, 0, 100, 0,NULL, 0, &r, NULL);
return (*result) ? mystrdup(line_uniq(delete_zeros(result))) : NULL;
}
@@ -1425,7 +1425,7 @@ char * SuggestMgr::suggest_morph_for_spelling_error(const char * word)
free(wlst[maxSug - 1]);
}
if (wlst) free(wlst);
return p;
return p;
}
@@ -1468,7 +1468,7 @@ int SuggestMgr::ngram(int n, char * s1, const char * s2, int uselen)
nscore = nscore + ns;
if (ns < 2) break;
}
} else {
} else {
char t[MAXSWUTF8L];
l1 = strlen(s1);
l2 = strlen(s2);