Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Unified Diff: src/hunspell/suggestmgr.cxx

Issue 11299291: Fixes non-working secondary Hunspell suggestion mechanism as reported here: http://code.google.com/… (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/hunspell/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hunspell/suggestmgr.hxx ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « src/hunspell/suggestmgr.hxx ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698