|
|
|
Lines 78-94
AffixMgr::AffixMgr(const char * affpath,
|
Link Here
|
|---|
|
| 78 |
trystring = NULL; |
78 |
trystring = NULL; |
| 79 |
encoding=NULL; |
79 |
encoding=NULL; |
| 80 |
csconv=NULL; |
80 |
csconv=NULL; |
| 81 |
utf8 = 0; |
81 |
utf8 = 0; |
| 82 |
complexprefixes = 0; |
82 |
complexprefixes = 0; |
| 83 |
maptable = NULL; |
83 |
maptable = NULL; |
| 84 |
nummap = 0; |
84 |
nummap = 0; |
| 85 |
breaktable = NULL; |
85 |
breaktable = NULL; |
| 86 |
numbreak = 0; |
86 |
numbreak = -1; |
| 87 |
reptable = NULL; |
87 |
reptable = NULL; |
| 88 |
numrep = 0; |
88 |
numrep = 0; |
| 89 |
iconvtable = NULL; |
89 |
iconvtable = NULL; |
| 90 |
oconvtable = NULL; |
90 |
oconvtable = NULL; |
| 91 |
checkcpdtable = NULL; |
91 |
checkcpdtable = NULL; |
| 92 |
// allow simplified compound forms (see 3rd field of CHECKCOMPOUNDPATTERN) |
92 |
// allow simplified compound forms (see 3rd field of CHECKCOMPOUNDPATTERN) |
| 93 |
simplifiedcpd = 0; |
93 |
simplifiedcpd = 0; |
| 94 |
numcheckcpd = 0; |
94 |
numcheckcpd = 0; |
|
Lines 104-119
AffixMgr::AffixMgr(const char * affpath,
|
Link Here
|
|---|
|
| 104 |
compoundforbidflag = FLAG_NULL; // compound fordidden flag for suffixed word |
104 |
compoundforbidflag = FLAG_NULL; // compound fordidden flag for suffixed word |
| 105 |
checkcompounddup = 0; // forbid double words in compounds |
105 |
checkcompounddup = 0; // forbid double words in compounds |
| 106 |
checkcompoundrep = 0; // forbid bad compounds (may be non compound word with a REP substitution) |
106 |
checkcompoundrep = 0; // forbid bad compounds (may be non compound word with a REP substitution) |
| 107 |
checkcompoundcase = 0; // forbid upper and lowercase combinations at word bounds |
107 |
checkcompoundcase = 0; // forbid upper and lowercase combinations at word bounds |
| 108 |
checkcompoundtriple = 0; // forbid compounds with triple letters |
108 |
checkcompoundtriple = 0; // forbid compounds with triple letters |
| 109 |
simplifiedtriple = 0; // allow simplified triple letters in compounds (Schiff+fahrt -> Schiffahrt) |
109 |
simplifiedtriple = 0; // allow simplified triple letters in compounds (Schiff+fahrt -> Schiffahrt) |
| 110 |
forbiddenword = FORBIDDENWORD; // forbidden word signing flag |
110 |
forbiddenword = FORBIDDENWORD; // forbidden word signing flag |
| 111 |
nosuggest = FLAG_NULL; // don't suggest words signed with NOSUGGEST flag |
111 |
nosuggest = FLAG_NULL; // don't suggest words signed with NOSUGGEST flag |
|
|
112 |
nongramsuggest = FLAG_NULL; |
| 112 |
lang = NULL; // language |
113 |
lang = NULL; // language |
| 113 |
langnum = 0; // language code (see http://l10n.openoffice.org/languages.html) |
114 |
langnum = 0; // language code (see http://l10n.openoffice.org/languages.html) |
| 114 |
needaffix = FLAG_NULL; // forbidden root, allowed only with suffixes |
115 |
needaffix = FLAG_NULL; // forbidden root, allowed only with suffixes |
| 115 |
cpdwordmax = -1; // default: unlimited wordcount in compound words |
116 |
cpdwordmax = -1; // default: unlimited wordcount in compound words |
| 116 |
cpdmin = -1; // undefined |
117 |
cpdmin = -1; // undefined |
| 117 |
cpdmaxsyllable = 0; // default: unlimited syllablecount in compound words |
118 |
cpdmaxsyllable = 0; // default: unlimited syllablecount in compound words |
| 118 |
cpdvowels=NULL; // vowels (for calculating of Hungarian compounding limit, O(n) search! XXX) |
119 |
cpdvowels=NULL; // vowels (for calculating of Hungarian compounding limit, O(n) search! XXX) |
| 119 |
cpdvowels_utf16=NULL; // vowels for UTF-8 encoding (bsearch instead of O(n) search) |
120 |
cpdvowels_utf16=NULL; // vowels for UTF-8 encoding (bsearch instead of O(n) search) |
|
Lines 131-149
AffixMgr::AffixMgr(const char * affpath,
|
Link Here
|
|---|
|
| 131 |
version=NULL; // affix and dictionary file version string |
132 |
version=NULL; // affix and dictionary file version string |
| 132 |
havecontclass=0; // flags of possible continuing classes (double affix) |
133 |
havecontclass=0; // flags of possible continuing classes (double affix) |
| 133 |
// LEMMA_PRESENT: not put root into the morphological output. Lemma presents |
134 |
// LEMMA_PRESENT: not put root into the morphological output. Lemma presents |
| 134 |
// in morhological description in dictionary file. It's often combined with PSEUDOROOT. |
135 |
// in morhological description in dictionary file. It's often combined with PSEUDOROOT. |
| 135 |
lemma_present = FLAG_NULL; |
136 |
lemma_present = FLAG_NULL; |
| 136 |
circumfix = FLAG_NULL; |
137 |
circumfix = FLAG_NULL; |
| 137 |
onlyincompound = FLAG_NULL; |
138 |
onlyincompound = FLAG_NULL; |
| 138 |
maxngramsugs = -1; // undefined |
139 |
maxngramsugs = -1; // undefined |
|
|
140 |
maxdiff = -1; // undefined |
| 141 |
onlymaxdiff = 0; |
| 142 |
maxcpdsugs = -1; // undefined |
| 139 |
nosplitsugs = 0; |
143 |
nosplitsugs = 0; |
| 140 |
sugswithdots = 0; |
144 |
sugswithdots = 0; |
| 141 |
keepcase = 0; |
145 |
keepcase = 0; |
|
|
146 |
forceucase = 0; |
| 147 |
warn = 0; |
| 148 |
forbidwarn = 0; |
| 142 |
checksharps = 0; |
149 |
checksharps = 0; |
| 143 |
substandard = FLAG_NULL; |
150 |
substandard = FLAG_NULL; |
| 144 |
fullstrip = 0; |
151 |
fullstrip = 0; |
| 145 |
|
152 |
|
| 146 |
sfx = NULL; |
153 |
sfx = NULL; |
| 147 |
pfx = NULL; |
154 |
pfx = NULL; |
| 148 |
|
155 |
|
| 149 |
for (int i=0; i < SETSIZE; i++) { |
156 |
for (int i=0; i < SETSIZE; i++) { |
|
Lines 269-284
AffixMgr::~AffixMgr()
|
Link Here
|
|---|
|
| 269 |
FREE_FLAG(compoundbegin); |
276 |
FREE_FLAG(compoundbegin); |
| 270 |
FREE_FLAG(compoundmiddle); |
277 |
FREE_FLAG(compoundmiddle); |
| 271 |
FREE_FLAG(compoundend); |
278 |
FREE_FLAG(compoundend); |
| 272 |
FREE_FLAG(compoundpermitflag); |
279 |
FREE_FLAG(compoundpermitflag); |
| 273 |
FREE_FLAG(compoundforbidflag); |
280 |
FREE_FLAG(compoundforbidflag); |
| 274 |
FREE_FLAG(compoundroot); |
281 |
FREE_FLAG(compoundroot); |
| 275 |
FREE_FLAG(forbiddenword); |
282 |
FREE_FLAG(forbiddenword); |
| 276 |
FREE_FLAG(nosuggest); |
283 |
FREE_FLAG(nosuggest); |
|
|
284 |
FREE_FLAG(nongramsuggest); |
| 277 |
FREE_FLAG(needaffix); |
285 |
FREE_FLAG(needaffix); |
| 278 |
FREE_FLAG(lemma_present); |
286 |
FREE_FLAG(lemma_present); |
| 279 |
FREE_FLAG(circumfix); |
287 |
FREE_FLAG(circumfix); |
| 280 |
FREE_FLAG(onlyincompound); |
288 |
FREE_FLAG(onlyincompound); |
| 281 |
|
289 |
|
| 282 |
cpdwordmax = 0; |
290 |
cpdwordmax = 0; |
| 283 |
pHMgr = NULL; |
291 |
pHMgr = NULL; |
| 284 |
cpdmin = 0; |
292 |
cpdmin = 0; |
|
Lines 472-487
int AffixMgr::parse_file(const char * a
|
Link Here
|
|---|
|
| 472 |
|
480 |
|
| 473 |
if (strncmp(line,"NOSUGGEST",9) == 0) { |
481 |
if (strncmp(line,"NOSUGGEST",9) == 0) { |
| 474 |
if (parse_flag(line, &nosuggest, afflst)) { |
482 |
if (parse_flag(line, &nosuggest, afflst)) { |
| 475 |
delete afflst; |
483 |
delete afflst; |
| 476 |
return 1; |
484 |
return 1; |
| 477 |
} |
485 |
} |
| 478 |
} |
486 |
} |
| 479 |
|
487 |
|
|
|
488 |
if (strncmp(line,"NONGRAMSUGGEST",14) == 0) { |
| 489 |
if (parse_flag(line, &nongramsuggest, afflst)) { |
| 490 |
delete afflst; |
| 491 |
return 1; |
| 492 |
} |
| 493 |
} |
| 494 |
|
| 480 |
/* parse in the flag used by forbidden words */ |
495 |
/* parse in the flag used by forbidden words */ |
| 481 |
if (strncmp(line,"FORBIDDENWORD",13) == 0) { |
496 |
if (strncmp(line,"FORBIDDENWORD",13) == 0) { |
| 482 |
if (parse_flag(line, &forbiddenword, afflst)) { |
497 |
if (parse_flag(line, &forbiddenword, afflst)) { |
| 483 |
delete afflst; |
498 |
delete afflst; |
| 484 |
return 1; |
499 |
return 1; |
| 485 |
} |
500 |
} |
| 486 |
} |
501 |
} |
| 487 |
|
502 |
|
|
Lines 651-666
int AffixMgr::parse_file(const char * a
|
Link Here
|
|---|
|
| 651 |
|
666 |
|
| 652 |
if (strncmp(line,"MAXNGRAMSUGS",12) == 0) { |
667 |
if (strncmp(line,"MAXNGRAMSUGS",12) == 0) { |
| 653 |
if (parse_num(line, &maxngramsugs, afflst)) { |
668 |
if (parse_num(line, &maxngramsugs, afflst)) { |
| 654 |
delete afflst; |
669 |
delete afflst; |
| 655 |
return 1; |
670 |
return 1; |
| 656 |
} |
671 |
} |
| 657 |
} |
672 |
} |
| 658 |
|
673 |
|
|
|
674 |
if (strncmp(line,"ONLYMAXDIFF", 11) == 0) |
| 675 |
onlymaxdiff = 1; |
| 676 |
|
| 677 |
if (strncmp(line,"MAXDIFF",7) == 0) { |
| 678 |
if (parse_num(line, &maxdiff, afflst)) { |
| 679 |
delete afflst; |
| 680 |
return 1; |
| 681 |
} |
| 682 |
} |
| 683 |
|
| 684 |
if (strncmp(line,"MAXCPDSUGS",10) == 0) { |
| 685 |
if (parse_num(line, &maxcpdsugs, afflst)) { |
| 686 |
delete afflst; |
| 687 |
return 1; |
| 688 |
} |
| 689 |
} |
| 690 |
|
| 659 |
if (strncmp(line,"NOSPLITSUGS",11) == 0) { |
691 |
if (strncmp(line,"NOSPLITSUGS",11) == 0) { |
| 660 |
nosplitsugs=1; |
692 |
nosplitsugs=1; |
| 661 |
} |
693 |
} |
| 662 |
|
694 |
|
| 663 |
if (strncmp(line,"FULLSTRIP",9) == 0) { |
695 |
if (strncmp(line,"FULLSTRIP",9) == 0) { |
| 664 |
fullstrip=1; |
696 |
fullstrip=1; |
| 665 |
} |
697 |
} |
| 666 |
|
698 |
|
|
Lines 671-686
int AffixMgr::parse_file(const char * a
|
Link Here
|
|---|
|
| 671 |
/* parse in the flag used by forbidden words */ |
703 |
/* parse in the flag used by forbidden words */ |
| 672 |
if (strncmp(line,"KEEPCASE",8) == 0) { |
704 |
if (strncmp(line,"KEEPCASE",8) == 0) { |
| 673 |
if (parse_flag(line, &keepcase, afflst)) { |
705 |
if (parse_flag(line, &keepcase, afflst)) { |
| 674 |
delete afflst; |
706 |
delete afflst; |
| 675 |
return 1; |
707 |
return 1; |
| 676 |
} |
708 |
} |
| 677 |
} |
709 |
} |
| 678 |
|
710 |
|
|
|
711 |
/* parse in the flag used by `forceucase' */ |
| 712 |
if (strncmp(line,"FORCEUCASE",10) == 0) { |
| 713 |
if (parse_flag(line, &forceucase, afflst)) { |
| 714 |
delete afflst; |
| 715 |
return 1; |
| 716 |
} |
| 717 |
} |
| 718 |
|
| 719 |
/* parse in the flag used by `warn' */ |
| 720 |
if (strncmp(line,"WARN",4) == 0) { |
| 721 |
if (parse_flag(line, &warn, afflst)) { |
| 722 |
delete afflst; |
| 723 |
return 1; |
| 724 |
} |
| 725 |
} |
| 726 |
|
| 727 |
if (strncmp(line,"FORBIDWARN",10) == 0) { |
| 728 |
forbidwarn=1; |
| 729 |
} |
| 730 |
|
| 679 |
/* parse in the flag used by the affix generator */ |
731 |
/* parse in the flag used by the affix generator */ |
| 680 |
if (strncmp(line,"SUBSTANDARD",11) == 0) { |
732 |
if (strncmp(line,"SUBSTANDARD",11) == 0) { |
| 681 |
if (parse_flag(line, &substandard, afflst)) { |
733 |
if (parse_flag(line, &substandard, afflst)) { |
| 682 |
delete afflst; |
734 |
delete afflst; |
| 683 |
return 1; |
735 |
return 1; |
| 684 |
} |
736 |
} |
| 685 |
} |
737 |
} |
| 686 |
|
738 |
|
|
Lines 758-774
int AffixMgr::parse_file(const char * a
|
Link Here
|
|---|
|
| 758 |
*(expw + strlen(expw)) = (char) i; |
810 |
*(expw + strlen(expw)) = (char) i; |
| 759 |
} |
811 |
} |
| 760 |
} |
812 |
} |
| 761 |
|
813 |
|
| 762 |
wordchars = mystrdup(expw); |
814 |
wordchars = mystrdup(expw); |
| 763 |
} |
815 |
} |
| 764 |
|
816 |
|
| 765 |
// default BREAK definition |
817 |
// default BREAK definition |
| 766 |
if (!breaktable) { |
818 |
if (numbreak == -1) { |
| 767 |
breaktable = (char **) malloc(sizeof(char *) * 3); |
819 |
breaktable = (char **) malloc(sizeof(char *) * 3); |
| 768 |
if (!breaktable) return 1; |
820 |
if (!breaktable) return 1; |
| 769 |
breaktable[0] = mystrdup("-"); |
821 |
breaktable[0] = mystrdup("-"); |
| 770 |
breaktable[1] = mystrdup("^-"); |
822 |
breaktable[1] = mystrdup("^-"); |
| 771 |
breaktable[2] = mystrdup("-$"); |
823 |
breaktable[2] = mystrdup("-$"); |
| 772 |
if (breaktable[0] && breaktable[1] && breaktable[2]) numbreak = 3; |
824 |
if (breaktable[0] && breaktable[1] && breaktable[2]) numbreak = 3; |
| 773 |
} |
825 |
} |
| 774 |
return 0; |
826 |
return 0; |
|
Lines 1316-1342
int AffixMgr::cpdrep_check(const char *
|
Link Here
|
|---|
|
| 1316 |
if (candidate_check(candidate,strlen(candidate))) return 1; |
1368 |
if (candidate_check(candidate,strlen(candidate))) return 1; |
| 1317 |
r++; // search for the next letter |
1369 |
r++; // search for the next letter |
| 1318 |
} |
1370 |
} |
| 1319 |
} |
1371 |
} |
| 1320 |
return 0; |
1372 |
return 0; |
| 1321 |
} |
1373 |
} |
| 1322 |
|
1374 |
|
| 1323 |
// forbid compoundings when there are special patterns at word bound |
1375 |
// forbid compoundings when there are special patterns at word bound |
| 1324 |
int AffixMgr::cpdpat_check(const char * word, int pos, hentry * r1, hentry * r2) |
1376 |
int AffixMgr::cpdpat_check(const char * word, int pos, hentry * r1, hentry * r2, const char affixed) |
| 1325 |
{ |
1377 |
{ |
| 1326 |
int len; |
1378 |
int len; |
| 1327 |
for (int i = 0; i < numcheckcpd; i++) { |
1379 |
for (int i = 0; i < numcheckcpd; i++) { |
| 1328 |
if (isSubset(checkcpdtable[i].pattern2, word + pos) && |
1380 |
if (isSubset(checkcpdtable[i].pattern2, word + pos) && |
| 1329 |
(!r1 || !checkcpdtable[i].cond || |
1381 |
(!r1 || !checkcpdtable[i].cond || |
| 1330 |
(r1->astr && TESTAFF(r1->astr, checkcpdtable[i].cond, r1->alen))) && |
1382 |
(r1->astr && TESTAFF(r1->astr, checkcpdtable[i].cond, r1->alen))) && |
| 1331 |
(!r2 || !checkcpdtable[i].cond2 || |
1383 |
(!r2 || !checkcpdtable[i].cond2 || |
| 1332 |
(r2->astr && TESTAFF(r2->astr, checkcpdtable[i].cond2, r2->alen))) && |
1384 |
(r2->astr && TESTAFF(r2->astr, checkcpdtable[i].cond2, r2->alen))) && |
| 1333 |
(len = strlen(checkcpdtable[i].pattern)) && (pos > len) && |
1385 |
// zero length pattern => only TESTAFF |
| 1334 |
(strncmp(word + pos - len, checkcpdtable[i].pattern, len) == 0)) return 1; |
1386 |
// zero pattern (0/flag) => unmodified stem (zero affixes allowed) |
|
|
1387 |
(!*(checkcpdtable[i].pattern) || ( |
| 1388 |
(*(checkcpdtable[i].pattern)=='0' && r1->blen <= pos && strncmp(word + pos - r1->blen, r1->word, r1->blen) == 0) || |
| 1389 |
(*(checkcpdtable[i].pattern)!='0' && (len = strlen(checkcpdtable[i].pattern)) && |
| 1390 |
strncmp(word + pos - len, checkcpdtable[i].pattern, len) == 0)))) { |
| 1391 |
return 1; |
| 1392 |
} |
| 1335 |
} |
1393 |
} |
| 1336 |
return 0; |
1394 |
return 0; |
| 1337 |
} |
1395 |
} |
| 1338 |
|
1396 |
|
| 1339 |
// forbid compounding with neighbouring upper and lower case characters at word bounds |
1397 |
// forbid compounding with neighbouring upper and lower case characters at word bounds |
| 1340 |
int AffixMgr::cpdcase_check(const char * word, int pos) |
1398 |
int AffixMgr::cpdcase_check(const char * word, int pos) |
| 1341 |
{ |
1399 |
{ |
| 1342 |
if (utf8) { |
1400 |
if (utf8) { |
|
Lines 1511-1567
void AffixMgr::setcminmax(int * cmin, in
|
Link Here
|
|---|
|
| 1511 |
for ((*cmax)--; (word[*cmax] & 0xc0) == 0x80; (*cmax)--); |
1569 |
for ((*cmax)--; (word[*cmax] & 0xc0) == 0x80; (*cmax)--); |
| 1512 |
} |
1570 |
} |
| 1513 |
} else { |
1571 |
} else { |
| 1514 |
*cmin = cpdmin; |
1572 |
*cmin = cpdmin; |
| 1515 |
*cmax = len - cpdmin + 1; |
1573 |
*cmax = len - cpdmin + 1; |
| 1516 |
} |
1574 |
} |
| 1517 |
} |
1575 |
} |
| 1518 |
|
1576 |
|
|
|
1577 |
|
| 1519 |
// check if compound word is correctly spelled |
1578 |
// check if compound word is correctly spelled |
| 1520 |
// hu_mov_rule = spec. Hungarian rule (XXX) |
1579 |
// hu_mov_rule = spec. Hungarian rule (XXX) |
| 1521 |
struct hentry * AffixMgr::compound_check(const char * word, int len, |
1580 |
struct hentry * AffixMgr::compound_check(const char * word, int len, |
| 1522 |
short wordnum, short numsyllable, short maxwordnum, short wnum, hentry ** words = NULL, |
1581 |
short wordnum, short numsyllable, short maxwordnum, short wnum, hentry ** words = NULL, |
| 1523 |
char hu_mov_rule = 0, char is_sug = 0) |
1582 |
char hu_mov_rule = 0, char is_sug = 0, int * info = NULL) |
| 1524 |
{ |
1583 |
{ |
| 1525 |
int i; |
1584 |
int i; |
| 1526 |
short oldnumsyllable, oldnumsyllable2, oldwordnum, oldwordnum2; |
1585 |
short oldnumsyllable, oldnumsyllable2, oldwordnum, oldwordnum2; |
| 1527 |
struct hentry * rv = NULL; |
1586 |
struct hentry * rv = NULL; |
| 1528 |
struct hentry * rv_first; |
1587 |
struct hentry * rv_first; |
| 1529 |
struct hentry * rwords[MAXWORDLEN]; // buffer for COMPOUND pattern checking |
1588 |
struct hentry * rwords[MAXWORDLEN]; // buffer for COMPOUND pattern checking |
| 1530 |
char st [MAXWORDUTF8LEN + 4]; |
1589 |
char st [MAXWORDUTF8LEN + 4]; |
| 1531 |
char ch; |
1590 |
char ch = '\0'; |
| 1532 |
int cmin; |
1591 |
int cmin; |
| 1533 |
int cmax; |
1592 |
int cmax; |
| 1534 |
int striple = 0; |
1593 |
int striple = 0; |
| 1535 |
int scpd = 0; |
1594 |
int scpd = 0; |
| 1536 |
int soldi = 0; |
1595 |
int soldi = 0; |
| 1537 |
int oldcmin = 0; |
1596 |
int oldcmin = 0; |
| 1538 |
int oldcmax = 0; |
1597 |
int oldcmax = 0; |
| 1539 |
int oldlen = 0; |
1598 |
int oldlen = 0; |
| 1540 |
int checkedstriple = 0; |
1599 |
int checkedstriple = 0; |
|
|
1600 |
int onlycpdrule; |
| 1601 |
int affixed = 0; |
| 1602 |
hentry ** oldwords = words; |
| 1541 |
|
1603 |
|
| 1542 |
int checked_prefix; |
1604 |
int checked_prefix; |
| 1543 |
|
1605 |
|
| 1544 |
setcminmax(&cmin, &cmax, word, len); |
1606 |
setcminmax(&cmin, &cmax, word, len); |
| 1545 |
|
1607 |
|
| 1546 |
strcpy(st, word); |
1608 |
strcpy(st, word); |
| 1547 |
|
1609 |
|
| 1548 |
for (i = cmin; i < cmax; i++) { |
1610 |
for (i = cmin; i < cmax; i++) { |
| 1549 |
|
|
|
| 1550 |
oldnumsyllable = numsyllable; |
| 1551 |
oldwordnum = wordnum; |
| 1552 |
checked_prefix = 0; |
| 1553 |
|
| 1554 |
// go to end of the UTF-8 character |
1611 |
// go to end of the UTF-8 character |
| 1555 |
if (utf8) { |
1612 |
if (utf8) { |
| 1556 |
for (; (st[i] & 0xc0) == 0x80; i++); |
1613 |
for (; (st[i] & 0xc0) == 0x80; i++); |
| 1557 |
if (i >= cmax) return NULL; |
1614 |
if (i >= cmax) return NULL; |
| 1558 |
} |
1615 |
} |
| 1559 |
|
1616 |
|
|
|
1617 |
words = oldwords; |
| 1618 |
onlycpdrule = (words) ? 1 : 0; |
| 1619 |
|
| 1620 |
do { // onlycpdrule loop |
| 1621 |
|
| 1622 |
oldnumsyllable = numsyllable; |
| 1623 |
oldwordnum = wordnum; |
| 1624 |
checked_prefix = 0; |
| 1625 |
|
| 1626 |
|
| 1560 |
do { // simplified checkcompoundpattern loop |
1627 |
do { // simplified checkcompoundpattern loop |
| 1561 |
|
1628 |
|
| 1562 |
if (scpd > 0) { |
1629 |
if (scpd > 0) { |
| 1563 |
for (; scpd <= numcheckcpd && (!checkcpdtable[scpd-1].pattern3 || |
1630 |
for (; scpd <= numcheckcpd && (!checkcpdtable[scpd-1].pattern3 || |
| 1564 |
strncmp(word + i, checkcpdtable[scpd-1].pattern3, strlen(checkcpdtable[scpd-1].pattern3)) != 0); scpd++); |
1631 |
strncmp(word + i, checkcpdtable[scpd-1].pattern3, strlen(checkcpdtable[scpd-1].pattern3)) != 0); scpd++); |
| 1565 |
|
1632 |
|
| 1566 |
if (scpd > numcheckcpd) break; // break simplified checkcompoundpattern loop |
1633 |
if (scpd > numcheckcpd) break; // break simplified checkcompoundpattern loop |
| 1567 |
strcpy(st + i, checkcpdtable[scpd-1].pattern); |
1634 |
strcpy(st + i, checkcpdtable[scpd-1].pattern); |
|
Lines 1574-1618
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1574 |
len += strlen(checkcpdtable[scpd-1].pattern) + strlen(checkcpdtable[scpd-1].pattern2) - strlen(checkcpdtable[scpd-1].pattern3); |
1641 |
len += strlen(checkcpdtable[scpd-1].pattern) + strlen(checkcpdtable[scpd-1].pattern2) - strlen(checkcpdtable[scpd-1].pattern3); |
| 1575 |
oldcmin = cmin; |
1642 |
oldcmin = cmin; |
| 1576 |
oldcmax = cmax; |
1643 |
oldcmax = cmax; |
| 1577 |
setcminmax(&cmin, &cmax, st, len); |
1644 |
setcminmax(&cmin, &cmax, st, len); |
| 1578 |
|
1645 |
|
| 1579 |
cmax = len - cpdmin + 1; |
1646 |
cmax = len - cpdmin + 1; |
| 1580 |
} |
1647 |
} |
| 1581 |
|
1648 |
|
| 1582 |
|
|
|
| 1583 |
ch = st[i]; |
1649 |
ch = st[i]; |
| 1584 |
st[i] = '\0'; |
1650 |
st[i] = '\0'; |
| 1585 |
|
1651 |
|
| 1586 |
sfx = NULL; |
1652 |
sfx = NULL; |
| 1587 |
pfx = NULL; |
1653 |
pfx = NULL; |
| 1588 |
|
1654 |
|
| 1589 |
// FIRST WORD |
1655 |
// FIRST WORD |
| 1590 |
|
1656 |
|
|
|
1657 |
affixed = 1; |
| 1591 |
rv = lookup(st); // perhaps without prefix |
1658 |
rv = lookup(st); // perhaps without prefix |
| 1592 |
|
1659 |
|
| 1593 |
// search homonym with compound flag |
1660 |
// search homonym with compound flag |
| 1594 |
while ((rv) && !hu_mov_rule && |
1661 |
while ((rv) && !hu_mov_rule && |
| 1595 |
((needaffix && TESTAFF(rv->astr, needaffix, rv->alen)) || |
1662 |
((needaffix && TESTAFF(rv->astr, needaffix, rv->alen)) || |
| 1596 |
!((compoundflag && !words && TESTAFF(rv->astr, compoundflag, rv->alen)) || |
1663 |
!((compoundflag && !words && !onlycpdrule && TESTAFF(rv->astr, compoundflag, rv->alen)) || |
| 1597 |
(compoundbegin && !wordnum && |
1664 |
(compoundbegin && !wordnum && !onlycpdrule && |
| 1598 |
TESTAFF(rv->astr, compoundbegin, rv->alen)) || |
1665 |
TESTAFF(rv->astr, compoundbegin, rv->alen)) || |
| 1599 |
(compoundmiddle && wordnum && !words && |
1666 |
(compoundmiddle && wordnum && !words && !onlycpdrule && |
| 1600 |
TESTAFF(rv->astr, compoundmiddle, rv->alen)) || |
1667 |
TESTAFF(rv->astr, compoundmiddle, rv->alen)) || |
| 1601 |
(numdefcpd && |
1668 |
(numdefcpd && onlycpdrule && |
| 1602 |
((!words && !wordnum && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0)) || |
1669 |
((!words && !wordnum && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0)) || |
| 1603 |
(words && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0))))) || |
1670 |
(words && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0))))) || |
| 1604 |
(scpd != 0 && checkcpdtable[scpd-1].cond != FLAG_NULL && |
1671 |
(scpd != 0 && checkcpdtable[scpd-1].cond != FLAG_NULL && |
| 1605 |
!TESTAFF(rv->astr, checkcpdtable[scpd-1].cond, rv->alen))) |
1672 |
!TESTAFF(rv->astr, checkcpdtable[scpd-1].cond, rv->alen))) |
| 1606 |
) { |
1673 |
) { |
| 1607 |
rv = rv->next_homonym; |
1674 |
rv = rv->next_homonym; |
| 1608 |
} |
1675 |
} |
| 1609 |
|
1676 |
|
|
|
1677 |
if (rv) affixed = 0; |
| 1678 |
|
| 1610 |
if (!rv) { |
1679 |
if (!rv) { |
|
|
1680 |
if (onlycpdrule) break; |
| 1611 |
if (compoundflag && |
1681 |
if (compoundflag && |
| 1612 |
!(rv = prefix_check(st, i, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN, compoundflag))) { |
1682 |
!(rv = prefix_check(st, i, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN, compoundflag))) { |
| 1613 |
if ((rv = suffix_check(st, i, 0, NULL, NULL, 0, NULL, |
1683 |
if ((rv = suffix_check(st, i, 0, NULL, NULL, 0, NULL, |
| 1614 |
FLAG_NULL, compoundflag, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN)) && !hu_mov_rule && |
1684 |
FLAG_NULL, compoundflag, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN)) && !hu_mov_rule && |
| 1615 |
sfx->getCont() && |
1685 |
sfx->getCont() && |
| 1616 |
((compoundforbidflag && TESTAFF(sfx->getCont(), compoundforbidflag, |
1686 |
((compoundforbidflag && TESTAFF(sfx->getCont(), compoundforbidflag, |
| 1617 |
sfx->getContLen())) || (compoundend && |
1687 |
sfx->getContLen())) || (compoundend && |
| 1618 |
TESTAFF(sfx->getCont(), compoundend, |
1688 |
TESTAFF(sfx->getCont(), compoundend, |
|
Lines 1626-1646
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1626 |
((rv = suffix_check(st, i, 0, NULL, NULL, 0, NULL, FLAG_NULL, compoundbegin, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN)) || |
1696 |
((rv = suffix_check(st, i, 0, NULL, NULL, 0, NULL, FLAG_NULL, compoundbegin, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN)) || |
| 1627 |
(rv = prefix_check(st, i, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN, compoundbegin)))) || |
1697 |
(rv = prefix_check(st, i, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN, compoundbegin)))) || |
| 1628 |
((wordnum > 0) && compoundmiddle && |
1698 |
((wordnum > 0) && compoundmiddle && |
| 1629 |
((rv = suffix_check(st, i, 0, NULL, NULL, 0, NULL, FLAG_NULL, compoundmiddle, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN)) || |
1699 |
((rv = suffix_check(st, i, 0, NULL, NULL, 0, NULL, FLAG_NULL, compoundmiddle, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN)) || |
| 1630 |
(rv = prefix_check(st, i, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN, compoundmiddle))))) |
1700 |
(rv = prefix_check(st, i, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN, compoundmiddle))))) |
| 1631 |
) checked_prefix = 1; |
1701 |
) checked_prefix = 1; |
| 1632 |
// else check forbiddenwords and needaffix |
1702 |
// else check forbiddenwords and needaffix |
| 1633 |
} else if (rv->astr && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
1703 |
} else if (rv->astr && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
| 1634 |
TESTAFF(rv->astr, needaffix, rv->alen) || |
1704 |
TESTAFF(rv->astr, needaffix, rv->alen) || |
|
|
1705 |
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen) || |
| 1635 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)) |
1706 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)) |
| 1636 |
)) { |
1707 |
)) { |
| 1637 |
st[i] = ch; |
1708 |
st[i] = ch; |
| 1638 |
continue; |
1709 |
//continue; |
|
|
1710 |
break; |
| 1639 |
} |
1711 |
} |
| 1640 |
|
1712 |
|
| 1641 |
// check non_compound flag in suffix and prefix |
1713 |
// check non_compound flag in suffix and prefix |
| 1642 |
if ((rv) && !hu_mov_rule && |
1714 |
if ((rv) && !hu_mov_rule && |
| 1643 |
((pfx && pfx->getCont() && |
1715 |
((pfx && pfx->getCont() && |
| 1644 |
TESTAFF(pfx->getCont(), compoundforbidflag, |
1716 |
TESTAFF(pfx->getCont(), compoundforbidflag, |
| 1645 |
pfx->getContLen())) || |
1717 |
pfx->getContLen())) || |
| 1646 |
(sfx && sfx->getCont() && |
1718 |
(sfx && sfx->getCont() && |
|
Lines 1668-1683
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1668 |
(sfx && sfx->getCont() && |
1740 |
(sfx && sfx->getCont() && |
| 1669 |
TESTAFF(sfx->getCont(), compoundmiddle, |
1741 |
TESTAFF(sfx->getCont(), compoundmiddle, |
| 1670 |
sfx->getContLen())))) { |
1742 |
sfx->getContLen())))) { |
| 1671 |
rv = NULL; |
1743 |
rv = NULL; |
| 1672 |
} |
1744 |
} |
| 1673 |
|
1745 |
|
| 1674 |
// check forbiddenwords |
1746 |
// check forbiddenwords |
| 1675 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
1747 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
|
|
1748 |
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen) || |
| 1676 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) { |
1749 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) { |
| 1677 |
return NULL; |
1750 |
return NULL; |
| 1678 |
} |
1751 |
} |
| 1679 |
|
1752 |
|
| 1680 |
// increment word number, if the second root has a compoundroot flag |
1753 |
// increment word number, if the second root has a compoundroot flag |
| 1681 |
if ((rv) && compoundroot && |
1754 |
if ((rv) && compoundroot && |
| 1682 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
1755 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
| 1683 |
wordnum++; |
1756 |
wordnum++; |
|
Lines 1724-1746
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1724 |
) |
1797 |
) |
| 1725 |
) |
1798 |
) |
| 1726 |
) { // first word is ok condition |
1799 |
) { // first word is ok condition |
| 1727 |
|
1800 |
|
| 1728 |
// LANG_hu section: spec. Hungarian rule |
1801 |
// LANG_hu section: spec. Hungarian rule |
| 1729 |
if (langnum == LANG_hu) { |
1802 |
if (langnum == LANG_hu) { |
| 1730 |
// calculate syllable number of the word |
1803 |
// calculate syllable number of the word |
| 1731 |
numsyllable += get_syllable(st, i); |
1804 |
numsyllable += get_syllable(st, i); |
| 1732 |
|
|
|
| 1733 |
// + 1 word, if syllable number of the prefix > 1 (hungarian convention) |
1805 |
// + 1 word, if syllable number of the prefix > 1 (hungarian convention) |
| 1734 |
if (pfx && (get_syllable(pfx->getKey(),strlen(pfx->getKey())) > 1)) wordnum++; |
1806 |
if (pfx && (get_syllable(pfx->getKey(),strlen(pfx->getKey())) > 1)) wordnum++; |
| 1735 |
} |
1807 |
} |
| 1736 |
// END of LANG_hu section |
1808 |
// END of LANG_hu section |
| 1737 |
|
1809 |
|
| 1738 |
|
|
|
| 1739 |
// NEXT WORD(S) |
1810 |
// NEXT WORD(S) |
| 1740 |
rv_first = rv; |
1811 |
rv_first = rv; |
| 1741 |
st[i] = ch; |
1812 |
st[i] = ch; |
| 1742 |
|
1813 |
|
| 1743 |
do { // striple loop |
1814 |
do { // striple loop |
| 1744 |
|
1815 |
|
| 1745 |
// check simplifiedtriple |
1816 |
// check simplifiedtriple |
| 1746 |
if (simplifiedtriple) { |
1817 |
if (simplifiedtriple) { |
|
Lines 1758-1792
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1758 |
(compoundend && !words && TESTAFF(rv->astr, compoundend, rv->alen)) || |
1829 |
(compoundend && !words && TESTAFF(rv->astr, compoundend, rv->alen)) || |
| 1759 |
(numdefcpd && words && defcpd_check(&words, wnum + 1, rv, NULL,1))) || |
1830 |
(numdefcpd && words && defcpd_check(&words, wnum + 1, rv, NULL,1))) || |
| 1760 |
(scpd != 0 && checkcpdtable[scpd-1].cond2 != FLAG_NULL && |
1831 |
(scpd != 0 && checkcpdtable[scpd-1].cond2 != FLAG_NULL && |
| 1761 |
!TESTAFF(rv->astr, checkcpdtable[scpd-1].cond2, rv->alen)) |
1832 |
!TESTAFF(rv->astr, checkcpdtable[scpd-1].cond2, rv->alen)) |
| 1762 |
)) { |
1833 |
)) { |
| 1763 |
rv = rv->next_homonym; |
1834 |
rv = rv->next_homonym; |
| 1764 |
} |
1835 |
} |
| 1765 |
|
1836 |
|
|
|
1837 |
// check FORCEUCASE |
| 1838 |
if (rv && forceucase && (rv) && |
| 1839 |
(TESTAFF(rv->astr, forceucase, rv->alen)) && !(info && *info & SPELL_ORIGCAP)) rv = NULL; |
| 1840 |
|
| 1766 |
if (rv && words && words[wnum + 1]) return rv_first; |
1841 |
if (rv && words && words[wnum + 1]) return rv_first; |
| 1767 |
|
1842 |
|
| 1768 |
oldnumsyllable2 = numsyllable; |
1843 |
oldnumsyllable2 = numsyllable; |
| 1769 |
oldwordnum2 = wordnum; |
1844 |
oldwordnum2 = wordnum; |
| 1770 |
|
1845 |
|
|
|
1846 |
|
| 1771 |
// LANG_hu section: spec. Hungarian rule, XXX hardwired dictionary code |
1847 |
// LANG_hu section: spec. Hungarian rule, XXX hardwired dictionary code |
| 1772 |
if ((rv) && (langnum == LANG_hu) && (TESTAFF(rv->astr, 'I', rv->alen)) && !(TESTAFF(rv->astr, 'J', rv->alen))) { |
1848 |
if ((rv) && (langnum == LANG_hu) && (TESTAFF(rv->astr, 'I', rv->alen)) && !(TESTAFF(rv->astr, 'J', rv->alen))) { |
| 1773 |
numsyllable--; |
1849 |
numsyllable--; |
| 1774 |
} |
1850 |
} |
| 1775 |
// END of LANG_hu section |
1851 |
// END of LANG_hu section |
| 1776 |
|
1852 |
|
| 1777 |
// increment word number, if the second root has a compoundroot flag |
1853 |
// increment word number, if the second root has a compoundroot flag |
| 1778 |
if ((rv) && (compoundroot) && |
1854 |
if ((rv) && (compoundroot) && |
| 1779 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
1855 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
| 1780 |
wordnum++; |
1856 |
wordnum++; |
| 1781 |
} |
1857 |
} |
| 1782 |
|
1858 |
|
| 1783 |
// check forbiddenwords |
1859 |
// check forbiddenwords |
| 1784 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
1860 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
|
|
1861 |
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen) || |
| 1785 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) return NULL; |
1862 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) return NULL; |
| 1786 |
|
1863 |
|
| 1787 |
// second word is acceptable, as a root? |
1864 |
// second word is acceptable, as a root? |
| 1788 |
// hungarian conventions: compounding is acceptable, |
1865 |
// hungarian conventions: compounding is acceptable, |
| 1789 |
// when compound forms consist of 2 words, or if more, |
1866 |
// when compound forms consist of 2 words, or if more, |
| 1790 |
// then the syllable number of root words must be 6, or lesser. |
1867 |
// then the syllable number of root words must be 6, or lesser. |
| 1791 |
|
1868 |
|
| 1792 |
if ((rv) && ( |
1869 |
if ((rv) && ( |
|
Lines 1795-1811
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1795 |
) |
1872 |
) |
| 1796 |
&& ( |
1873 |
&& ( |
| 1797 |
((cpdwordmax==-1) || (wordnum+1<cpdwordmax)) || |
1874 |
((cpdwordmax==-1) || (wordnum+1<cpdwordmax)) || |
| 1798 |
((cpdmaxsyllable!=0) && |
1875 |
((cpdmaxsyllable!=0) && |
| 1799 |
(numsyllable + get_syllable(HENTRY_WORD(rv), rv->clen)<=cpdmaxsyllable)) |
1876 |
(numsyllable + get_syllable(HENTRY_WORD(rv), rv->clen)<=cpdmaxsyllable)) |
| 1800 |
) && |
1877 |
) && |
| 1801 |
( |
1878 |
( |
| 1802 |
// test CHECKCOMPOUNDPATTERN |
1879 |
// test CHECKCOMPOUNDPATTERN |
| 1803 |
!numcheckcpd || scpd != 0 || !cpdpat_check(word, i, rv_first, rv) |
1880 |
!numcheckcpd || scpd != 0 || !cpdpat_check(word, i, rv_first, rv, 0) |
| 1804 |
) && |
1881 |
) && |
| 1805 |
( |
1882 |
( |
| 1806 |
(!checkcompounddup || (rv != rv_first)) |
1883 |
(!checkcompounddup || (rv != rv_first)) |
| 1807 |
) |
1884 |
) |
| 1808 |
// test CHECKCOMPOUNDPATTERN conditions |
1885 |
// test CHECKCOMPOUNDPATTERN conditions |
| 1809 |
&& (scpd == 0 || checkcpdtable[scpd-1].cond2 == FLAG_NULL || |
1886 |
&& (scpd == 0 || checkcpdtable[scpd-1].cond2 == FLAG_NULL || |
| 1810 |
TESTAFF(rv->astr, checkcpdtable[scpd-1].cond2, rv->alen)) |
1887 |
TESTAFF(rv->astr, checkcpdtable[scpd-1].cond2, rv->alen)) |
| 1811 |
) |
1888 |
) |
|
Lines 1816-1864
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1816 |
} |
1893 |
} |
| 1817 |
|
1894 |
|
| 1818 |
numsyllable = oldnumsyllable2; |
1895 |
numsyllable = oldnumsyllable2; |
| 1819 |
wordnum = oldwordnum2; |
1896 |
wordnum = oldwordnum2; |
| 1820 |
|
1897 |
|
| 1821 |
// perhaps second word has prefix or/and suffix |
1898 |
// perhaps second word has prefix or/and suffix |
| 1822 |
sfx = NULL; |
1899 |
sfx = NULL; |
| 1823 |
sfxflag = FLAG_NULL; |
1900 |
sfxflag = FLAG_NULL; |
| 1824 |
rv = (compoundflag) ? affix_check((word+i),strlen(word+i), compoundflag, IN_CPD_END) : NULL; |
1901 |
rv = (compoundflag && !onlycpdrule) ? affix_check((word+i),strlen(word+i), compoundflag, IN_CPD_END) : NULL; |
| 1825 |
if (!rv && compoundend) { |
1902 |
if (!rv && compoundend && !onlycpdrule) { |
| 1826 |
sfx = NULL; |
1903 |
sfx = NULL; |
| 1827 |
pfx = NULL; |
1904 |
pfx = NULL; |
| 1828 |
rv = affix_check((word+i),strlen(word+i), compoundend, IN_CPD_END); |
1905 |
rv = affix_check((word+i),strlen(word+i), compoundend, IN_CPD_END); |
| 1829 |
} |
1906 |
} |
| 1830 |
|
1907 |
|
| 1831 |
if (!rv && numdefcpd && words) { |
1908 |
if (!rv && numdefcpd && words) { |
| 1832 |
rv = affix_check((word+i),strlen(word+i), 0, IN_CPD_END); |
1909 |
rv = affix_check((word+i),strlen(word+i), 0, IN_CPD_END); |
| 1833 |
if (rv && defcpd_check(&words, wnum + 1, rv, NULL, 1)) return rv_first; |
1910 |
if (rv && defcpd_check(&words, wnum + 1, rv, NULL, 1)) return rv_first; |
| 1834 |
rv = NULL; |
1911 |
rv = NULL; |
| 1835 |
} |
1912 |
} |
| 1836 |
|
1913 |
|
| 1837 |
// test CHECKCOMPOUNDPATTERN conditions (allowed forms) |
1914 |
// test CHECKCOMPOUNDPATTERN conditions (allowed forms) |
| 1838 |
if (rv && !(scpd == 0 || checkcpdtable[scpd-1].cond2 == FLAG_NULL || |
1915 |
if (rv && !(scpd == 0 || checkcpdtable[scpd-1].cond2 == FLAG_NULL || |
| 1839 |
TESTAFF(rv->astr, checkcpdtable[scpd-1].cond2, rv->alen))) rv = NULL; |
1916 |
TESTAFF(rv->astr, checkcpdtable[scpd-1].cond2, rv->alen))) rv = NULL; |
| 1840 |
|
1917 |
|
| 1841 |
// test CHECKCOMPOUNDPATTERN conditions (forbidden compounds) |
1918 |
// test CHECKCOMPOUNDPATTERN conditions (forbidden compounds) |
| 1842 |
if (rv && numcheckcpd && scpd == 0 && cpdpat_check(word, i, rv_first, rv)) rv = NULL; |
1919 |
if (rv && numcheckcpd && scpd == 0 && cpdpat_check(word, i, rv_first, rv, affixed)) rv = NULL; |
| 1843 |
|
1920 |
|
| 1844 |
// check non_compound flag in suffix and prefix |
1921 |
// check non_compound flag in suffix and prefix |
| 1845 |
if ((rv) && |
1922 |
if ((rv) && |
| 1846 |
((pfx && pfx->getCont() && |
1923 |
((pfx && pfx->getCont() && |
| 1847 |
TESTAFF(pfx->getCont(), compoundforbidflag, |
1924 |
TESTAFF(pfx->getCont(), compoundforbidflag, |
| 1848 |
pfx->getContLen())) || |
1925 |
pfx->getContLen())) || |
| 1849 |
(sfx && sfx->getCont() && |
1926 |
(sfx && sfx->getCont() && |
| 1850 |
TESTAFF(sfx->getCont(), compoundforbidflag, |
1927 |
TESTAFF(sfx->getCont(), compoundforbidflag, |
| 1851 |
sfx->getContLen())))) { |
1928 |
sfx->getContLen())))) { |
| 1852 |
rv = NULL; |
1929 |
rv = NULL; |
| 1853 |
} |
1930 |
} |
| 1854 |
|
1931 |
|
|
|
1932 |
// check FORCEUCASE |
| 1933 |
if (rv && forceucase && (rv) && |
| 1934 |
(TESTAFF(rv->astr, forceucase, rv->alen)) && !(info && *info & SPELL_ORIGCAP)) rv = NULL; |
| 1935 |
|
| 1855 |
// check forbiddenwords |
1936 |
// check forbiddenwords |
| 1856 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
1937 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
|
|
1938 |
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen) || |
| 1857 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) return NULL; |
1939 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) return NULL; |
| 1858 |
|
1940 |
|
| 1859 |
// pfxappnd = prefix of word+i, or NULL |
1941 |
// pfxappnd = prefix of word+i, or NULL |
| 1860 |
// calculate syllable number of prefix. |
1942 |
// calculate syllable number of prefix. |
| 1861 |
// hungarian convention: when syllable number of prefix is more, |
1943 |
// hungarian convention: when syllable number of prefix is more, |
| 1862 |
// than 1, the prefix+word counts as two words. |
1944 |
// than 1, the prefix+word counts as two words. |
| 1863 |
|
1945 |
|
| 1864 |
if (langnum == LANG_hu) { |
1946 |
if (langnum == LANG_hu) { |
|
Lines 1878-1894
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1878 |
|
1960 |
|
| 1879 |
// increment syllable num, if last word has a SYLLABLENUM flag |
1961 |
// increment syllable num, if last word has a SYLLABLENUM flag |
| 1880 |
// and the suffix is beginning `s' |
1962 |
// and the suffix is beginning `s' |
| 1881 |
|
1963 |
|
| 1882 |
if (cpdsyllablenum) { |
1964 |
if (cpdsyllablenum) { |
| 1883 |
switch (sfxflag) { |
1965 |
switch (sfxflag) { |
| 1884 |
case 'c': { numsyllable+=2; break; } |
1966 |
case 'c': { numsyllable+=2; break; } |
| 1885 |
case 'J': { numsyllable += 1; break; } |
1967 |
case 'J': { numsyllable += 1; break; } |
| 1886 |
case 'I': { if (TESTAFF(rv->astr, 'J', rv->alen)) numsyllable += 1; break; } |
1968 |
case 'I': { if (rv && TESTAFF(rv->astr, 'J', rv->alen)) numsyllable += 1; break; } |
| 1887 |
} |
1969 |
} |
| 1888 |
} |
1970 |
} |
| 1889 |
} |
1971 |
} |
| 1890 |
|
1972 |
|
| 1891 |
// increment word number, if the second word has a compoundroot flag |
1973 |
// increment word number, if the second word has a compoundroot flag |
| 1892 |
if ((rv) && (compoundroot) && |
1974 |
if ((rv) && (compoundroot) && |
| 1893 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
1975 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
| 1894 |
wordnum++; |
1976 |
wordnum++; |
|
Lines 1913-1937
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1913 |
} |
1995 |
} |
| 1914 |
|
1996 |
|
| 1915 |
numsyllable = oldnumsyllable2; |
1997 |
numsyllable = oldnumsyllable2; |
| 1916 |
wordnum = oldwordnum2; |
1998 |
wordnum = oldwordnum2; |
| 1917 |
|
1999 |
|
| 1918 |
// perhaps second word is a compound word (recursive call) |
2000 |
// perhaps second word is a compound word (recursive call) |
| 1919 |
if (wordnum < maxwordnum) { |
2001 |
if (wordnum < maxwordnum) { |
| 1920 |
rv = compound_check((st+i),strlen(st+i), wordnum+1, |
2002 |
rv = compound_check((st+i),strlen(st+i), wordnum+1, |
| 1921 |
numsyllable, maxwordnum, wnum + 1, words, 0, is_sug); |
2003 |
numsyllable, maxwordnum, wnum + 1, words, 0, is_sug, info); |
| 1922 |
if (rv && numcheckcpd && ((scpd == 0 && cpdpat_check(word, i, rv_first, rv)) || |
2004 |
|
| 1923 |
(scpd != 0 && !cpdpat_check(word, i, rv_first, rv)))) rv = NULL; |
2005 |
if (rv && numcheckcpd && ((scpd == 0 && cpdpat_check(word, i, rv_first, rv, affixed)) || |
|
|
2006 |
(scpd != 0 && !cpdpat_check(word, i, rv_first, rv, affixed)))) rv = NULL; |
| 1924 |
} else { |
2007 |
} else { |
| 1925 |
rv=NULL; |
2008 |
rv=NULL; |
| 1926 |
} |
2009 |
} |
| 1927 |
if (rv) { |
2010 |
if (rv) { |
| 1928 |
// forbid compound word, if it is a non compound word with typical fault |
2011 |
// forbid compound word, if it is a non compound word with typical fault |
| 1929 |
if (checkcompoundrep && cpdrep_check(word, len)) return NULL; |
2012 |
if (checkcompoundrep || forbiddenword) { |
|
|
2013 |
struct hentry * rv2 = NULL; |
| 2014 |
|
| 2015 |
if (checkcompoundrep && cpdrep_check(word, len)) return NULL; |
| 2016 |
|
| 2017 |
// check first part |
| 2018 |
if (strncmp(rv->word, word + i, rv->blen) == 0) { |
| 2019 |
char r = *(st + i + rv->blen); |
| 2020 |
*(st + i + rv->blen) = '\0'; |
| 2021 |
|
| 2022 |
if (checkcompoundrep && cpdrep_check(st, i + rv->blen)) { |
| 2023 |
*(st + i + rv->blen) = r; |
| 2024 |
continue; |
| 2025 |
} |
| 2026 |
|
| 2027 |
if (forbiddenword) { |
| 2028 |
rv2 = lookup(word); |
| 2029 |
if (!rv2) rv2 = affix_check(word, len); |
| 2030 |
if (rv2 && rv2->astr && TESTAFF(rv2->astr, forbiddenword, rv2->alen) && |
| 2031 |
(strncmp(rv2->word, st, i + rv->blen) == 0)) { |
| 2032 |
return NULL; |
| 2033 |
} |
| 2034 |
} |
| 2035 |
*(st + i + rv->blen) = r; |
| 2036 |
} |
| 2037 |
} |
| 1930 |
return rv_first; |
2038 |
return rv_first; |
| 1931 |
} |
2039 |
} |
| 1932 |
} while (striple && !checkedstriple); // end of striple loop |
2040 |
} while (striple && !checkedstriple); // end of striple loop |
| 1933 |
|
2041 |
|
| 1934 |
if (checkedstriple) { |
2042 |
if (checkedstriple) { |
| 1935 |
i++; |
2043 |
i++; |
| 1936 |
checkedstriple = 0; |
2044 |
checkedstriple = 0; |
| 1937 |
striple = 0; |
2045 |
striple = 0; |
|
Lines 1943-1969
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1943 |
i = soldi; |
2051 |
i = soldi; |
| 1944 |
soldi = 0; |
2052 |
soldi = 0; |
| 1945 |
len = oldlen; |
2053 |
len = oldlen; |
| 1946 |
cmin = oldcmin; |
2054 |
cmin = oldcmin; |
| 1947 |
cmax = oldcmax; |
2055 |
cmax = oldcmax; |
| 1948 |
} |
2056 |
} |
| 1949 |
scpd++; |
2057 |
scpd++; |
| 1950 |
|
2058 |
|
| 1951 |
} while (simplifiedcpd && scpd <= numcheckcpd); // end of simplifiedcpd loop |
2059 |
|
|
|
2060 |
} while (!onlycpdrule && simplifiedcpd && scpd <= numcheckcpd); // end of simplifiedcpd loop |
| 2061 |
|
| 2062 |
scpd = 0; |
| 2063 |
wordnum = oldwordnum; |
| 2064 |
numsyllable = oldnumsyllable; |
| 1952 |
|
2065 |
|
| 1953 |
if (soldi != 0) { |
2066 |
if (soldi != 0) { |
| 1954 |
i = soldi; |
2067 |
i = soldi; |
| 1955 |
strcpy(st, word); // XXX add more optim. |
2068 |
strcpy(st, word); // XXX add more optim. |
| 1956 |
soldi = 0; |
2069 |
soldi = 0; |
| 1957 |
} else st[i] = ch; |
2070 |
} else st[i] = ch; |
| 1958 |
|
2071 |
|
| 1959 |
scpd = 0; |
2072 |
} while (numdefcpd && oldwordnum == 0 && !onlycpdrule && (onlycpdrule = 1)); // end of onlycpd loop |
| 1960 |
wordnum = oldwordnum; |
2073 |
|
| 1961 |
numsyllable = oldnumsyllable; |
|
|
| 1962 |
} |
2074 |
} |
| 1963 |
|
2075 |
|
| 1964 |
return NULL; |
2076 |
return NULL; |
| 1965 |
} |
2077 |
} |
| 1966 |
|
2078 |
|
| 1967 |
// check if compound word is correctly spelled |
2079 |
// check if compound word is correctly spelled |
| 1968 |
// hu_mov_rule = spec. Hungarian rule (XXX) |
2080 |
// hu_mov_rule = spec. Hungarian rule (XXX) |
| 1969 |
int AffixMgr::compound_check_morph(const char * word, int len, |
2081 |
int AffixMgr::compound_check_morph(const char * word, int len, |
|
Lines 1981-2049
int AffixMgr::compound_check_morph(const
|
Link Here
|
|---|
|
| 1981 |
char ch; |
2093 |
char ch; |
| 1982 |
|
2094 |
|
| 1983 |
int checked_prefix; |
2095 |
int checked_prefix; |
| 1984 |
char presult[MAXLNLEN]; |
2096 |
char presult[MAXLNLEN]; |
| 1985 |
|
2097 |
|
| 1986 |
int cmin; |
2098 |
int cmin; |
| 1987 |
int cmax; |
2099 |
int cmax; |
| 1988 |
|
2100 |
|
|
|
2101 |
int onlycpdrule; |
| 2102 |
int affixed = 0; |
| 2103 |
hentry ** oldwords = words; |
| 2104 |
|
| 1989 |
setcminmax(&cmin, &cmax, word, len); |
2105 |
setcminmax(&cmin, &cmax, word, len); |
| 1990 |
|
2106 |
|
| 1991 |
strcpy(st, word); |
2107 |
strcpy(st, word); |
| 1992 |
|
2108 |
|
| 1993 |
for (i = cmin; i < cmax; i++) { |
2109 |
for (i = cmin; i < cmax; i++) { |
| 1994 |
oldnumsyllable = numsyllable; |
2110 |
oldnumsyllable = numsyllable; |
| 1995 |
oldwordnum = wordnum; |
2111 |
oldwordnum = wordnum; |
| 1996 |
checked_prefix = 0; |
2112 |
checked_prefix = 0; |
| 1997 |
|
2113 |
|
| 1998 |
// go to end of the UTF-8 character |
2114 |
// go to end of the UTF-8 character |
| 1999 |
if (utf8) { |
2115 |
if (utf8) { |
| 2000 |
for (; (st[i] & 0xc0) == 0x80; i++); |
2116 |
for (; (st[i] & 0xc0) == 0x80; i++); |
| 2001 |
if (i >= cmax) return 0; |
2117 |
if (i >= cmax) return 0; |
| 2002 |
} |
2118 |
} |
| 2003 |
|
2119 |
|
|
|
2120 |
words = oldwords; |
| 2121 |
onlycpdrule = (words) ? 1 : 0; |
| 2122 |
|
| 2123 |
do { // onlycpdrule loop |
| 2124 |
|
| 2125 |
oldnumsyllable = numsyllable; |
| 2126 |
oldwordnum = wordnum; |
| 2127 |
checked_prefix = 0; |
| 2128 |
|
| 2004 |
ch = st[i]; |
2129 |
ch = st[i]; |
| 2005 |
st[i] = '\0'; |
2130 |
st[i] = '\0'; |
| 2006 |
sfx = NULL; |
2131 |
sfx = NULL; |
| 2007 |
|
2132 |
|
| 2008 |
// FIRST WORD |
2133 |
// FIRST WORD |
|
|
2134 |
|
| 2135 |
affixed = 1; |
| 2136 |
|
| 2009 |
*presult = '\0'; |
2137 |
*presult = '\0'; |
| 2010 |
if (partresult) mystrcat(presult, partresult, MAXLNLEN); |
2138 |
if (partresult) mystrcat(presult, partresult, MAXLNLEN); |
| 2011 |
|
2139 |
|
| 2012 |
rv = lookup(st); // perhaps without prefix |
2140 |
rv = lookup(st); // perhaps without prefix |
| 2013 |
|
2141 |
|
| 2014 |
// search homonym with compound flag |
2142 |
// search homonym with compound flag |
| 2015 |
while ((rv) && !hu_mov_rule && |
2143 |
while ((rv) && !hu_mov_rule && |
| 2016 |
((needaffix && TESTAFF(rv->astr, needaffix, rv->alen)) || |
2144 |
((needaffix && TESTAFF(rv->astr, needaffix, rv->alen)) || |
| 2017 |
!((compoundflag && !words && TESTAFF(rv->astr, compoundflag, rv->alen)) || |
2145 |
!((compoundflag && !words && !onlycpdrule && TESTAFF(rv->astr, compoundflag, rv->alen)) || |
| 2018 |
(compoundbegin && !wordnum && |
2146 |
(compoundbegin && !wordnum && !onlycpdrule && |
| 2019 |
TESTAFF(rv->astr, compoundbegin, rv->alen)) || |
2147 |
TESTAFF(rv->astr, compoundbegin, rv->alen)) || |
| 2020 |
(compoundmiddle && wordnum && !words && |
2148 |
(compoundmiddle && wordnum && !words && !onlycpdrule && |
| 2021 |
TESTAFF(rv->astr, compoundmiddle, rv->alen)) || |
2149 |
TESTAFF(rv->astr, compoundmiddle, rv->alen)) || |
| 2022 |
(numdefcpd && |
2150 |
(numdefcpd && onlycpdrule && |
| 2023 |
((!words && !wordnum && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0)) || |
2151 |
((!words && !wordnum && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0)) || |
| 2024 |
(words && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0)))) |
2152 |
(words && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0)))) |
| 2025 |
))) { |
2153 |
))) { |
| 2026 |
rv = rv->next_homonym; |
2154 |
rv = rv->next_homonym; |
| 2027 |
} |
2155 |
} |
| 2028 |
|
2156 |
|
|
|
2157 |
if (rv) affixed = 0; |
| 2158 |
|
| 2029 |
if (rv) { |
2159 |
if (rv) { |
| 2030 |
sprintf(presult + strlen(presult), "%c%s%s", MSEP_FLD, MORPH_PART, st); |
2160 |
sprintf(presult + strlen(presult), "%c%s%s", MSEP_FLD, MORPH_PART, st); |
| 2031 |
if (!HENTRY_FIND(rv, MORPH_STEM)) { |
2161 |
if (!HENTRY_FIND(rv, MORPH_STEM)) { |
| 2032 |
sprintf(presult + strlen(presult), "%c%s%s", MSEP_FLD, MORPH_STEM, st); |
2162 |
sprintf(presult + strlen(presult), "%c%s%s", MSEP_FLD, MORPH_STEM, st); |
| 2033 |
} |
2163 |
} |
| 2034 |
// store the pointer of the hash entry |
2164 |
// store the pointer of the hash entry |
| 2035 |
// sprintf(presult + strlen(presult), "%c%s%p", MSEP_FLD, MORPH_HENTRY, rv); |
2165 |
// sprintf(presult + strlen(presult), "%c%s%p", MSEP_FLD, MORPH_HENTRY, rv); |
| 2036 |
if (HENTRY_DATA(rv)) { |
2166 |
if (HENTRY_DATA(rv)) { |
| 2037 |
sprintf(presult + strlen(presult), "%c%s", MSEP_FLD, HENTRY_DATA2(rv)); |
2167 |
sprintf(presult + strlen(presult), "%c%s", MSEP_FLD, HENTRY_DATA2(rv)); |
| 2038 |
} |
2168 |
} |
| 2039 |
} |
2169 |
} |
|
|
2170 |
|
| 2040 |
if (!rv) { |
2171 |
if (!rv) { |
| 2041 |
if (compoundflag && |
2172 |
if (onlycpdrule) break; |
|
|
2173 |
if (compoundflag && |
| 2042 |
!(rv = prefix_check(st, i, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN, compoundflag))) { |
2174 |
!(rv = prefix_check(st, i, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN, compoundflag))) { |
| 2043 |
if ((rv = suffix_check(st, i, 0, NULL, NULL, 0, NULL, |
2175 |
if ((rv = suffix_check(st, i, 0, NULL, NULL, 0, NULL, |
| 2044 |
FLAG_NULL, compoundflag, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN)) && !hu_mov_rule && |
2176 |
FLAG_NULL, compoundflag, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN)) && !hu_mov_rule && |
| 2045 |
sfx->getCont() && |
2177 |
sfx->getCont() && |
| 2046 |
((compoundforbidflag && TESTAFF(sfx->getCont(), compoundforbidflag, |
2178 |
((compoundforbidflag && TESTAFF(sfx->getCont(), compoundforbidflag, |
| 2047 |
sfx->getContLen())) || (compoundend && |
2179 |
sfx->getContLen())) || (compoundend && |
| 2048 |
TESTAFF(sfx->getCont(), compoundend, |
2180 |
TESTAFF(sfx->getCont(), compoundend, |
| 2049 |
sfx->getContLen())))) { |
2181 |
sfx->getContLen())))) { |
|
Lines 2075-2090
int AffixMgr::compound_check_morph(const
|
Link Here
|
|---|
|
| 2075 |
sprintf(presult + strlen(presult), "%c%s%s%s", MSEP_FLD, |
2207 |
sprintf(presult + strlen(presult), "%c%s%s%s", MSEP_FLD, |
| 2076 |
MORPH_PART, st, line_uniq_app(&p, MSEP_REC)); |
2208 |
MORPH_PART, st, line_uniq_app(&p, MSEP_REC)); |
| 2077 |
} |
2209 |
} |
| 2078 |
if (p) free(p); |
2210 |
if (p) free(p); |
| 2079 |
checked_prefix = 1; |
2211 |
checked_prefix = 1; |
| 2080 |
} |
2212 |
} |
| 2081 |
// else check forbiddenwords |
2213 |
// else check forbiddenwords |
| 2082 |
} else if (rv->astr && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
2214 |
} else if (rv->astr && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
|
|
2215 |
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen) || |
| 2083 |
TESTAFF(rv->astr, needaffix, rv->alen))) { |
2216 |
TESTAFF(rv->astr, needaffix, rv->alen))) { |
| 2084 |
st[i] = ch; |
2217 |
st[i] = ch; |
| 2085 |
continue; |
2218 |
continue; |
| 2086 |
} |
2219 |
} |
| 2087 |
|
2220 |
|
| 2088 |
// check non_compound flag in suffix and prefix |
2221 |
// check non_compound flag in suffix and prefix |
| 2089 |
if ((rv) && !hu_mov_rule && |
2222 |
if ((rv) && !hu_mov_rule && |
| 2090 |
((pfx && pfx->getCont() && |
2223 |
((pfx && pfx->getCont() && |
|
Lines 2114-2130
int AffixMgr::compound_check_morph(const
|
Link Here
|
|---|
|
| 2114 |
pfx->getContLen())) || |
2247 |
pfx->getContLen())) || |
| 2115 |
(sfx && sfx->getCont() && |
2248 |
(sfx && sfx->getCont() && |
| 2116 |
TESTAFF(sfx->getCont(), compoundmiddle, |
2249 |
TESTAFF(sfx->getCont(), compoundmiddle, |
| 2117 |
sfx->getContLen())))) { |
2250 |
sfx->getContLen())))) { |
| 2118 |
rv = NULL; |
2251 |
rv = NULL; |
| 2119 |
} |
2252 |
} |
| 2120 |
|
2253 |
|
| 2121 |
// check forbiddenwords |
2254 |
// check forbiddenwords |
| 2122 |
if ((rv) && (rv->astr) && TESTAFF(rv->astr, forbiddenword, rv->alen)) continue; |
2255 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) |
|
|
2256 |
|| TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen))) continue; |
| 2123 |
|
2257 |
|
| 2124 |
// increment word number, if the second root has a compoundroot flag |
2258 |
// increment word number, if the second root has a compoundroot flag |
| 2125 |
if ((rv) && (compoundroot) && |
2259 |
if ((rv) && (compoundroot) && |
| 2126 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
2260 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
| 2127 |
wordnum++; |
2261 |
wordnum++; |
| 2128 |
} |
2262 |
} |
| 2129 |
|
2263 |
|
| 2130 |
// first word is acceptable in compound words? |
2264 |
// first word is acceptable in compound words? |
|
Lines 2146-2162
int AffixMgr::compound_check_morph(const
|
Link Here
|
|---|
|
| 2146 |
&& ! (( checkcompoundtriple && !words && // test triple letters |
2280 |
&& ! (( checkcompoundtriple && !words && // test triple letters |
| 2147 |
(word[i-1]==word[i]) && ( |
2281 |
(word[i-1]==word[i]) && ( |
| 2148 |
((i>1) && (word[i-1]==word[i-2])) || |
2282 |
((i>1) && (word[i-1]==word[i-2])) || |
| 2149 |
((word[i-1]==word[i+1])) // may be word[i+1] == '\0' |
2283 |
((word[i-1]==word[i+1])) // may be word[i+1] == '\0' |
| 2150 |
) |
2284 |
) |
| 2151 |
) || |
2285 |
) || |
| 2152 |
( |
2286 |
( |
| 2153 |
// test CHECKCOMPOUNDPATTERN |
2287 |
// test CHECKCOMPOUNDPATTERN |
| 2154 |
numcheckcpd && !words && cpdpat_check(word, i, rv, NULL) |
2288 |
numcheckcpd && !words && cpdpat_check(word, i, rv, NULL, affixed) |
| 2155 |
) || |
2289 |
) || |
| 2156 |
( |
2290 |
( |
| 2157 |
checkcompoundcase && !words && cpdcase_check(word, i) |
2291 |
checkcompoundcase && !words && cpdcase_check(word, i) |
| 2158 |
)) |
2292 |
)) |
| 2159 |
) |
2293 |
) |
| 2160 |
// LANG_hu section: spec. Hungarian rule |
2294 |
// LANG_hu section: spec. Hungarian rule |
| 2161 |
|| ((!rv) && (langnum == LANG_hu) && hu_mov_rule && (rv = affix_check(st,i)) && |
2295 |
|| ((!rv) && (langnum == LANG_hu) && hu_mov_rule && (rv = affix_check(st,i)) && |
| 2162 |
(sfx && sfx->getCont() && ( |
2296 |
(sfx && sfx->getCont() && ( |
|
Lines 2222-2238
int AffixMgr::compound_check_morph(const
|
Link Here
|
|---|
|
| 2222 |
// END of LANG_hu section |
2356 |
// END of LANG_hu section |
| 2223 |
// increment word number, if the second root has a compoundroot flag |
2357 |
// increment word number, if the second root has a compoundroot flag |
| 2224 |
if ((rv) && (compoundroot) && |
2358 |
if ((rv) && (compoundroot) && |
| 2225 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
2359 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
| 2226 |
wordnum++; |
2360 |
wordnum++; |
| 2227 |
} |
2361 |
} |
| 2228 |
|
2362 |
|
| 2229 |
// check forbiddenwords |
2363 |
// check forbiddenwords |
| 2230 |
if ((rv) && (rv->astr) && TESTAFF(rv->astr, forbiddenword, rv->alen)) { |
2364 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
|
|
2365 |
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen))) { |
| 2231 |
st[i] = ch; |
2366 |
st[i] = ch; |
| 2232 |
continue; |
2367 |
continue; |
| 2233 |
} |
2368 |
} |
| 2234 |
|
2369 |
|
| 2235 |
// second word is acceptable, as a root? |
2370 |
// second word is acceptable, as a root? |
| 2236 |
// hungarian conventions: compounding is acceptable, |
2371 |
// hungarian conventions: compounding is acceptable, |
| 2237 |
// when compound forms consist of 2 words, or if more, |
2372 |
// when compound forms consist of 2 words, or if more, |
| 2238 |
// then the syllable number of root words must be 6, or lesser. |
2373 |
// then the syllable number of root words must be 6, or lesser. |
|
Lines 2276-2294
int AffixMgr::compound_check_morph(const
|
Link Here
|
|---|
|
| 2276 |
|
2411 |
|
| 2277 |
numsyllable = oldnumsyllable2 ; |
2412 |
numsyllable = oldnumsyllable2 ; |
| 2278 |
wordnum = oldwordnum2; |
2413 |
wordnum = oldwordnum2; |
| 2279 |
|
2414 |
|
| 2280 |
// perhaps second word has prefix or/and suffix |
2415 |
// perhaps second word has prefix or/and suffix |
| 2281 |
sfx = NULL; |
2416 |
sfx = NULL; |
| 2282 |
sfxflag = FLAG_NULL; |
2417 |
sfxflag = FLAG_NULL; |
| 2283 |
|
2418 |
|
| 2284 |
if (compoundflag) rv = affix_check((word+i),strlen(word+i), compoundflag); else rv = NULL; |
2419 |
if (compoundflag && !onlycpdrule) rv = affix_check((word+i),strlen(word+i), compoundflag); else rv = NULL; |
| 2285 |
|
2420 |
|
| 2286 |
if (!rv && compoundend) { |
2421 |
if (!rv && compoundend && !onlycpdrule) { |
| 2287 |
sfx = NULL; |
2422 |
sfx = NULL; |
| 2288 |
pfx = NULL; |
2423 |
pfx = NULL; |
| 2289 |
rv = affix_check((word+i),strlen(word+i), compoundend); |
2424 |
rv = affix_check((word+i),strlen(word+i), compoundend); |
| 2290 |
} |
2425 |
} |
| 2291 |
|
2426 |
|
| 2292 |
if (!rv && numdefcpd && words) { |
2427 |
if (!rv && numdefcpd && words) { |
| 2293 |
rv = affix_check((word+i),strlen(word+i), 0, IN_CPD_END); |
2428 |
rv = affix_check((word+i),strlen(word+i), 0, IN_CPD_END); |
| 2294 |
if (rv && words && defcpd_check(&words, wnum + 1, rv, NULL, 1)) { |
2429 |
if (rv && words && defcpd_check(&words, wnum + 1, rv, NULL, 1)) { |
|
Lines 2316-2332
int AffixMgr::compound_check_morph(const
|
Link Here
|
|---|
|
| 2316 |
pfx->getContLen())) || |
2451 |
pfx->getContLen())) || |
| 2317 |
(sfx && sfx->getCont() && |
2452 |
(sfx && sfx->getCont() && |
| 2318 |
TESTAFF(sfx->getCont(), compoundforbidflag, |
2453 |
TESTAFF(sfx->getCont(), compoundforbidflag, |
| 2319 |
sfx->getContLen())))) { |
2454 |
sfx->getContLen())))) { |
| 2320 |
rv = NULL; |
2455 |
rv = NULL; |
| 2321 |
} |
2456 |
} |
| 2322 |
|
2457 |
|
| 2323 |
// check forbiddenwords |
2458 |
// check forbiddenwords |
| 2324 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr,forbiddenword,rv->alen)) |
2459 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr,forbiddenword,rv->alen) || |
|
|
2460 |
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen)) |
| 2325 |
&& (! TESTAFF(rv->astr, needaffix, rv->alen))) { |
2461 |
&& (! TESTAFF(rv->astr, needaffix, rv->alen))) { |
| 2326 |
st[i] = ch; |
2462 |
st[i] = ch; |
| 2327 |
continue; |
2463 |
continue; |
| 2328 |
} |
2464 |
} |
| 2329 |
|
2465 |
|
| 2330 |
if (langnum == LANG_hu) { |
2466 |
if (langnum == LANG_hu) { |
| 2331 |
// calculate syllable number of the word |
2467 |
// calculate syllable number of the word |
| 2332 |
numsyllable += get_syllable(word + i, strlen(word + i)); |
2468 |
numsyllable += get_syllable(word + i, strlen(word + i)); |
|
Lines 2397-2412
int AffixMgr::compound_check_morph(const
|
Link Here
|
|---|
|
| 2397 |
numsyllable, maxwordnum, wnum + 1, words, 0, result, presult); |
2533 |
numsyllable, maxwordnum, wnum + 1, words, 0, result, presult); |
| 2398 |
} else { |
2534 |
} else { |
| 2399 |
rv=NULL; |
2535 |
rv=NULL; |
| 2400 |
} |
2536 |
} |
| 2401 |
} |
2537 |
} |
| 2402 |
st[i] = ch; |
2538 |
st[i] = ch; |
| 2403 |
wordnum = oldwordnum; |
2539 |
wordnum = oldwordnum; |
| 2404 |
numsyllable = oldnumsyllable; |
2540 |
numsyllable = oldnumsyllable; |
|
|
2541 |
|
| 2542 |
} while (numdefcpd && oldwordnum == 0 && !onlycpdrule && (onlycpdrule = 1)); // end of onlycpd loop |
| 2543 |
|
| 2405 |
} |
2544 |
} |
| 2406 |
return 0; |
2545 |
return 0; |
| 2407 |
} |
2546 |
} |
| 2408 |
|
2547 |
|
| 2409 |
// return 1 if s1 (reversed) is a leading subset of end of s2 |
2548 |
// return 1 if s1 (reversed) is a leading subset of end of s2 |
| 2410 |
/* inline int AffixMgr::isRevSubset(const char * s1, const char * end_of_s2, int len) |
2549 |
/* inline int AffixMgr::isRevSubset(const char * s1, const char * end_of_s2, int len) |
| 2411 |
{ |
2550 |
{ |
| 2412 |
while ((len > 0) && *s1 && (*s1 == *end_of_s2)) { |
2551 |
while ((len > 0) && *s1 && (*s1 == *end_of_s2)) { |
|
Lines 2452-2490
struct hentry * AffixMgr::suffix_check (
|
Link Here
|
|---|
|
| 2452 |
circumfix, ep->getContLen())) && |
2591 |
circumfix, ep->getContLen())) && |
| 2453 |
(!se->getCont() || !(TESTAFF(se->getCont(),circumfix,se->getContLen())))) || |
2592 |
(!se->getCont() || !(TESTAFF(se->getCont(),circumfix,se->getContLen())))) || |
| 2454 |
// circumfix flag in prefix AND suffix |
2593 |
// circumfix flag in prefix AND suffix |
| 2455 |
((ppfx && (ep->getCont()) && TESTAFF(ep->getCont(), |
2594 |
((ppfx && (ep->getCont()) && TESTAFF(ep->getCont(), |
| 2456 |
circumfix, ep->getContLen())) && |
2595 |
circumfix, ep->getContLen())) && |
| 2457 |
(se->getCont() && (TESTAFF(se->getCont(),circumfix,se->getContLen()))))) && |
2596 |
(se->getCont() && (TESTAFF(se->getCont(),circumfix,se->getContLen()))))) && |
| 2458 |
// fogemorpheme |
2597 |
// fogemorpheme |
| 2459 |
(in_compound || |
2598 |
(in_compound || |
| 2460 |
!((se->getCont() && (TESTAFF(se->getCont(), onlyincompound, se->getContLen()))))) && |
2599 |
!(se->getCont() && (TESTAFF(se->getCont(), onlyincompound, se->getContLen())))) && |
| 2461 |
// needaffix on prefix or first suffix |
2600 |
// needaffix on prefix or first suffix |
| 2462 |
(cclass || |
2601 |
(cclass || |
| 2463 |
!(se->getCont() && TESTAFF(se->getCont(), needaffix, se->getContLen())) || |
2602 |
!(se->getCont() && TESTAFF(se->getCont(), needaffix, se->getContLen())) || |
| 2464 |
(ppfx && !((ep->getCont()) && |
2603 |
(ppfx && !((ep->getCont()) && |
| 2465 |
TESTAFF(ep->getCont(), needaffix, |
2604 |
TESTAFF(ep->getCont(), needaffix, |
| 2466 |
ep->getContLen()))) |
2605 |
ep->getContLen()))) |
| 2467 |
) |
2606 |
)) { |
| 2468 |
) { |
|
|
| 2469 |
rv = se->checkword(word,len, sfxopts, ppfx, wlst, maxSug, ns, (FLAG) cclass, |
2607 |
rv = se->checkword(word,len, sfxopts, ppfx, wlst, maxSug, ns, (FLAG) cclass, |
| 2470 |
needflag, (in_compound ? 0 : onlyincompound)); |
2608 |
needflag, (in_compound ? 0 : onlyincompound)); |
| 2471 |
if (rv) { |
2609 |
if (rv) { |
| 2472 |
sfx=se; // BUG: sfx not stateless |
2610 |
sfx=se; // BUG: sfx not stateless |
| 2473 |
return rv; |
2611 |
return rv; |
| 2474 |
} |
2612 |
} |
| 2475 |
} |
2613 |
} |
| 2476 |
} |
2614 |
} |
| 2477 |
se = se->getNext(); |
2615 |
se = se->getNext(); |
| 2478 |
} |
2616 |
} |
| 2479 |
|
2617 |
|
| 2480 |
// now handle the general case |
2618 |
// now handle the general case |
| 2481 |
if (len == 0) return NULL; // FULLSTRIP |
2619 |
if (len == 0) return NULL; // FULLSTRIP |
| 2482 |
unsigned char sp = *((const unsigned char *)(word + len - 1)); |
2620 |
unsigned char sp= *((const unsigned char *)(word + len - 1)); |
| 2483 |
SfxEntry * sptr = sStart[sp]; |
2621 |
SfxEntry * sptr = sStart[sp]; |
| 2484 |
|
2622 |
|
| 2485 |
while (sptr) { |
2623 |
while (sptr) { |
| 2486 |
if (isRevSubset(sptr->getKey(), word + len - 1, len) |
2624 |
if (isRevSubset(sptr->getKey(), word + len - 1, len) |
| 2487 |
) { |
2625 |
) { |
| 2488 |
// suffixes are not allowed in beginning of compounds |
2626 |
// suffixes are not allowed in beginning of compounds |
| 2489 |
if ((((in_compound != IN_CPD_BEGIN)) || // && !cclass |
2627 |
if ((((in_compound != IN_CPD_BEGIN)) || // && !cclass |
| 2490 |
// except when signed with compoundpermitflag flag |
2628 |
// except when signed with compoundpermitflag flag |
|
Lines 2503-2519
struct hentry * AffixMgr::suffix_check (
|
Link Here
|
|---|
|
| 2503 |
!((sptr->getCont() && (TESTAFF(sptr->getCont(), onlyincompound, sptr->getContLen()))))) && |
2641 |
!((sptr->getCont() && (TESTAFF(sptr->getCont(), onlyincompound, sptr->getContLen()))))) && |
| 2504 |
// needaffix on prefix or first suffix |
2642 |
// needaffix on prefix or first suffix |
| 2505 |
(cclass || |
2643 |
(cclass || |
| 2506 |
!(sptr->getCont() && TESTAFF(sptr->getCont(), needaffix, sptr->getContLen())) || |
2644 |
!(sptr->getCont() && TESTAFF(sptr->getCont(), needaffix, sptr->getContLen())) || |
| 2507 |
(ppfx && !((ep->getCont()) && |
2645 |
(ppfx && !((ep->getCont()) && |
| 2508 |
TESTAFF(ep->getCont(), needaffix, |
2646 |
TESTAFF(ep->getCont(), needaffix, |
| 2509 |
ep->getContLen()))) |
2647 |
ep->getContLen()))) |
| 2510 |
) |
2648 |
) |
| 2511 |
) { |
2649 |
) if (in_compound != IN_CPD_END || ppfx || !(sptr->getCont() && TESTAFF(sptr->getCont(), onlyincompound, sptr->getContLen()))) { |
| 2512 |
rv = sptr->checkword(word,len, sfxopts, ppfx, wlst, |
2650 |
rv = sptr->checkword(word,len, sfxopts, ppfx, wlst, |
| 2513 |
maxSug, ns, cclass, needflag, (in_compound ? 0 : onlyincompound)); |
2651 |
maxSug, ns, cclass, needflag, (in_compound ? 0 : onlyincompound)); |
| 2514 |
if (rv) { |
2652 |
if (rv) { |
| 2515 |
sfx=sptr; // BUG: sfx not stateless |
2653 |
sfx=sptr; // BUG: sfx not stateless |
| 2516 |
sfxflag = sptr->getFlag(); // BUG: sfxflag not stateless |
2654 |
sfxflag = sptr->getFlag(); // BUG: sfxflag not stateless |
| 2517 |
if (!sptr->getCont()) sfxappnd=sptr->getKey(); // BUG: sfxappnd not stateless |
2655 |
if (!sptr->getCont()) sfxappnd=sptr->getKey(); // BUG: sfxappnd not stateless |
| 2518 |
return rv; |
2656 |
return rv; |
| 2519 |
} |
2657 |
} |
|
Lines 2791-2813
struct hentry * AffixMgr::affix_check (c
|
Link Here
|
|---|
|
| 2791 |
if (rv) return rv; |
2929 |
if (rv) return rv; |
| 2792 |
|
2930 |
|
| 2793 |
// if still not found check all suffixes |
2931 |
// if still not found check all suffixes |
| 2794 |
rv = suffix_check(word, len, 0, NULL, NULL, 0, NULL, FLAG_NULL, needflag, in_compound); |
2932 |
rv = suffix_check(word, len, 0, NULL, NULL, 0, NULL, FLAG_NULL, needflag, in_compound); |
| 2795 |
|
2933 |
|
| 2796 |
if (havecontclass) { |
2934 |
if (havecontclass) { |
| 2797 |
sfx = NULL; |
2935 |
sfx = NULL; |
| 2798 |
pfx = NULL; |
2936 |
pfx = NULL; |
|
|
2937 |
|
| 2799 |
if (rv) return rv; |
2938 |
if (rv) return rv; |
| 2800 |
// if still not found check all two-level suffixes |
2939 |
// if still not found check all two-level suffixes |
| 2801 |
rv = suffix_check_twosfx(word, len, 0, NULL, needflag); |
2940 |
rv = suffix_check_twosfx(word, len, 0, NULL, needflag); |
|
|
2941 |
|
| 2802 |
if (rv) return rv; |
2942 |
if (rv) return rv; |
| 2803 |
// if still not found check all two-level suffixes |
2943 |
// if still not found check all two-level suffixes |
| 2804 |
rv = prefix_check_twosfx(word, len, IN_CPD_NOT, needflag); |
2944 |
rv = prefix_check_twosfx(word, len, IN_CPD_NOT, needflag); |
| 2805 |
} |
2945 |
} |
|
|
2946 |
|
| 2806 |
return rv; |
2947 |
return rv; |
| 2807 |
} |
2948 |
} |
| 2808 |
|
2949 |
|
| 2809 |
// check if word with affixes is correctly spelled |
2950 |
// check if word with affixes is correctly spelled |
| 2810 |
char * AffixMgr::affix_check_morph(const char * word, int len, const FLAG needflag, char in_compound) |
2951 |
char * AffixMgr::affix_check_morph(const char * word, int len, const FLAG needflag, char in_compound) |
| 2811 |
{ |
2952 |
{ |
| 2812 |
char result[MAXLNLEN]; |
2953 |
char result[MAXLNLEN]; |
| 2813 |
char * st = NULL; |
2954 |
char * st = NULL; |
|
Lines 2890-2906
char * AffixMgr::morphgen(char * ts, int
|
Link Here
|
|---|
|
| 2890 |
|
3031 |
|
| 2891 |
int cmp = morphcmp(stemmorph, targetmorph); |
3032 |
int cmp = morphcmp(stemmorph, targetmorph); |
| 2892 |
|
3033 |
|
| 2893 |
if (cmp == 0) { |
3034 |
if (cmp == 0) { |
| 2894 |
char * newword = sptr->add(ts, wl); |
3035 |
char * newword = sptr->add(ts, wl); |
| 2895 |
if (newword) { |
3036 |
if (newword) { |
| 2896 |
hentry * check = pHMgr->lookup(newword); // XXX extra dic |
3037 |
hentry * check = pHMgr->lookup(newword); // XXX extra dic |
| 2897 |
if (!check || !check->astr || |
3038 |
if (!check || !check->astr || |
| 2898 |
!TESTAFF(check->astr, forbiddenword, check->alen)) { |
3039 |
!(TESTAFF(check->astr, forbiddenword, check->alen) || |
|
|
3040 |
TESTAFF(check->astr, ONLYUPCASEFLAG, check->alen))) { |
| 2899 |
return newword; |
3041 |
return newword; |
| 2900 |
} |
3042 |
} |
| 2901 |
free(newword); |
3043 |
free(newword); |
| 2902 |
} |
3044 |
} |
| 2903 |
} |
3045 |
} |
| 2904 |
|
3046 |
|
| 2905 |
// recursive call for secondary suffixes |
3047 |
// recursive call for secondary suffixes |
| 2906 |
if ((level == 0) && (cmp == 1) && (sptr->getContLen() > 0) && |
3048 |
if ((level == 0) && (cmp == 1) && (sptr->getContLen() > 0) && |
|
Lines 3144-3159
int AffixMgr::get_fullstrip() const
|
Link Here
|
|---|
|
| 3144 |
return fullstrip; |
3286 |
return fullstrip; |
| 3145 |
} |
3287 |
} |
| 3146 |
|
3288 |
|
| 3147 |
FLAG AffixMgr::get_keepcase() const |
3289 |
FLAG AffixMgr::get_keepcase() const |
| 3148 |
{ |
3290 |
{ |
| 3149 |
return keepcase; |
3291 |
return keepcase; |
| 3150 |
} |
3292 |
} |
| 3151 |
|
3293 |
|
|
|
3294 |
FLAG AffixMgr::get_forceucase() const |
| 3295 |
{ |
| 3296 |
return forceucase; |
| 3297 |
} |
| 3298 |
|
| 3299 |
FLAG AffixMgr::get_warn() const |
| 3300 |
{ |
| 3301 |
return warn; |
| 3302 |
} |
| 3303 |
|
| 3304 |
int AffixMgr::get_forbidwarn() const |
| 3305 |
{ |
| 3306 |
return forbidwarn; |
| 3307 |
} |
| 3308 |
|
| 3152 |
int AffixMgr::get_checksharps() const |
3309 |
int AffixMgr::get_checksharps() const |
| 3153 |
{ |
3310 |
{ |
| 3154 |
return checksharps; |
3311 |
return checksharps; |
| 3155 |
} |
3312 |
} |
| 3156 |
|
3313 |
|
| 3157 |
char * AffixMgr::encode_flag(unsigned short aflag) const |
3314 |
char * AffixMgr::encode_flag(unsigned short aflag) const |
| 3158 |
{ |
3315 |
{ |
| 3159 |
return pHMgr->encode_flag(aflag); |
3316 |
return pHMgr->encode_flag(aflag); |
|
Lines 3219-3234
FLAG AffixMgr::get_forbiddenword() const
|
Link Here
|
|---|
|
| 3219 |
} |
3376 |
} |
| 3220 |
|
3377 |
|
| 3221 |
// return the forbidden words control flag |
3378 |
// return the forbidden words control flag |
| 3222 |
FLAG AffixMgr::get_nosuggest() const |
3379 |
FLAG AffixMgr::get_nosuggest() const |
| 3223 |
{ |
3380 |
{ |
| 3224 |
return nosuggest; |
3381 |
return nosuggest; |
| 3225 |
} |
3382 |
} |
| 3226 |
|
3383 |
|
|
|
3384 |
// return the forbidden words control flag |
| 3385 |
FLAG AffixMgr::get_nongramsuggest() const |
| 3386 |
{ |
| 3387 |
return nongramsuggest; |
| 3388 |
} |
| 3389 |
|
| 3227 |
// return the forbidden words flag modify flag |
3390 |
// return the forbidden words flag modify flag |
| 3228 |
FLAG AffixMgr::get_needaffix() const |
3391 |
FLAG AffixMgr::get_needaffix() const |
| 3229 |
{ |
3392 |
{ |
| 3230 |
return needaffix; |
3393 |
return needaffix; |
| 3231 |
} |
3394 |
} |
| 3232 |
|
3395 |
|
| 3233 |
// return the onlyincompound flag |
3396 |
// return the onlyincompound flag |
| 3234 |
FLAG AffixMgr::get_onlyincompound() const |
3397 |
FLAG AffixMgr::get_onlyincompound() const |
|
Lines 3297-3318
int AffixMgr::have_contclass() const
|
Link Here
|
|---|
|
| 3297 |
} |
3460 |
} |
| 3298 |
|
3461 |
|
| 3299 |
// return utf8 |
3462 |
// return utf8 |
| 3300 |
int AffixMgr::get_utf8() const |
3463 |
int AffixMgr::get_utf8() const |
| 3301 |
{ |
3464 |
{ |
| 3302 |
return utf8; |
3465 |
return utf8; |
| 3303 |
} |
3466 |
} |
| 3304 |
|
3467 |
|
| 3305 |
// return nosplitsugs |
|
|
| 3306 |
int AffixMgr::get_maxngramsugs(void) const |
3468 |
int AffixMgr::get_maxngramsugs(void) const |
| 3307 |
{ |
3469 |
{ |
| 3308 |
return maxngramsugs; |
3470 |
return maxngramsugs; |
| 3309 |
} |
3471 |
} |
| 3310 |
|
3472 |
|
|
|
3473 |
int AffixMgr::get_maxcpdsugs(void) const |
| 3474 |
{ |
| 3475 |
return maxcpdsugs; |
| 3476 |
} |
| 3477 |
|
| 3478 |
int AffixMgr::get_maxdiff(void) const |
| 3479 |
{ |
| 3480 |
return maxdiff; |
| 3481 |
} |
| 3482 |
|
| 3483 |
int AffixMgr::get_onlymaxdiff(void) const |
| 3484 |
{ |
| 3485 |
return onlymaxdiff; |
| 3486 |
} |
| 3487 |
|
| 3311 |
// return nosplitsugs |
3488 |
// return nosplitsugs |
| 3312 |
int AffixMgr::get_nosplitsugs(void) const |
3489 |
int AffixMgr::get_nosplitsugs(void) const |
| 3313 |
{ |
3490 |
{ |
| 3314 |
return nosplitsugs; |
3491 |
return nosplitsugs; |
| 3315 |
} |
3492 |
} |
| 3316 |
|
3493 |
|
| 3317 |
// return sugswithdots |
3494 |
// return sugswithdots |
| 3318 |
int AffixMgr::get_sugswithdots(void) const |
3495 |
int AffixMgr::get_sugswithdots(void) const |
|
Lines 3444-3460
int AffixMgr::parse_reptable(char * lin
|
Link Here
|
|---|
|
| 3444 |
case 0: { |
3621 |
case 0: { |
| 3445 |
if (strncmp(piece,"REP",3) != 0) { |
3622 |
if (strncmp(piece,"REP",3) != 0) { |
| 3446 |
HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af->getlinenum()); |
3623 |
HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af->getlinenum()); |
| 3447 |
numrep = 0; |
3624 |
numrep = 0; |
| 3448 |
return 1; |
3625 |
return 1; |
| 3449 |
} |
3626 |
} |
| 3450 |
break; |
3627 |
break; |
| 3451 |
} |
3628 |
} |
| 3452 |
case 1: { reptable[j].pattern = mystrrep(mystrdup(piece),"_"," "); break; } |
3629 |
case 1: { |
|
|
3630 |
if (*piece == '^') reptable[j].start = true; else reptable[j].start = false; |
| 3631 |
reptable[j].pattern = mystrrep(mystrdup(piece + int(reptable[j].start)),"_"," "); |
| 3632 |
int lr = strlen(reptable[j].pattern) - 1; |
| 3633 |
if (reptable[j].pattern[lr] == '$') { |
| 3634 |
reptable[j].end = true; |
| 3635 |
reptable[j].pattern[lr] = '\0'; |
| 3636 |
} else reptable[j].end = false; |
| 3637 |
break; |
| 3638 |
} |
| 3453 |
case 2: { reptable[j].pattern2 = mystrrep(mystrdup(piece),"_"," "); break; } |
3639 |
case 2: { reptable[j].pattern2 = mystrrep(mystrdup(piece),"_"," "); break; } |
| 3454 |
default: break; |
3640 |
default: break; |
| 3455 |
} |
3641 |
} |
| 3456 |
i++; |
3642 |
i++; |
| 3457 |
} |
3643 |
} |
| 3458 |
piece = mystrsep(&tp, 0); |
3644 |
piece = mystrsep(&tp, 0); |
| 3459 |
} |
3645 |
} |
| 3460 |
if ((!(reptable[j].pattern)) || (!(reptable[j].pattern2))) { |
3646 |
if ((!(reptable[j].pattern)) || (!(reptable[j].pattern2))) { |
|
Lines 3533-3557
int AffixMgr::parse_convtable(char * li
|
Link Here
|
|---|
|
| 3533 |
break; |
3719 |
break; |
| 3534 |
} |
3720 |
} |
| 3535 |
default: break; |
3721 |
default: break; |
| 3536 |
} |
3722 |
} |
| 3537 |
i++; |
3723 |
i++; |
| 3538 |
} |
3724 |
} |
| 3539 |
piece = mystrsep(&tp, 0); |
3725 |
piece = mystrsep(&tp, 0); |
| 3540 |
} |
3726 |
} |
| 3541 |
if (!pattern || !pattern2) { |
3727 |
if (!pattern || !pattern2) { |
| 3542 |
if (pattern) |
3728 |
if (pattern) |
| 3543 |
free(pattern); |
3729 |
free(pattern); |
| 3544 |
if (pattern2) |
3730 |
if (pattern2) |
| 3545 |
free(pattern2); |
3731 |
free(pattern2); |
| 3546 |
HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af->getlinenum()); |
3732 |
HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af->getlinenum()); |
| 3547 |
return 1; |
3733 |
return 1; |
| 3548 |
} |
3734 |
} |
| 3549 |
(*rl)->add(pattern, pattern2); |
3735 |
(*rl)->add(pattern, pattern2); |
| 3550 |
} |
3736 |
} |
| 3551 |
return 0; |
3737 |
return 0; |
| 3552 |
} |
3738 |
} |
| 3553 |
|
3739 |
|
| 3554 |
|
3740 |
|
| 3555 |
/* parse in the typical fault correcting table */ |
3741 |
/* parse in the typical fault correcting table */ |
| 3556 |
int AffixMgr::parse_phonetable(char * line, FileMgr * af) |
3742 |
int AffixMgr::parse_phonetable(char * line, FileMgr * af) |
| 3557 |
{ |
3743 |
{ |
|
Lines 3935-3969
int AffixMgr::parse_maptable(char * lin
|
Link Here
|
|---|
|
| 3935 |
} |
4121 |
} |
| 3936 |
} |
4122 |
} |
| 3937 |
return 0; |
4123 |
return 0; |
| 3938 |
} |
4124 |
} |
| 3939 |
|
4125 |
|
| 3940 |
/* parse in the word breakpoint table */ |
4126 |
/* parse in the word breakpoint table */ |
| 3941 |
int AffixMgr::parse_breaktable(char * line, FileMgr * af) |
4127 |
int AffixMgr::parse_breaktable(char * line, FileMgr * af) |
| 3942 |
{ |
4128 |
{ |
| 3943 |
if (numbreak != 0) { |
4129 |
if (numbreak > -1) { |
| 3944 |
HUNSPELL_WARNING(stderr, "error: line %d: multiple table definitions\n", af->getlinenum()); |
4130 |
HUNSPELL_WARNING(stderr, "error: line %d: multiple table definitions\n", af->getlinenum()); |
| 3945 |
return 1; |
4131 |
return 1; |
| 3946 |
} |
4132 |
} |
| 3947 |
char * tp = line; |
4133 |
char * tp = line; |
| 3948 |
char * piece; |
4134 |
char * piece; |
| 3949 |
int i = 0; |
4135 |
int i = 0; |
| 3950 |
int np = 0; |
4136 |
int np = 0; |
| 3951 |
piece = mystrsep(&tp, 0); |
4137 |
piece = mystrsep(&tp, 0); |
| 3952 |
while (piece) { |
4138 |
while (piece) { |
| 3953 |
if (*piece != '\0') { |
4139 |
if (*piece != '\0') { |
| 3954 |
switch(i) { |
4140 |
switch(i) { |
| 3955 |
case 0: { np++; break; } |
4141 |
case 0: { np++; break; } |
| 3956 |
case 1: { |
4142 |
case 1: { |
| 3957 |
numbreak = atoi(piece); |
4143 |
numbreak = atoi(piece); |
| 3958 |
if (numbreak < 1) { |
4144 |
if (numbreak < 0) { |
| 3959 |
HUNSPELL_WARNING(stderr, "error: line %d: bad entry number\n", af->getlinenum()); |
4145 |
HUNSPELL_WARNING(stderr, "error: line %d: bad entry number\n", af->getlinenum()); |
| 3960 |
return 1; |
4146 |
return 1; |
| 3961 |
} |
4147 |
} |
|
|
4148 |
if (numbreak == 0) return 0; |
| 3962 |
breaktable = (char **) malloc(numbreak * sizeof(char *)); |
4149 |
breaktable = (char **) malloc(numbreak * sizeof(char *)); |
| 3963 |
if (!breaktable) return 1; |
4150 |
if (!breaktable) return 1; |
| 3964 |
np++; |
4151 |
np++; |
| 3965 |
break; |
4152 |
break; |
| 3966 |
} |
4153 |
} |
| 3967 |
default: break; |
4154 |
default: break; |
| 3968 |
} |
4155 |
} |
| 3969 |
i++; |
4156 |
i++; |