| OLD | NEW |
| 1 #include "license.hunspell" | 1 #include "license.hunspell" |
| 2 #include "license.myspell" | 2 #include "license.myspell" |
| 3 | 3 |
| 4 #include <stdlib.h> | 4 #include <stdlib.h> |
| 5 #include <string.h> | 5 #include <string.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <ctype.h> | 7 #include <ctype.h> |
| 8 | 8 |
| 9 #include "suggestmgr.hxx" | 9 #include "suggestmgr.hxx" |
| 10 #include "htypes.hxx" | 10 #include "htypes.hxx" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 if (source->astr) { | 97 if (source->astr) { |
| 98 hash_item->astr = *source->astr; | 98 hash_item->astr = *source->astr; |
| 99 hash_item->entry.astr = &hash_item->astr; | 99 hash_item->entry.astr = &hash_item->astr; |
| 100 } | 100 } |
| 101 return &hash_item->entry; | 101 return &hash_item->entry; |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace | 104 } // namespace |
| 105 #endif | 105 #endif |
| 106 | 106 |
| 107 |
| 108 #ifdef HUNSPELL_CHROME_CLIENT |
| 109 SuggestMgr::SuggestMgr(hunspell::BDictReader* reader, |
| 110 const char * tryme, int maxn, |
| 111 AffixMgr * aptr) |
| 112 { |
| 113 bdict_reader = reader; |
| 114 #else |
| 107 SuggestMgr::SuggestMgr(const char * tryme, int maxn, | 115 SuggestMgr::SuggestMgr(const char * tryme, int maxn, |
| 108 AffixMgr * aptr) | 116 AffixMgr * aptr) |
| 109 { | 117 { |
| 118 #endif |
| 110 | 119 |
| 111 // register affix manager and check in string of chars to | 120 // register affix manager and check in string of chars to |
| 112 // try when building candidate suggestions | 121 // try when building candidate suggestions |
| 113 pAMgr = aptr; | 122 pAMgr = aptr; |
| 114 | 123 |
| 115 csconv = NULL; | 124 csconv = NULL; |
| 116 | 125 |
| 117 ckeyl = 0; | 126 ckeyl = 0; |
| 118 ckey = NULL; | 127 ckey = NULL; |
| 119 ckey_utf = NULL; | 128 ckey_utf = NULL; |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 | 501 |
| 493 // suggestions for a typical fault of spelling, that | 502 // suggestions for a typical fault of spelling, that |
| 494 // differs with more, than 1 letter from the right form. | 503 // differs with more, than 1 letter from the right form. |
| 495 int SuggestMgr::replchars(char** wlst, const char * word, int ns, int cpdsuggest
) | 504 int SuggestMgr::replchars(char** wlst, const char * word, int ns, int cpdsuggest
) |
| 496 { | 505 { |
| 497 char candidate[MAXSWUTF8L]; | 506 char candidate[MAXSWUTF8L]; |
| 498 const char * r; | 507 const char * r; |
| 499 int lenr, lenp; | 508 int lenr, lenp; |
| 500 int wl = strlen(word); | 509 int wl = strlen(word); |
| 501 if (wl < 2 || ! pAMgr) return ns; | 510 if (wl < 2 || ! pAMgr) return ns; |
| 511 |
| 512 #ifdef HUNSPELL_CHROME_CLIENT |
| 513 const char *pattern, *pattern2; |
| 514 hunspell::ReplacementIterator iterator = bdict_reader->GetReplacementIterator(
); |
| 515 while (iterator.GetNext(&pattern, &pattern2)) { |
| 516 r = word; |
| 517 lenr = strlen(pattern2); |
| 518 lenp = strlen(pattern); |
| 519 |
| 520 // search every occurence of the pattern in the word |
| 521 while ((r=strstr(r, pattern)) != NULL) { |
| 522 strcpy(candidate, word); |
| 523 if (r-word + lenr + strlen(r+lenp) >= MAXLNLEN) break; |
| 524 strcpy(candidate+(r-word), pattern2); |
| 525 strcpy(candidate+(r-word)+lenr, r+lenp); |
| 526 ns = testsug(wlst, candidate, wl-lenp+lenr, ns, cpdsuggest, NULL, NULL
); |
| 527 if (ns == -1) return -1; |
| 528 // check REP suggestions with space |
| 529 char * sp = strchr(candidate, ' '); |
| 530 if (sp) { |
| 531 char * prev = candidate; |
| 532 while (sp) { |
| 533 *sp = '\0'; |
| 534 if (checkword(prev, strlen(prev), 0, NULL, NULL)) { |
| 535 int oldns = ns; |
| 536 *sp = ' '; |
| 537 ns = testsug(wlst, sp + 1, strlen(sp + 1), ns, cpdsuggest, NULL,
NULL); |
| 538 if (ns == -1) return -1; |
| 539 if (oldns < ns) { |
| 540 free(wlst[ns - 1]); |
| 541 wlst[ns - 1] = mystrdup(candidate); |
| 542 if (!wlst[ns - 1]) return -1; |
| 543 } |
| 544 } |
| 545 *sp = ' '; |
| 546 prev = sp + 1; |
| 547 sp = strchr(prev, ' '); |
| 548 } |
| 549 } |
| 550 r++; // search for the next letter |
| 551 } |
| 552 } |
| 553 #else |
| 502 int numrep = pAMgr->get_numrep(); | 554 int numrep = pAMgr->get_numrep(); |
| 503 struct replentry* reptable = pAMgr->get_reptable(); | 555 struct replentry* reptable = pAMgr->get_reptable(); |
| 504 if (reptable==NULL) return ns; | 556 if (reptable==NULL) return ns; |
| 505 for (int i=0; i < numrep; i++ ) { | 557 for (int i=0; i < numrep; i++ ) { |
| 506 r = word; | 558 r = word; |
| 507 lenr = strlen(reptable[i].pattern2); | 559 lenr = strlen(reptable[i].pattern2); |
| 508 lenp = strlen(reptable[i].pattern); | 560 lenp = strlen(reptable[i].pattern); |
| 509 // search every occurence of the pattern in the word | 561 // search every occurence of the pattern in the word |
| 510 while ((r=strstr(r, reptable[i].pattern)) != NULL && (!reptable[i].end ||
strlen(r) == strlen(reptable[i].pattern)) && | 562 while ((r=strstr(r, reptable[i].pattern)) != NULL && (!reptable[i].end ||
strlen(r) == strlen(reptable[i].pattern)) && |
| 511 (!reptable[i].start || r == word)) { | 563 (!reptable[i].start || r == word)) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 533 } | 585 } |
| 534 } | 586 } |
| 535 *sp = ' '; | 587 *sp = ' '; |
| 536 prev = sp + 1; | 588 prev = sp + 1; |
| 537 sp = strchr(prev, ' '); | 589 sp = strchr(prev, ' '); |
| 538 } | 590 } |
| 539 } | 591 } |
| 540 r++; // search for the next letter | 592 r++; // search for the next letter |
| 541 } | 593 } |
| 542 } | 594 } |
| 595 #endif |
| 543 return ns; | 596 return ns; |
| 544 } | 597 } |
| 545 | 598 |
| 546 // perhaps we doubled two characters (pattern aba -> ababa, for example vacation
-> vacacation) | 599 // perhaps we doubled two characters (pattern aba -> ababa, for example vacation
-> vacacation) |
| 547 int SuggestMgr::doubletwochars(char** wlst, const char * word, int ns, int cpdsu
ggest) | 600 int SuggestMgr::doubletwochars(char** wlst, const char * word, int ns, int cpdsu
ggest) |
| 548 { | 601 { |
| 549 char candidate[MAXSWUTF8L]; | 602 char candidate[MAXSWUTF8L]; |
| 550 int state=0; | 603 int state=0; |
| 551 int wl = strlen(word); | 604 int wl = strlen(word); |
| 552 if (wl < 5 || ! pAMgr) return ns; | 605 if (wl < 5 || ! pAMgr) return ns; |
| (...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2094 len++; | 2147 len++; |
| 2095 i--; | 2148 i--; |
| 2096 j--; | 2149 j--; |
| 2097 } else if (result[i*(n+1) + j] == LCS_UP) { | 2150 } else if (result[i*(n+1) + j] == LCS_UP) { |
| 2098 i--; | 2151 i--; |
| 2099 } else j--; | 2152 } else j--; |
| 2100 } | 2153 } |
| 2101 free(result); | 2154 free(result); |
| 2102 return len; | 2155 return len; |
| 2103 } | 2156 } |
| OLD | NEW |