|
|
|
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 758-774
int AffixMgr::parse_file(const char * a
|
Link Here
|
|---|
|
| 758 |
*(expw + strlen(expw)) = (char) i; |
758 |
*(expw + strlen(expw)) = (char) i; |
| 759 |
} |
759 |
} |
| 760 |
} |
760 |
} |
| 761 |
|
761 |
|
| 762 |
wordchars = mystrdup(expw); |
762 |
wordchars = mystrdup(expw); |
| 763 |
} |
763 |
} |
| 764 |
|
764 |
|
| 765 |
// default BREAK definition |
765 |
// default BREAK definition |
| 766 |
if (!breaktable) { |
766 |
if (numbreak == -1) { |
| 767 |
breaktable = (char **) malloc(sizeof(char *) * 3); |
767 |
breaktable = (char **) malloc(sizeof(char *) * 3); |
| 768 |
if (!breaktable) return 1; |
768 |
if (!breaktable) return 1; |
| 769 |
breaktable[0] = mystrdup("-"); |
769 |
breaktable[0] = mystrdup("-"); |
| 770 |
breaktable[1] = mystrdup("^-"); |
770 |
breaktable[1] = mystrdup("^-"); |
| 771 |
breaktable[2] = mystrdup("-$"); |
771 |
breaktable[2] = mystrdup("-$"); |
| 772 |
if (breaktable[0] && breaktable[1] && breaktable[2]) numbreak = 3; |
772 |
if (breaktable[0] && breaktable[1] && breaktable[2]) numbreak = 3; |
| 773 |
} |
773 |
} |
| 774 |
return 0; |
774 |
return 0; |
|
Lines 1316-1342
int AffixMgr::cpdrep_check(const char *
|
Link Here
|
|---|
|
| 1316 |
if (candidate_check(candidate,strlen(candidate))) return 1; |
1316 |
if (candidate_check(candidate,strlen(candidate))) return 1; |
| 1317 |
r++; // search for the next letter |
1317 |
r++; // search for the next letter |
| 1318 |
} |
1318 |
} |
| 1319 |
} |
1319 |
} |
| 1320 |
return 0; |
1320 |
return 0; |
| 1321 |
} |
1321 |
} |
| 1322 |
|
1322 |
|
| 1323 |
// forbid compoundings when there are special patterns at word bound |
1323 |
// forbid compoundings when there are special patterns at word bound |
| 1324 |
int AffixMgr::cpdpat_check(const char * word, int pos, hentry * r1, hentry * r2) |
1324 |
int AffixMgr::cpdpat_check(const char * word, int pos, hentry * r1, hentry * r2, const char affixed) |
| 1325 |
{ |
1325 |
{ |
| 1326 |
int len; |
1326 |
int len; |
| 1327 |
for (int i = 0; i < numcheckcpd; i++) { |
1327 |
for (int i = 0; i < numcheckcpd; i++) { |
| 1328 |
if (isSubset(checkcpdtable[i].pattern2, word + pos) && |
1328 |
if (isSubset(checkcpdtable[i].pattern2, word + pos) && |
| 1329 |
(!r1 || !checkcpdtable[i].cond || |
1329 |
(!r1 || !checkcpdtable[i].cond || |
| 1330 |
(r1->astr && TESTAFF(r1->astr, checkcpdtable[i].cond, r1->alen))) && |
1330 |
(r1->astr && TESTAFF(r1->astr, checkcpdtable[i].cond, r1->alen))) && |
| 1331 |
(!r2 || !checkcpdtable[i].cond2 || |
1331 |
(!r2 || !checkcpdtable[i].cond2 || |
| 1332 |
(r2->astr && TESTAFF(r2->astr, checkcpdtable[i].cond2, r2->alen))) && |
1332 |
(r2->astr && TESTAFF(r2->astr, checkcpdtable[i].cond2, r2->alen))) && |
| 1333 |
(len = strlen(checkcpdtable[i].pattern)) && (pos > len) && |
1333 |
// zero length pattern => only TESTAFF |
| 1334 |
(strncmp(word + pos - len, checkcpdtable[i].pattern, len) == 0)) return 1; |
1334 |
// zero pattern (0/flag) => unmodified stem (zero affixes allowed) |
|
|
1335 |
(!*(checkcpdtable[i].pattern) || ( |
| 1336 |
(*(checkcpdtable[i].pattern)=='0' && r1->blen <= pos && strncmp(word + pos - r1->blen, r1->word, r1->blen) == 0) || |
| 1337 |
(*(checkcpdtable[i].pattern)!='0' && (len = strlen(checkcpdtable[i].pattern)) && |
| 1338 |
strncmp(word + pos - len, checkcpdtable[i].pattern, len) == 0)))) { |
| 1339 |
return 1; |
| 1340 |
} |
| 1335 |
} |
1341 |
} |
| 1336 |
return 0; |
1342 |
return 0; |
| 1337 |
} |
1343 |
} |
| 1338 |
|
1344 |
|
| 1339 |
// forbid compounding with neighbouring upper and lower case characters at word bounds |
1345 |
// forbid compounding with neighbouring upper and lower case characters at word bounds |
| 1340 |
int AffixMgr::cpdcase_check(const char * word, int pos) |
1346 |
int AffixMgr::cpdcase_check(const char * word, int pos) |
| 1341 |
{ |
1347 |
{ |
| 1342 |
if (utf8) { |
1348 |
if (utf8) { |
|
Lines 1511-1526
void AffixMgr::setcminmax(int * cmin, in
|
Link Here
|
|---|
|
| 1511 |
for ((*cmax)--; (word[*cmax] & 0xc0) == 0x80; (*cmax)--); |
1517 |
for ((*cmax)--; (word[*cmax] & 0xc0) == 0x80; (*cmax)--); |
| 1512 |
} |
1518 |
} |
| 1513 |
} else { |
1519 |
} else { |
| 1514 |
*cmin = cpdmin; |
1520 |
*cmin = cpdmin; |
| 1515 |
*cmax = len - cpdmin + 1; |
1521 |
*cmax = len - cpdmin + 1; |
| 1516 |
} |
1522 |
} |
| 1517 |
} |
1523 |
} |
| 1518 |
|
1524 |
|
|
|
1525 |
|
| 1519 |
// check if compound word is correctly spelled |
1526 |
// check if compound word is correctly spelled |
| 1520 |
// hu_mov_rule = spec. Hungarian rule (XXX) |
1527 |
// hu_mov_rule = spec. Hungarian rule (XXX) |
| 1521 |
struct hentry * AffixMgr::compound_check(const char * word, int len, |
1528 |
struct hentry * AffixMgr::compound_check(const char * word, int len, |
| 1522 |
short wordnum, short numsyllable, short maxwordnum, short wnum, hentry ** words = NULL, |
1529 |
short wordnum, short numsyllable, short maxwordnum, short wnum, hentry ** words = NULL, |
| 1523 |
char hu_mov_rule = 0, char is_sug = 0) |
1530 |
char hu_mov_rule = 0, char is_sug = 0) |
| 1524 |
{ |
1531 |
{ |
| 1525 |
int i; |
1532 |
int i; |
| 1526 |
short oldnumsyllable, oldnumsyllable2, oldwordnum, oldwordnum2; |
1533 |
short oldnumsyllable, oldnumsyllable2, oldwordnum, oldwordnum2; |
|
Lines 1533-1567
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1533 |
int cmax; |
1540 |
int cmax; |
| 1534 |
int striple = 0; |
1541 |
int striple = 0; |
| 1535 |
int scpd = 0; |
1542 |
int scpd = 0; |
| 1536 |
int soldi = 0; |
1543 |
int soldi = 0; |
| 1537 |
int oldcmin = 0; |
1544 |
int oldcmin = 0; |
| 1538 |
int oldcmax = 0; |
1545 |
int oldcmax = 0; |
| 1539 |
int oldlen = 0; |
1546 |
int oldlen = 0; |
| 1540 |
int checkedstriple = 0; |
1547 |
int checkedstriple = 0; |
|
|
1548 |
int onlycpdrule; |
| 1549 |
int affixed = 0; |
| 1541 |
|
1550 |
|
| 1542 |
int checked_prefix; |
1551 |
int checked_prefix; |
| 1543 |
|
1552 |
|
| 1544 |
setcminmax(&cmin, &cmax, word, len); |
1553 |
setcminmax(&cmin, &cmax, word, len); |
| 1545 |
|
1554 |
|
| 1546 |
strcpy(st, word); |
1555 |
strcpy(st, word); |
| 1547 |
|
1556 |
|
| 1548 |
for (i = cmin; i < cmax; i++) { |
1557 |
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 |
1558 |
// go to end of the UTF-8 character |
| 1555 |
if (utf8) { |
1559 |
if (utf8) { |
| 1556 |
for (; (st[i] & 0xc0) == 0x80; i++); |
1560 |
for (; (st[i] & 0xc0) == 0x80; i++); |
| 1557 |
if (i >= cmax) return NULL; |
1561 |
if (i >= cmax) return NULL; |
| 1558 |
} |
1562 |
} |
| 1559 |
|
1563 |
|
|
|
1564 |
onlycpdrule = 0; |
| 1565 |
|
| 1566 |
do { // onlycpdrule loop |
| 1567 |
|
| 1568 |
oldnumsyllable = numsyllable; |
| 1569 |
oldwordnum = wordnum; |
| 1570 |
checked_prefix = 0; |
| 1571 |
|
| 1560 |
do { // simplified checkcompoundpattern loop |
1572 |
do { // simplified checkcompoundpattern loop |
| 1561 |
|
1573 |
|
| 1562 |
if (scpd > 0) { |
1574 |
if (scpd > 0) { |
| 1563 |
for (; scpd <= numcheckcpd && (!checkcpdtable[scpd-1].pattern3 || |
1575 |
for (; scpd <= numcheckcpd && (!checkcpdtable[scpd-1].pattern3 || |
| 1564 |
strncmp(word + i, checkcpdtable[scpd-1].pattern3, strlen(checkcpdtable[scpd-1].pattern3)) != 0); scpd++); |
1576 |
strncmp(word + i, checkcpdtable[scpd-1].pattern3, strlen(checkcpdtable[scpd-1].pattern3)) != 0); scpd++); |
| 1565 |
|
1577 |
|
| 1566 |
if (scpd > numcheckcpd) break; // break simplified checkcompoundpattern loop |
1578 |
if (scpd > numcheckcpd) break; // break simplified checkcompoundpattern loop |
| 1567 |
strcpy(st + i, checkcpdtable[scpd-1].pattern); |
1579 |
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); |
1586 |
len += strlen(checkcpdtable[scpd-1].pattern) + strlen(checkcpdtable[scpd-1].pattern2) - strlen(checkcpdtable[scpd-1].pattern3); |
| 1575 |
oldcmin = cmin; |
1587 |
oldcmin = cmin; |
| 1576 |
oldcmax = cmax; |
1588 |
oldcmax = cmax; |
| 1577 |
setcminmax(&cmin, &cmax, st, len); |
1589 |
setcminmax(&cmin, &cmax, st, len); |
| 1578 |
|
1590 |
|
| 1579 |
cmax = len - cpdmin + 1; |
1591 |
cmax = len - cpdmin + 1; |
| 1580 |
} |
1592 |
} |
| 1581 |
|
1593 |
|
| 1582 |
|
|
|
| 1583 |
ch = st[i]; |
1594 |
ch = st[i]; |
| 1584 |
st[i] = '\0'; |
1595 |
st[i] = '\0'; |
| 1585 |
|
1596 |
|
| 1586 |
sfx = NULL; |
1597 |
sfx = NULL; |
| 1587 |
pfx = NULL; |
1598 |
pfx = NULL; |
| 1588 |
|
1599 |
|
| 1589 |
// FIRST WORD |
1600 |
// FIRST WORD |
| 1590 |
|
1601 |
|
|
|
1602 |
affixed = 1; |
| 1591 |
rv = lookup(st); // perhaps without prefix |
1603 |
rv = lookup(st); // perhaps without prefix |
| 1592 |
|
1604 |
|
| 1593 |
// search homonym with compound flag |
1605 |
// search homonym with compound flag |
| 1594 |
while ((rv) && !hu_mov_rule && |
1606 |
while ((rv) && !hu_mov_rule && |
| 1595 |
((needaffix && TESTAFF(rv->astr, needaffix, rv->alen)) || |
1607 |
((needaffix && TESTAFF(rv->astr, needaffix, rv->alen)) || |
| 1596 |
!((compoundflag && !words && TESTAFF(rv->astr, compoundflag, rv->alen)) || |
1608 |
!((compoundflag && !words && !onlycpdrule && TESTAFF(rv->astr, compoundflag, rv->alen)) || |
| 1597 |
(compoundbegin && !wordnum && |
1609 |
(compoundbegin && !wordnum && !onlycpdrule && |
| 1598 |
TESTAFF(rv->astr, compoundbegin, rv->alen)) || |
1610 |
TESTAFF(rv->astr, compoundbegin, rv->alen)) || |
| 1599 |
(compoundmiddle && wordnum && !words && |
1611 |
(compoundmiddle && wordnum && !words && !onlycpdrule && |
| 1600 |
TESTAFF(rv->astr, compoundmiddle, rv->alen)) || |
1612 |
TESTAFF(rv->astr, compoundmiddle, rv->alen)) || |
| 1601 |
(numdefcpd && |
1613 |
(numdefcpd && |
| 1602 |
((!words && !wordnum && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0)) || |
1614 |
((!words && !wordnum && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0)) || |
| 1603 |
(words && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0))))) || |
1615 |
(words && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0))) && (onlycpdrule = 1))) || // switch onlycpdrule on |
| 1604 |
(scpd != 0 && checkcpdtable[scpd-1].cond != FLAG_NULL && |
1616 |
(scpd != 0 && checkcpdtable[scpd-1].cond != FLAG_NULL && |
| 1605 |
!TESTAFF(rv->astr, checkcpdtable[scpd-1].cond, rv->alen))) |
1617 |
!TESTAFF(rv->astr, checkcpdtable[scpd-1].cond, rv->alen))) |
| 1606 |
) { |
1618 |
) { |
| 1607 |
rv = rv->next_homonym; |
1619 |
rv = rv->next_homonym; |
| 1608 |
} |
1620 |
} |
| 1609 |
|
1621 |
|
|
|
1622 |
if (rv) affixed = 0; |
| 1623 |
|
| 1610 |
if (!rv) { |
1624 |
if (!rv) { |
|
|
1625 |
if (onlycpdrule) break; |
| 1611 |
if (compoundflag && |
1626 |
if (compoundflag && |
| 1612 |
!(rv = prefix_check(st, i, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN, compoundflag))) { |
1627 |
!(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, |
1628 |
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 && |
1629 |
FLAG_NULL, compoundflag, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN)) && !hu_mov_rule && |
| 1615 |
sfx->getCont() && |
1630 |
sfx->getCont() && |
| 1616 |
((compoundforbidflag && TESTAFF(sfx->getCont(), compoundforbidflag, |
1631 |
((compoundforbidflag && TESTAFF(sfx->getCont(), compoundforbidflag, |
| 1617 |
sfx->getContLen())) || (compoundend && |
1632 |
sfx->getContLen())) || (compoundend && |
| 1618 |
TESTAFF(sfx->getCont(), compoundend, |
1633 |
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)) || |
1641 |
((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)))) || |
1642 |
(rv = prefix_check(st, i, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN, compoundbegin)))) || |
| 1628 |
((wordnum > 0) && compoundmiddle && |
1643 |
((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)) || |
1644 |
((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))))) |
1645 |
(rv = prefix_check(st, i, hu_mov_rule ? IN_CPD_OTHER : IN_CPD_BEGIN, compoundmiddle))))) |
| 1631 |
) checked_prefix = 1; |
1646 |
) checked_prefix = 1; |
| 1632 |
// else check forbiddenwords and needaffix |
1647 |
// else check forbiddenwords and needaffix |
| 1633 |
} else if (rv->astr && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
1648 |
} else if (rv->astr && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
| 1634 |
TESTAFF(rv->astr, needaffix, rv->alen) || |
1649 |
TESTAFF(rv->astr, needaffix, rv->alen) || |
|
|
1650 |
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen) || |
| 1635 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)) |
1651 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)) |
| 1636 |
)) { |
1652 |
)) { |
| 1637 |
st[i] = ch; |
1653 |
st[i] = ch; |
| 1638 |
continue; |
1654 |
//continue; |
|
|
1655 |
break; |
| 1639 |
} |
1656 |
} |
| 1640 |
|
1657 |
|
| 1641 |
// check non_compound flag in suffix and prefix |
1658 |
// check non_compound flag in suffix and prefix |
| 1642 |
if ((rv) && !hu_mov_rule && |
1659 |
if ((rv) && !hu_mov_rule && |
| 1643 |
((pfx && pfx->getCont() && |
1660 |
((pfx && pfx->getCont() && |
| 1644 |
TESTAFF(pfx->getCont(), compoundforbidflag, |
1661 |
TESTAFF(pfx->getCont(), compoundforbidflag, |
| 1645 |
pfx->getContLen())) || |
1662 |
pfx->getContLen())) || |
| 1646 |
(sfx && sfx->getCont() && |
1663 |
(sfx && sfx->getCont() && |
|
Lines 1668-1683
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1668 |
(sfx && sfx->getCont() && |
1685 |
(sfx && sfx->getCont() && |
| 1669 |
TESTAFF(sfx->getCont(), compoundmiddle, |
1686 |
TESTAFF(sfx->getCont(), compoundmiddle, |
| 1670 |
sfx->getContLen())))) { |
1687 |
sfx->getContLen())))) { |
| 1671 |
rv = NULL; |
1688 |
rv = NULL; |
| 1672 |
} |
1689 |
} |
| 1673 |
|
1690 |
|
| 1674 |
// check forbiddenwords |
1691 |
// check forbiddenwords |
| 1675 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
1692 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
|
|
1693 |
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen) || |
| 1676 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) { |
1694 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) { |
| 1677 |
return NULL; |
1695 |
return NULL; |
| 1678 |
} |
1696 |
} |
| 1679 |
|
1697 |
|
| 1680 |
// increment word number, if the second root has a compoundroot flag |
1698 |
// increment word number, if the second root has a compoundroot flag |
| 1681 |
if ((rv) && compoundroot && |
1699 |
if ((rv) && compoundroot && |
| 1682 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
1700 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
| 1683 |
wordnum++; |
1701 |
wordnum++; |
|
Lines 1730-1746
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1730 |
// calculate syllable number of the word |
1748 |
// calculate syllable number of the word |
| 1731 |
numsyllable += get_syllable(st, i); |
1749 |
numsyllable += get_syllable(st, i); |
| 1732 |
|
1750 |
|
| 1733 |
// + 1 word, if syllable number of the prefix > 1 (hungarian convention) |
1751 |
// + 1 word, if syllable number of the prefix > 1 (hungarian convention) |
| 1734 |
if (pfx && (get_syllable(pfx->getKey(),strlen(pfx->getKey())) > 1)) wordnum++; |
1752 |
if (pfx && (get_syllable(pfx->getKey(),strlen(pfx->getKey())) > 1)) wordnum++; |
| 1735 |
} |
1753 |
} |
| 1736 |
// END of LANG_hu section |
1754 |
// END of LANG_hu section |
| 1737 |
|
1755 |
|
| 1738 |
|
|
|
| 1739 |
// NEXT WORD(S) |
1756 |
// NEXT WORD(S) |
| 1740 |
rv_first = rv; |
1757 |
rv_first = rv; |
| 1741 |
st[i] = ch; |
1758 |
st[i] = ch; |
| 1742 |
|
1759 |
|
| 1743 |
do { // striple loop |
1760 |
do { // striple loop |
| 1744 |
|
1761 |
|
| 1745 |
// check simplifiedtriple |
1762 |
// check simplifiedtriple |
| 1746 |
if (simplifiedtriple) { |
1763 |
if (simplifiedtriple) { |
|
Lines 1777-1792
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1777 |
// increment word number, if the second root has a compoundroot flag |
1794 |
// increment word number, if the second root has a compoundroot flag |
| 1778 |
if ((rv) && (compoundroot) && |
1795 |
if ((rv) && (compoundroot) && |
| 1779 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
1796 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
| 1780 |
wordnum++; |
1797 |
wordnum++; |
| 1781 |
} |
1798 |
} |
| 1782 |
|
1799 |
|
| 1783 |
// check forbiddenwords |
1800 |
// check forbiddenwords |
| 1784 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
1801 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
|
|
1802 |
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen) || |
| 1785 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) return NULL; |
1803 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) return NULL; |
| 1786 |
|
1804 |
|
| 1787 |
// second word is acceptable, as a root? |
1805 |
// second word is acceptable, as a root? |
| 1788 |
// hungarian conventions: compounding is acceptable, |
1806 |
// hungarian conventions: compounding is acceptable, |
| 1789 |
// when compound forms consist of 2 words, or if more, |
1807 |
// when compound forms consist of 2 words, or if more, |
| 1790 |
// then the syllable number of root words must be 6, or lesser. |
1808 |
// then the syllable number of root words must be 6, or lesser. |
| 1791 |
|
1809 |
|
| 1792 |
if ((rv) && ( |
1810 |
if ((rv) && ( |
|
Lines 1795-1811
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1795 |
) |
1813 |
) |
| 1796 |
&& ( |
1814 |
&& ( |
| 1797 |
((cpdwordmax==-1) || (wordnum+1<cpdwordmax)) || |
1815 |
((cpdwordmax==-1) || (wordnum+1<cpdwordmax)) || |
| 1798 |
((cpdmaxsyllable!=0) && |
1816 |
((cpdmaxsyllable!=0) && |
| 1799 |
(numsyllable + get_syllable(HENTRY_WORD(rv), rv->clen)<=cpdmaxsyllable)) |
1817 |
(numsyllable + get_syllable(HENTRY_WORD(rv), rv->clen)<=cpdmaxsyllable)) |
| 1800 |
) && |
1818 |
) && |
| 1801 |
( |
1819 |
( |
| 1802 |
// test CHECKCOMPOUNDPATTERN |
1820 |
// test CHECKCOMPOUNDPATTERN |
| 1803 |
!numcheckcpd || scpd != 0 || !cpdpat_check(word, i, rv_first, rv) |
1821 |
!numcheckcpd || scpd != 0 || !cpdpat_check(word, i, rv_first, rv, 0) |
| 1804 |
) && |
1822 |
) && |
| 1805 |
( |
1823 |
( |
| 1806 |
(!checkcompounddup || (rv != rv_first)) |
1824 |
(!checkcompounddup || (rv != rv_first)) |
| 1807 |
) |
1825 |
) |
| 1808 |
// test CHECKCOMPOUNDPATTERN conditions |
1826 |
// test CHECKCOMPOUNDPATTERN conditions |
| 1809 |
&& (scpd == 0 || checkcpdtable[scpd-1].cond2 == FLAG_NULL || |
1827 |
&& (scpd == 0 || checkcpdtable[scpd-1].cond2 == FLAG_NULL || |
| 1810 |
TESTAFF(rv->astr, checkcpdtable[scpd-1].cond2, rv->alen)) |
1828 |
TESTAFF(rv->astr, checkcpdtable[scpd-1].cond2, rv->alen)) |
| 1811 |
) |
1829 |
) |
|
Lines 1816-1864
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1816 |
} |
1834 |
} |
| 1817 |
|
1835 |
|
| 1818 |
numsyllable = oldnumsyllable2; |
1836 |
numsyllable = oldnumsyllable2; |
| 1819 |
wordnum = oldwordnum2; |
1837 |
wordnum = oldwordnum2; |
| 1820 |
|
1838 |
|
| 1821 |
// perhaps second word has prefix or/and suffix |
1839 |
// perhaps second word has prefix or/and suffix |
| 1822 |
sfx = NULL; |
1840 |
sfx = NULL; |
| 1823 |
sfxflag = FLAG_NULL; |
1841 |
sfxflag = FLAG_NULL; |
| 1824 |
rv = (compoundflag) ? affix_check((word+i),strlen(word+i), compoundflag, IN_CPD_END) : NULL; |
1842 |
rv = (compoundflag && !onlycpdrule) ? affix_check((word+i),strlen(word+i), compoundflag, IN_CPD_END) : NULL; |
| 1825 |
if (!rv && compoundend) { |
1843 |
if (!rv && compoundend && !onlycpdrule) { |
| 1826 |
sfx = NULL; |
1844 |
sfx = NULL; |
| 1827 |
pfx = NULL; |
1845 |
pfx = NULL; |
| 1828 |
rv = affix_check((word+i),strlen(word+i), compoundend, IN_CPD_END); |
1846 |
rv = affix_check((word+i),strlen(word+i), compoundend, IN_CPD_END); |
| 1829 |
} |
1847 |
} |
| 1830 |
|
1848 |
|
| 1831 |
if (!rv && numdefcpd && words) { |
1849 |
if (!rv && numdefcpd && words) { |
| 1832 |
rv = affix_check((word+i),strlen(word+i), 0, IN_CPD_END); |
1850 |
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; |
1851 |
if (rv && defcpd_check(&words, wnum + 1, rv, NULL, 1)) return rv_first; |
| 1834 |
rv = NULL; |
1852 |
rv = NULL; |
| 1835 |
} |
1853 |
} |
| 1836 |
|
1854 |
|
| 1837 |
// test CHECKCOMPOUNDPATTERN conditions (allowed forms) |
1855 |
// test CHECKCOMPOUNDPATTERN conditions (allowed forms) |
| 1838 |
if (rv && !(scpd == 0 || checkcpdtable[scpd-1].cond2 == FLAG_NULL || |
1856 |
if (rv && !(scpd == 0 || checkcpdtable[scpd-1].cond2 == FLAG_NULL || |
| 1839 |
TESTAFF(rv->astr, checkcpdtable[scpd-1].cond2, rv->alen))) rv = NULL; |
1857 |
TESTAFF(rv->astr, checkcpdtable[scpd-1].cond2, rv->alen))) rv = NULL; |
| 1840 |
|
1858 |
|
| 1841 |
// test CHECKCOMPOUNDPATTERN conditions (forbidden compounds) |
1859 |
// test CHECKCOMPOUNDPATTERN conditions (forbidden compounds) |
| 1842 |
if (rv && numcheckcpd && scpd == 0 && cpdpat_check(word, i, rv_first, rv)) rv = NULL; |
1860 |
if (rv && numcheckcpd && scpd == 0 && cpdpat_check(word, i, rv_first, rv, affixed)) rv = NULL; |
| 1843 |
|
1861 |
|
| 1844 |
// check non_compound flag in suffix and prefix |
1862 |
// check non_compound flag in suffix and prefix |
| 1845 |
if ((rv) && |
1863 |
if ((rv) && |
| 1846 |
((pfx && pfx->getCont() && |
1864 |
((pfx && pfx->getCont() && |
| 1847 |
TESTAFF(pfx->getCont(), compoundforbidflag, |
1865 |
TESTAFF(pfx->getCont(), compoundforbidflag, |
| 1848 |
pfx->getContLen())) || |
1866 |
pfx->getContLen())) || |
| 1849 |
(sfx && sfx->getCont() && |
1867 |
(sfx && sfx->getCont() && |
| 1850 |
TESTAFF(sfx->getCont(), compoundforbidflag, |
1868 |
TESTAFF(sfx->getCont(), compoundforbidflag, |
| 1851 |
sfx->getContLen())))) { |
1869 |
sfx->getContLen())))) { |
| 1852 |
rv = NULL; |
1870 |
rv = NULL; |
| 1853 |
} |
1871 |
} |
| 1854 |
|
1872 |
|
| 1855 |
// check forbiddenwords |
1873 |
// check forbiddenwords |
| 1856 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
1874 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
|
|
1875 |
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen) || |
| 1857 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) return NULL; |
1876 |
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) return NULL; |
| 1858 |
|
1877 |
|
| 1859 |
// pfxappnd = prefix of word+i, or NULL |
1878 |
// pfxappnd = prefix of word+i, or NULL |
| 1860 |
// calculate syllable number of prefix. |
1879 |
// calculate syllable number of prefix. |
| 1861 |
// hungarian convention: when syllable number of prefix is more, |
1880 |
// hungarian convention: when syllable number of prefix is more, |
| 1862 |
// than 1, the prefix+word counts as two words. |
1881 |
// than 1, the prefix+word counts as two words. |
| 1863 |
|
1882 |
|
| 1864 |
if (langnum == LANG_hu) { |
1883 |
if (langnum == LANG_hu) { |
|
Lines 1878-1894
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1878 |
|
1897 |
|
| 1879 |
// increment syllable num, if last word has a SYLLABLENUM flag |
1898 |
// increment syllable num, if last word has a SYLLABLENUM flag |
| 1880 |
// and the suffix is beginning `s' |
1899 |
// and the suffix is beginning `s' |
| 1881 |
|
1900 |
|
| 1882 |
if (cpdsyllablenum) { |
1901 |
if (cpdsyllablenum) { |
| 1883 |
switch (sfxflag) { |
1902 |
switch (sfxflag) { |
| 1884 |
case 'c': { numsyllable+=2; break; } |
1903 |
case 'c': { numsyllable+=2; break; } |
| 1885 |
case 'J': { numsyllable += 1; break; } |
1904 |
case 'J': { numsyllable += 1; break; } |
| 1886 |
case 'I': { if (TESTAFF(rv->astr, 'J', rv->alen)) numsyllable += 1; break; } |
1905 |
case 'I': { if (rv && TESTAFF(rv->astr, 'J', rv->alen)) numsyllable += 1; break; } |
| 1887 |
} |
1906 |
} |
| 1888 |
} |
1907 |
} |
| 1889 |
} |
1908 |
} |
| 1890 |
|
1909 |
|
| 1891 |
// increment word number, if the second word has a compoundroot flag |
1910 |
// increment word number, if the second word has a compoundroot flag |
| 1892 |
if ((rv) && (compoundroot) && |
1911 |
if ((rv) && (compoundroot) && |
| 1893 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
1912 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
| 1894 |
wordnum++; |
1913 |
wordnum++; |
|
Lines 1914-1937
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1914 |
|
1933 |
|
| 1915 |
numsyllable = oldnumsyllable2; |
1934 |
numsyllable = oldnumsyllable2; |
| 1916 |
wordnum = oldwordnum2; |
1935 |
wordnum = oldwordnum2; |
| 1917 |
|
1936 |
|
| 1918 |
// perhaps second word is a compound word (recursive call) |
1937 |
// perhaps second word is a compound word (recursive call) |
| 1919 |
if (wordnum < maxwordnum) { |
1938 |
if (wordnum < maxwordnum) { |
| 1920 |
rv = compound_check((st+i),strlen(st+i), wordnum+1, |
1939 |
rv = compound_check((st+i),strlen(st+i), wordnum+1, |
| 1921 |
numsyllable, maxwordnum, wnum + 1, words, 0, is_sug); |
1940 |
numsyllable, maxwordnum, wnum + 1, words, 0, is_sug); |
| 1922 |
if (rv && numcheckcpd && ((scpd == 0 && cpdpat_check(word, i, rv_first, rv)) || |
1941 |
if (rv && numcheckcpd && ((scpd == 0 && cpdpat_check(word, i, rv_first, rv, affixed)) || |
| 1923 |
(scpd != 0 && !cpdpat_check(word, i, rv_first, rv)))) rv = NULL; |
1942 |
(scpd != 0 && !cpdpat_check(word, i, rv_first, rv, affixed)))) rv = NULL; |
| 1924 |
} else { |
1943 |
} else { |
| 1925 |
rv=NULL; |
1944 |
rv=NULL; |
| 1926 |
} |
1945 |
} |
| 1927 |
if (rv) { |
1946 |
if (rv) { |
| 1928 |
// forbid compound word, if it is a non compound word with typical fault |
1947 |
// forbid compound word, if it is a non compound word with typical fault |
| 1929 |
if (checkcompoundrep && cpdrep_check(word, len)) return NULL; |
1948 |
if (checkcompoundrep || forbiddenword) { |
|
|
1949 |
struct hentry * rv2 = NULL; |
| 1950 |
if (checkcompoundrep && cpdrep_check(word, len)) return NULL; |
| 1951 |
// check first part |
| 1952 |
if (strncmp(rv->word, word + i, rv->blen) == 0) { |
| 1953 |
char r = *(st + i + rv->blen); |
| 1954 |
*(st + i + rv->blen) = '\0'; |
| 1955 |
if (checkcompoundrep && cpdrep_check(st, i + rv->blen)) return NULL; |
| 1956 |
if (forbiddenword) { |
| 1957 |
rv2 = lookup(word); |
| 1958 |
if (!rv2) rv2 = affix_check(word, len); |
| 1959 |
if (rv2 && rv2->astr && TESTAFF(rv2->astr, forbiddenword, rv2->alen) && |
| 1960 |
(strncmp(rv2->word, st, i + rv->blen) == 0)) { |
| 1961 |
return NULL; |
| 1962 |
} |
| 1963 |
} |
| 1964 |
*(st + i + rv->blen) = r; |
| 1965 |
} |
| 1966 |
} |
| 1967 |
|
| 1930 |
return rv_first; |
1968 |
return rv_first; |
| 1931 |
} |
1969 |
} |
| 1932 |
} while (striple && !checkedstriple); // end of striple loop |
1970 |
} while (striple && !checkedstriple); // end of striple loop |
| 1933 |
|
1971 |
|
| 1934 |
if (checkedstriple) { |
1972 |
if (checkedstriple) { |
| 1935 |
i++; |
1973 |
i++; |
| 1936 |
checkedstriple = 0; |
1974 |
checkedstriple = 0; |
| 1937 |
striple = 0; |
1975 |
striple = 0; |
|
Lines 1943-1969
struct hentry * AffixMgr::compound_check
|
Link Here
|
|---|
|
| 1943 |
i = soldi; |
1981 |
i = soldi; |
| 1944 |
soldi = 0; |
1982 |
soldi = 0; |
| 1945 |
len = oldlen; |
1983 |
len = oldlen; |
| 1946 |
cmin = oldcmin; |
1984 |
cmin = oldcmin; |
| 1947 |
cmax = oldcmax; |
1985 |
cmax = oldcmax; |
| 1948 |
} |
1986 |
} |
| 1949 |
scpd++; |
1987 |
scpd++; |
| 1950 |
|
1988 |
|
| 1951 |
} while (simplifiedcpd && scpd <= numcheckcpd); // end of simplifiedcpd loop |
1989 |
} while (!onlycpdrule && simplifiedcpd && scpd <= numcheckcpd); // end of simplifiedcpd loop |
|
|
1990 |
|
| 1991 |
scpd = 0; |
| 1992 |
wordnum = oldwordnum; |
| 1993 |
numsyllable = oldnumsyllable; |
| 1952 |
|
1994 |
|
| 1953 |
if (soldi != 0) { |
1995 |
if (soldi != 0) { |
| 1954 |
i = soldi; |
1996 |
i = soldi; |
| 1955 |
strcpy(st, word); // XXX add more optim. |
1997 |
strcpy(st, word); // XXX add more optim. |
| 1956 |
soldi = 0; |
1998 |
soldi = 0; |
| 1957 |
} else st[i] = ch; |
1999 |
} else st[i] = ch; |
| 1958 |
|
2000 |
|
| 1959 |
scpd = 0; |
2001 |
} while (numdefcpd && oldwordnum == 0 && !onlycpdrule && (onlycpdrule = 1)); // end of onlycpd loop |
| 1960 |
wordnum = oldwordnum; |
2002 |
|
| 1961 |
numsyllable = oldnumsyllable; |
|
|
| 1962 |
} |
2003 |
} |
| 1963 |
|
2004 |
|
| 1964 |
return NULL; |
2005 |
return NULL; |
| 1965 |
} |
2006 |
} |
| 1966 |
|
2007 |
|
| 1967 |
// check if compound word is correctly spelled |
2008 |
// check if compound word is correctly spelled |
| 1968 |
// hu_mov_rule = spec. Hungarian rule (XXX) |
2009 |
// hu_mov_rule = spec. Hungarian rule (XXX) |
| 1969 |
int AffixMgr::compound_check_morph(const char * word, int len, |
2010 |
int AffixMgr::compound_check_morph(const char * word, int len, |
|
Lines 2075-2090
int AffixMgr::compound_check_morph(const
|
Link Here
|
|---|
|
| 2075 |
sprintf(presult + strlen(presult), "%c%s%s%s", MSEP_FLD, |
2116 |
sprintf(presult + strlen(presult), "%c%s%s%s", MSEP_FLD, |
| 2076 |
MORPH_PART, st, line_uniq_app(&p, MSEP_REC)); |
2117 |
MORPH_PART, st, line_uniq_app(&p, MSEP_REC)); |
| 2077 |
} |
2118 |
} |
| 2078 |
if (p) free(p); |
2119 |
if (p) free(p); |
| 2079 |
checked_prefix = 1; |
2120 |
checked_prefix = 1; |
| 2080 |
} |
2121 |
} |
| 2081 |
// else check forbiddenwords |
2122 |
// else check forbiddenwords |
| 2082 |
} else if (rv->astr && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
2123 |
} else if (rv->astr && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
|
|
2124 |
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen) || |
| 2083 |
TESTAFF(rv->astr, needaffix, rv->alen))) { |
2125 |
TESTAFF(rv->astr, needaffix, rv->alen))) { |
| 2084 |
st[i] = ch; |
2126 |
st[i] = ch; |
| 2085 |
continue; |
2127 |
continue; |
| 2086 |
} |
2128 |
} |
| 2087 |
|
2129 |
|
| 2088 |
// check non_compound flag in suffix and prefix |
2130 |
// check non_compound flag in suffix and prefix |
| 2089 |
if ((rv) && !hu_mov_rule && |
2131 |
if ((rv) && !hu_mov_rule && |
| 2090 |
((pfx && pfx->getCont() && |
2132 |
((pfx && pfx->getCont() && |
|
Lines 2114-2130
int AffixMgr::compound_check_morph(const
|
Link Here
|
|---|
|
| 2114 |
pfx->getContLen())) || |
2156 |
pfx->getContLen())) || |
| 2115 |
(sfx && sfx->getCont() && |
2157 |
(sfx && sfx->getCont() && |
| 2116 |
TESTAFF(sfx->getCont(), compoundmiddle, |
2158 |
TESTAFF(sfx->getCont(), compoundmiddle, |
| 2117 |
sfx->getContLen())))) { |
2159 |
sfx->getContLen())))) { |
| 2118 |
rv = NULL; |
2160 |
rv = NULL; |
| 2119 |
} |
2161 |
} |
| 2120 |
|
2162 |
|
| 2121 |
// check forbiddenwords |
2163 |
// check forbiddenwords |
| 2122 |
if ((rv) && (rv->astr) && TESTAFF(rv->astr, forbiddenword, rv->alen)) continue; |
2164 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) |
|
|
2165 |
|| TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen))) continue; |
| 2123 |
|
2166 |
|
| 2124 |
// increment word number, if the second root has a compoundroot flag |
2167 |
// increment word number, if the second root has a compoundroot flag |
| 2125 |
if ((rv) && (compoundroot) && |
2168 |
if ((rv) && (compoundroot) && |
| 2126 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
2169 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
| 2127 |
wordnum++; |
2170 |
wordnum++; |
| 2128 |
} |
2171 |
} |
| 2129 |
|
2172 |
|
| 2130 |
// first word is acceptable in compound words? |
2173 |
// first word is acceptable in compound words? |
|
Lines 2146-2162
int AffixMgr::compound_check_morph(const
|
Link Here
|
|---|
|
| 2146 |
&& ! (( checkcompoundtriple && !words && // test triple letters |
2189 |
&& ! (( checkcompoundtriple && !words && // test triple letters |
| 2147 |
(word[i-1]==word[i]) && ( |
2190 |
(word[i-1]==word[i]) && ( |
| 2148 |
((i>1) && (word[i-1]==word[i-2])) || |
2191 |
((i>1) && (word[i-1]==word[i-2])) || |
| 2149 |
((word[i-1]==word[i+1])) // may be word[i+1] == '\0' |
2192 |
((word[i-1]==word[i+1])) // may be word[i+1] == '\0' |
| 2150 |
) |
2193 |
) |
| 2151 |
) || |
2194 |
) || |
| 2152 |
( |
2195 |
( |
| 2153 |
// test CHECKCOMPOUNDPATTERN |
2196 |
// test CHECKCOMPOUNDPATTERN |
| 2154 |
numcheckcpd && !words && cpdpat_check(word, i, rv, NULL) |
2197 |
numcheckcpd && !words && cpdpat_check(word, i, rv, NULL, 0) |
| 2155 |
) || |
2198 |
) || |
| 2156 |
( |
2199 |
( |
| 2157 |
checkcompoundcase && !words && cpdcase_check(word, i) |
2200 |
checkcompoundcase && !words && cpdcase_check(word, i) |
| 2158 |
)) |
2201 |
)) |
| 2159 |
) |
2202 |
) |
| 2160 |
// LANG_hu section: spec. Hungarian rule |
2203 |
// LANG_hu section: spec. Hungarian rule |
| 2161 |
|| ((!rv) && (langnum == LANG_hu) && hu_mov_rule && (rv = affix_check(st,i)) && |
2204 |
|| ((!rv) && (langnum == LANG_hu) && hu_mov_rule && (rv = affix_check(st,i)) && |
| 2162 |
(sfx && sfx->getCont() && ( |
2205 |
(sfx && sfx->getCont() && ( |
|
Lines 2222-2238
int AffixMgr::compound_check_morph(const
|
Link Here
|
|---|
|
| 2222 |
// END of LANG_hu section |
2265 |
// END of LANG_hu section |
| 2223 |
// increment word number, if the second root has a compoundroot flag |
2266 |
// increment word number, if the second root has a compoundroot flag |
| 2224 |
if ((rv) && (compoundroot) && |
2267 |
if ((rv) && (compoundroot) && |
| 2225 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
2268 |
(TESTAFF(rv->astr, compoundroot, rv->alen))) { |
| 2226 |
wordnum++; |
2269 |
wordnum++; |
| 2227 |
} |
2270 |
} |
| 2228 |
|
2271 |
|
| 2229 |
// check forbiddenwords |
2272 |
// check forbiddenwords |
| 2230 |
if ((rv) && (rv->astr) && TESTAFF(rv->astr, forbiddenword, rv->alen)) { |
2273 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) || |
|
|
2274 |
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen))) { |
| 2231 |
st[i] = ch; |
2275 |
st[i] = ch; |
| 2232 |
continue; |
2276 |
continue; |
| 2233 |
} |
2277 |
} |
| 2234 |
|
2278 |
|
| 2235 |
// second word is acceptable, as a root? |
2279 |
// second word is acceptable, as a root? |
| 2236 |
// hungarian conventions: compounding is acceptable, |
2280 |
// hungarian conventions: compounding is acceptable, |
| 2237 |
// when compound forms consist of 2 words, or if more, |
2281 |
// when compound forms consist of 2 words, or if more, |
| 2238 |
// then the syllable number of root words must be 6, or lesser. |
2282 |
// then the syllable number of root words must be 6, or lesser. |
|
Lines 2316-2332
int AffixMgr::compound_check_morph(const
|
Link Here
|
|---|
|
| 2316 |
pfx->getContLen())) || |
2360 |
pfx->getContLen())) || |
| 2317 |
(sfx && sfx->getCont() && |
2361 |
(sfx && sfx->getCont() && |
| 2318 |
TESTAFF(sfx->getCont(), compoundforbidflag, |
2362 |
TESTAFF(sfx->getCont(), compoundforbidflag, |
| 2319 |
sfx->getContLen())))) { |
2363 |
sfx->getContLen())))) { |
| 2320 |
rv = NULL; |
2364 |
rv = NULL; |
| 2321 |
} |
2365 |
} |
| 2322 |
|
2366 |
|
| 2323 |
// check forbiddenwords |
2367 |
// check forbiddenwords |
| 2324 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr,forbiddenword,rv->alen)) |
2368 |
if ((rv) && (rv->astr) && (TESTAFF(rv->astr,forbiddenword,rv->alen) || |
|
|
2369 |
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen)) |
| 2325 |
&& (! TESTAFF(rv->astr, needaffix, rv->alen))) { |
2370 |
&& (! TESTAFF(rv->astr, needaffix, rv->alen))) { |
| 2326 |
st[i] = ch; |
2371 |
st[i] = ch; |
| 2327 |
continue; |
2372 |
continue; |
| 2328 |
} |
2373 |
} |
| 2329 |
|
2374 |
|
| 2330 |
if (langnum == LANG_hu) { |
2375 |
if (langnum == LANG_hu) { |
| 2331 |
// calculate syllable number of the word |
2376 |
// calculate syllable number of the word |
| 2332 |
numsyllable += get_syllable(word + i, strlen(word + i)); |
2377 |
numsyllable += get_syllable(word + i, strlen(word + i)); |
|
Lines 2886-2902
char * AffixMgr::morphgen(char * ts, int
|
Link Here
|
|---|
|
| 2886 |
|
2931 |
|
| 2887 |
int cmp = morphcmp(stemmorph, targetmorph); |
2932 |
int cmp = morphcmp(stemmorph, targetmorph); |
| 2888 |
|
2933 |
|
| 2889 |
if (cmp == 0) { |
2934 |
if (cmp == 0) { |
| 2890 |
char * newword = sptr->add(ts, wl); |
2935 |
char * newword = sptr->add(ts, wl); |
| 2891 |
if (newword) { |
2936 |
if (newword) { |
| 2892 |
hentry * check = pHMgr->lookup(newword); // XXX extra dic |
2937 |
hentry * check = pHMgr->lookup(newword); // XXX extra dic |
| 2893 |
if (!check || !check->astr || |
2938 |
if (!check || !check->astr || |
| 2894 |
!TESTAFF(check->astr, forbiddenword, check->alen)) { |
2939 |
!(TESTAFF(check->astr, forbiddenword, check->alen) || |
|
|
2940 |
TESTAFF(check->astr, ONLYUPCASEFLAG, check->alen))) { |
| 2895 |
return newword; |
2941 |
return newword; |
| 2896 |
} |
2942 |
} |
| 2897 |
free(newword); |
2943 |
free(newword); |
| 2898 |
} |
2944 |
} |
| 2899 |
} |
2945 |
} |
| 2900 |
|
2946 |
|
| 2901 |
// recursive call for secondary suffixes |
2947 |
// recursive call for secondary suffixes |
| 2902 |
if ((level == 0) && (cmp == 1) && (sptr->getContLen() > 0) && |
2948 |
if ((level == 0) && (cmp == 1) && (sptr->getContLen() > 0) && |
|
Lines 3440-3456
int AffixMgr::parse_reptable(char * lin
|
Link Here
|
|---|
|
| 3440 |
case 0: { |
3486 |
case 0: { |
| 3441 |
if (strncmp(piece,"REP",3) != 0) { |
3487 |
if (strncmp(piece,"REP",3) != 0) { |
| 3442 |
HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af->getlinenum()); |
3488 |
HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af->getlinenum()); |
| 3443 |
numrep = 0; |
3489 |
numrep = 0; |
| 3444 |
return 1; |
3490 |
return 1; |
| 3445 |
} |
3491 |
} |
| 3446 |
break; |
3492 |
break; |
| 3447 |
} |
3493 |
} |
| 3448 |
case 1: { reptable[j].pattern = mystrrep(mystrdup(piece),"_"," "); break; } |
3494 |
case 1: { |
|
|
3495 |
if (*piece == '^') reptable[j].start = true; else reptable[j].start = false; |
| 3496 |
reptable[j].pattern = mystrrep(mystrdup(piece + int(reptable[j].start)),"_"," "); |
| 3497 |
int lr = strlen(reptable[j].pattern) - 1; |
| 3498 |
if (reptable[j].pattern[lr] == '$') { |
| 3499 |
reptable[j].end = true; |
| 3500 |
reptable[j].pattern[lr] = '\0'; |
| 3501 |
} else reptable[j].end = false; |
| 3502 |
break; |
| 3503 |
} |
| 3449 |
case 2: { reptable[j].pattern2 = mystrrep(mystrdup(piece),"_"," "); break; } |
3504 |
case 2: { reptable[j].pattern2 = mystrrep(mystrdup(piece),"_"," "); break; } |
| 3450 |
default: break; |
3505 |
default: break; |
| 3451 |
} |
3506 |
} |
| 3452 |
i++; |
3507 |
i++; |
| 3453 |
} |
3508 |
} |
| 3454 |
piece = mystrsep(&tp, 0); |
3509 |
piece = mystrsep(&tp, 0); |
| 3455 |
} |
3510 |
} |
| 3456 |
if ((!(reptable[j].pattern)) || (!(reptable[j].pattern2))) { |
3511 |
if ((!(reptable[j].pattern)) || (!(reptable[j].pattern2))) { |
|
Lines 3530-3547
int AffixMgr::parse_convtable(char * li
|
Link Here
|
|---|
|
| 3530 |
} |
3585 |
} |
| 3531 |
default: break; |
3586 |
default: break; |
| 3532 |
} |
3587 |
} |
| 3533 |
i++; |
3588 |
i++; |
| 3534 |
} |
3589 |
} |
| 3535 |
piece = mystrsep(&tp, 0); |
3590 |
piece = mystrsep(&tp, 0); |
| 3536 |
} |
3591 |
} |
| 3537 |
if (!pattern || !pattern2) { |
3592 |
if (!pattern || !pattern2) { |
| 3538 |
HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af->getlinenum()); |
3593 |
if (pattern) |
| 3539 |
return 1; |
3594 |
free(pattern); |
|
|
3595 |
if (pattern2) |
| 3596 |
free(pattern2); |
| 3597 |
HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af->getlinenum()); |
| 3598 |
return 1; |
| 3540 |
} |
3599 |
} |
| 3541 |
(*rl)->add(pattern, pattern2); |
3600 |
(*rl)->add(pattern, pattern2); |
| 3542 |
} |
3601 |
} |
| 3543 |
return 0; |
3602 |
return 0; |
| 3544 |
} |
3603 |
} |
| 3545 |
|
3604 |
|
| 3546 |
|
3605 |
|
| 3547 |
/* parse in the typical fault correcting table */ |
3606 |
/* parse in the typical fault correcting table */ |
|
Lines 3927-3961
int AffixMgr::parse_maptable(char * lin
|
Link Here
|
|---|
|
| 3927 |
} |
3986 |
} |
| 3928 |
} |
3987 |
} |
| 3929 |
return 0; |
3988 |
return 0; |
| 3930 |
} |
3989 |
} |
| 3931 |
|
3990 |
|
| 3932 |
/* parse in the word breakpoint table */ |
3991 |
/* parse in the word breakpoint table */ |
| 3933 |
int AffixMgr::parse_breaktable(char * line, FileMgr * af) |
3992 |
int AffixMgr::parse_breaktable(char * line, FileMgr * af) |
| 3934 |
{ |
3993 |
{ |
| 3935 |
if (numbreak != 0) { |
3994 |
if (numbreak > -1) { |
| 3936 |
HUNSPELL_WARNING(stderr, "error: line %d: multiple table definitions\n", af->getlinenum()); |
3995 |
HUNSPELL_WARNING(stderr, "error: line %d: multiple table definitions\n", af->getlinenum()); |
| 3937 |
return 1; |
3996 |
return 1; |
| 3938 |
} |
3997 |
} |
| 3939 |
char * tp = line; |
3998 |
char * tp = line; |
| 3940 |
char * piece; |
3999 |
char * piece; |
| 3941 |
int i = 0; |
4000 |
int i = 0; |
| 3942 |
int np = 0; |
4001 |
int np = 0; |
| 3943 |
piece = mystrsep(&tp, 0); |
4002 |
piece = mystrsep(&tp, 0); |
| 3944 |
while (piece) { |
4003 |
while (piece) { |
| 3945 |
if (*piece != '\0') { |
4004 |
if (*piece != '\0') { |
| 3946 |
switch(i) { |
4005 |
switch(i) { |
| 3947 |
case 0: { np++; break; } |
4006 |
case 0: { np++; break; } |
| 3948 |
case 1: { |
4007 |
case 1: { |
| 3949 |
numbreak = atoi(piece); |
4008 |
numbreak = atoi(piece); |
| 3950 |
if (numbreak < 1) { |
4009 |
if (numbreak < 0) { |
| 3951 |
HUNSPELL_WARNING(stderr, "error: line %d: bad entry number\n", af->getlinenum()); |
4010 |
HUNSPELL_WARNING(stderr, "error: line %d: bad entry number\n", af->getlinenum()); |
| 3952 |
return 1; |
4011 |
return 1; |
| 3953 |
} |
4012 |
} |
|
|
4013 |
if (numbreak == 0) return 0; |
| 3954 |
breaktable = (char **) malloc(numbreak * sizeof(char *)); |
4014 |
breaktable = (char **) malloc(numbreak * sizeof(char *)); |
| 3955 |
if (!breaktable) return 1; |
4015 |
if (!breaktable) return 1; |
| 3956 |
np++; |
4016 |
np++; |
| 3957 |
break; |
4017 |
break; |
| 3958 |
} |
4018 |
} |
| 3959 |
default: break; |
4019 |
default: break; |
| 3960 |
} |
4020 |
} |
| 3961 |
i++; |
4021 |
i++; |