英単語予測格納をvectorからsetへ。
1 parent 0b347ec commit 8efa834195646af003e2c9ccd18517acd2df7c44
@tamra tamra authored on 9 Feb 2006
Showing 3 changed files
View
10
honoka/plugins/wordsdic.cpp
 
/*!
\fn Honoka::WordsDic::find(const string &word)
*/
vector<string> Honoka::WordsDic::find(const string &word)
set<string> Honoka::WordsDic::find(const string &word)
{
vector<string> res,bres;
set<string> res,bres;
if (fd == -1) return res;
if (word.length() > 255) return res;
if (fd == -1) return res;
char w[256],ow[256];
if (p[i] == 0) break;
s += p[i];
}
if (strncmp(ow,ob,word.length()) == 0)
res.push_back(s);
else bres.push_back(s);
res.insert(s);
else bres.insert(s);
}
while(*p != '\n') p ++;
p ++;
}
for(unsigned int i = 0;i < bres.size();i ++) res.push_back(bres[i]);
for(set<string>::iterator it = bres.begin();it != bres.end();it ++) res.insert(*it);
return res;
}
View
4
honoka/plugins/wordsdic.h
 
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>
 
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
public:
WordsDic(const string &filename);
 
~WordsDic();
vector<string> find(const string &word);
set<string> find(const string &word);
 
protected:
int fd;
char *mmapptr;
View
4
honoka/plugins/wordsprediction.cpp
}
if (!word.length()) return l;
prewords = str.substr(0,str.length() - word.length());
pos = prewords.length();
vector<string> res = dic->find(utf8_wcstombs(word).c_str());
set<string> res = dic->find(utf8_wcstombs(word).c_str());
if (res.size() > limit) {
l.Title = utf8_mbstowcs(String(_("too many prediction results!")));
l.kType = PREDICTION;
l.kouho.push_back(ResultEntry(str,word));
l.kouho.push_back(ResultEntry(str,word));
} else {
l.Title = utf8_mbstowcs(String(_("lookup result")));
l.kType = PREDICTION;
for(vector<string>::iterator it = res.begin();it != res.end();it ++) {
for(set<string>::iterator it = res.begin();it != res.end();it ++) {
if (addSpace) l.kouho.push_back(ResultEntry(prewords + utf8_mbstowcs(*it) + utf8_mbstowcs(" "),utf8_mbstowcs(*it)));
else l.kouho.push_back(ResultEntry(prewords + utf8_mbstowcs(*it),utf8_mbstowcs(*it)));
}
}