return bFound;
}
-void Library::LookupWithFuzzy(const string &str, TSearchResultList& res_list)
+void Library::LookupWithFuzzy(const gchar* sWord)
{
- static const int MAXFUZZY=10;
+ static const int MAX_FUZZY_MATCH_ITEM=100;
+ gchar *fuzzy_reslist[MAX_FUZZY_MATCH_ITEM];
+ bool bFound = false;
- gchar *fuzzy_res[MAXFUZZY];
- if (!Libs::LookupWithFuzzy(str.c_str(), fuzzy_res, MAXFUZZY, query_dictmask))
- return;
-
- for (gchar **p=fuzzy_res, **end=fuzzy_res+MAXFUZZY;
- p!=end && *p; ++p) {
-// SimpleLookup(*p, res_list);
- g_free(*p);
+ pMStarDict->ResultsListClear();
+
+ bFound = Libs::LookupWithFuzzy(sWord, fuzzy_reslist, MAX_FUZZY_MATCH_ITEM, query_dictmask);
+ if (bFound) {
+ SimpleLookup(fuzzy_reslist[0], iCurrentIndex);
+
+ for (int i=0; i<MAX_FUZZY_MATCH_ITEM && fuzzy_reslist[i]; i++) {
+ pMStarDict->ResultsListInsertLast(fuzzy_reslist[i]);
+ g_free(fuzzy_reslist[i]);
+ }
+ pMStarDict->ReScroll();
}
}
-void Library::LookupWithRule(const string &str, TSearchResultList& res_list)
+void Library::LookupWithRule(const gchar* sWord)
{
- std::vector<gchar *> match_res((MAX_MATCH_ITEM_PER_LIB) * query_dictmask.size());
+ gint iMatchCount=0;
+ gchar **ppMatchWord = (gchar **)g_malloc(sizeof(gchar *) * (MAX_MATCH_ITEM_PER_LIB) * query_dictmask.size());
- gint nfound=Libs::LookupWithRule(str.c_str(), &match_res[0], query_dictmask);
- if (!nfound)
- return;
+ pMStarDict->ResultsListClear();
+
+ iMatchCount=Libs::LookupWithRule(sWord, ppMatchWord, query_dictmask);
+ if (iMatchCount) {
+ for (gint i=0; i<iMatchCount; i++)
+ pMStarDict->ResultsListInsertLast(ppMatchWord[i]);
+
+ SimpleLookup(ppMatchWord[0], iCurrentIndex);
+ pMStarDict->ReScroll();
- for (gint i=0; i<nfound; ++i) {
-// SimpleLookup(match_res[i], res_list);
- g_free(match_res[i]);
+ for(gint i=0; i<iMatchCount; i++)
+ g_free(ppMatchWord[i]);
}
+ g_free(ppMatchWord);
}
void Library::LookupData(const string &str, TSearchResultList& res_list)
bool BuildResultData(std::vector<InstantDictIndex> &dictmask, const char* sWord, CurrentIndex *iIndex, int iLib, TSearchResultList& res_list);
bool SimpleLookup(const gchar* sWord, CurrentIndex* piIndex);
+ void LookupWithFuzzy(const gchar* sWord);
+ void LookupWithRule(const gchar* sWord);
private:
- void LookupWithFuzzy(const string &str, TSearchResultList& res_list);
- void LookupWithRule(const string &str, TSearchResultList& res_lsit);
void LookupData(const string &str, TSearchResultList& res_list);
};
switch (analyse_query(sWord, query)) {
case qtFUZZY:
g_debug ("FUZZY");
-// oLibs->LookupWithFuzzy(query, res_list);
+ mStarDict->oLibs->LookupWithFuzzy(sWord);
break;
case qtREGEX:
g_debug ("REGEX");
-// oLibs->LookupWithRule(query, res_list);
+ mStarDict->oLibs->LookupWithRule(sWord);
break;
case qtSIMPLE:
g_debug ("SIMPLE");
bFound = mStarDict->oLibs->SimpleLookup(sWord, mStarDict->oLibs->iCurrentIndex);
if (!bFound) {
- /* suggested */
+ const gchar *sugWord = mStarDict->oLibs->GetSuggestWord(sWord, mStarDict->oLibs->iCurrentIndex, mStarDict->oLibs->query_dictmask, 0);
+ if (sugWord) {
+ gchar *sSugWord = g_strdup(sugWord);
+ bFound = mStarDict->oLibs->SimpleLookup(sSugWord, mStarDict->oLibs->iCurrentIndex);
+ g_free(sSugWord);
+ }
}
mStarDict->oLibs->ListWords(mStarDict->oLibs->iCurrentIndex);
break;