| |
---|
| | continue; |
---|
| | } |
---|
| | if (String(s).length() >= 2) |
---|
| | if (String(s).substr(0,2) == ";;") continue; |
---|
| | vector<WideString> sList; |
---|
| | WideString wstr; |
---|
| | |
---|
| | WideString wstr,ent; |
---|
| | iconv.convert(wstr,String(s)); |
---|
| | if (!wstr.length()) continue; |
---|
| | uint pos = 0,count = 0; |
---|
| | // "/"でsplit。 |
---|
| | while(-1) { |
---|
| | if ((pos + count) >= wstr.length()) break; |
---|
| | if (wstr.at(pos + count) == utf8_mbstowcs(String("/"))[0]) { |
---|
| | if (count) sList.push_back(wstr.substr(pos,count)); |
---|
| | pos += (count + 1); |
---|
| | count = 0; |
---|
| | continue; |
---|
| | } |
---|
| | count ++; |
---|
| | } |
---|
| | // 読みの空白を削除。 |
---|
| | // @todo okuri-ari |
---|
| | wstr = WideString(); |
---|
| | if (sList.size() < 2) continue; |
---|
| | for(unsigned int i = 0;i < sList[0].length();i ++) { |
---|
| | if (sList[0][i] != utf8_mbstowcs(String(" "))[0]) { |
---|
| | wstr = wstr + sList[0][i]; |
---|
| | for(unsigned int i = 0;i < wstr.length();i ++) { |
---|
| | if (wstr.substr(i,1) == utf8_mbstowcs(String(" "))) { |
---|
| | ent = wstr.substr(0,i); |
---|
| | break; |
---|
| | } |
---|
| | } |
---|
| | sList[0] = wstr; |
---|
| | |
---|
| | SKKDicEntry dic; |
---|
| | vector<WideString> sList = parser(wstr); |
---|
| | for(unsigned int i = 1;i < sList.size();i ++) { |
---|
| | SKKDicEntryData e; |
---|
| | e.cache = false; |
---|
| | wstr = sList[i]; |
---|
| | e.kouho = wstr; |
---|
| | SKKDicEntryData e = annotationParser(sList[i]); |
---|
| | dic.data.push_back(e); |
---|
| | |
---|
| | } |
---|
| | dic_data.insert(pair<WideString,SKKDicEntry>(sList[0],dic)); |
---|
| | dic.cache = true; |
---|
| | dic.okuri = okuri; |
---|
| | dic_data.insert(pair<WideString,SKKDicEntry>(ent,dic)); |
---|
| | } |
---|
| | fclose(f); |
---|
| | } |
---|
| | |
---|
| | |
---|
| | /*! |
---|
| | \fn SKKDic::parser(const WideString data) |
---|
| | */ |
---|
| | vector<WideString> SKKDic::parser(const WideString data) |
---|
| | { |
---|
| | uint pos = 0,count = 0; |
---|
| | vector<WideString> sList; |
---|
| | // "/"¤Çsplit¡£ |
---|
| | while(-1) { |
---|
| | if ((pos + count) >= data.length()) break; |
---|
| | if (data.at(pos + count) == utf8_mbstowcs(String("/"))[0]) { |
---|
| | if (count) sList.push_back(data.substr(pos,count)); |
---|
| | pos += (count + 1); |
---|
| | count = 0; |
---|
| | continue; |
---|
| | } |
---|
| | count ++; |
---|
| | } |
---|
| | return sList; |
---|
| | } |
---|
| | |
---|
| | |
---|
| | /*! |
---|
| | \fn SKKDic::find(WideString text) |
---|
| | */ |
---|
| | const vector<SKKDicEntryData> SKKDic::find(WideString text) |
---|
| | { |
---|
| | vector<SKKDicEntryData> d; |
---|
| | map<WideString,SKKDicEntry>::iterator it = dic_data.find(text); |
---|
| | if (it == dic_data.end()) return vector<SKKDicEntryData>(); |
---|
| | //return it->second.data; |
---|
| | vector<SKKDicEntryData> d; |
---|
| | for(unsigned int i = 0;i < it->second.data.size();i ++) { |
---|
| | if (!it->second.data[i].cache) { |
---|
| | d.push_back(annotationParser(it->second.data[i].kouho)); |
---|
| | } else d.push_back(it->second.data[i]); |
---|
| | } |
---|
| | if (it == dic_data.end()) return d; |
---|
| | if (it->second.cache) return it->second.data; |
---|
| | return d; |
---|
| | } |
---|
| | |
---|
| | |
---|
| |
---|
| | */ |
---|
| | SKKDicEntryData SKKDic::annotationParser(WideString l) |
---|
| | { |
---|
| | SKKDicEntryData e; |
---|
| | e.cache = true; |
---|
| | if (l.length() <= 2) { |
---|
| | e.kouho = l; |
---|
| | return e; |
---|
| | } |
---|
| |
---|
| | return e; |
---|
| | |
---|
| | } |
---|
| | |
---|
| | |
---|
| | |