Index: src/hunspell/suggestmgr.cxx |
=================================================================== |
--- src/hunspell/suggestmgr.cxx (revision 149334) |
+++ src/hunspell/suggestmgr.cxx (working copy) |
@@ -104,9 +104,18 @@ |
} // namespace |
#endif |
+ |
+#ifdef HUNSPELL_CHROME_CLIENT |
+SuggestMgr::SuggestMgr(hunspell::BDictReader* reader, |
+ const char * tryme, int maxn, |
+ AffixMgr * aptr) |
+{ |
+ bdict_reader = reader; |
+#else |
SuggestMgr::SuggestMgr(const char * tryme, int maxn, |
AffixMgr * aptr) |
{ |
+#endif |
// register affix manager and check in string of chars to |
// try when building candidate suggestions |
@@ -499,6 +508,49 @@ |
int lenr, lenp; |
int wl = strlen(word); |
if (wl < 2 || ! pAMgr) return ns; |
+ |
+#ifdef HUNSPELL_CHROME_CLIENT |
+ const char *pattern, *pattern2; |
+ hunspell::ReplacementIterator iterator = bdict_reader->GetReplacementIterator(); |
+ while (iterator.GetNext(&pattern, &pattern2)) { |
+ r = word; |
+ lenr = strlen(pattern2); |
+ lenp = strlen(pattern); |
+ |
+ // search every occurence of the pattern in the word |
+ while ((r=strstr(r, pattern)) != NULL) { |
+ strcpy(candidate, word); |
+ if (r-word + lenr + strlen(r+lenp) >= MAXLNLEN) break; |
+ strcpy(candidate+(r-word), pattern2); |
+ strcpy(candidate+(r-word)+lenr, r+lenp); |
+ ns = testsug(wlst, candidate, wl-lenp+lenr, ns, cpdsuggest, NULL, NULL); |
+ if (ns == -1) return -1; |
+ // check REP suggestions with space |
+ char * sp = strchr(candidate, ' '); |
+ if (sp) { |
+ char * prev = candidate; |
+ while (sp) { |
+ *sp = '\0'; |
+ if (checkword(prev, strlen(prev), 0, NULL, NULL)) { |
+ int oldns = ns; |
+ *sp = ' '; |
+ ns = testsug(wlst, sp + 1, strlen(sp + 1), ns, cpdsuggest, NULL, NULL); |
+ if (ns == -1) return -1; |
+ if (oldns < ns) { |
+ free(wlst[ns - 1]); |
+ wlst[ns - 1] = mystrdup(candidate); |
+ if (!wlst[ns - 1]) return -1; |
+ } |
+ } |
+ *sp = ' '; |
+ prev = sp + 1; |
+ sp = strchr(prev, ' '); |
+ } |
+ } |
+ r++; // search for the next letter |
+ } |
+ } |
+#else |
int numrep = pAMgr->get_numrep(); |
struct replentry* reptable = pAMgr->get_reptable(); |
if (reptable==NULL) return ns; |
@@ -540,6 +592,7 @@ |
r++; // search for the next letter |
} |
} |
+#endif |
return ns; |
} |