| |
---|
| | * Free Software Foundation, Inc., * |
---|
| | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
---|
| | ***************************************************************************/ |
---|
| | #include "romkan.h" |
---|
| | #include "romkan_table.h" |
---|
| | #include "scim_wnn_def.h" |
---|
| | |
---|
| | #ifdef HAVE_CONFIG_H |
---|
| | #include <config.h> |
---|
| |
---|
| | */ |
---|
| | void Romkan::loadTable(const String &filename, bool inc) |
---|
| | { |
---|
| | FILE *f = fopen(filename.c_str(),"r"); |
---|
| | if (!f) return; |
---|
| | if (!f) { |
---|
| | #ifdef SCIM_WNN_DATADIR |
---|
| | String fn = SCIM_WNN_DATADIR; |
---|
| | fn += "/" + filename; |
---|
| | f = fopen(fn.c_str(),"r"); |
---|
| | if (!f) return; |
---|
| | #else |
---|
| | return; |
---|
| | #endif |
---|
| | } |
---|
| | |
---|
| | while(-1) { |
---|
| | char s[256]; |
---|
| | if(fgets(s,256,f) == NULL) break; |
---|
| |
---|
| | String rk_table = config->read(SCIM_CONFIG_WNN_ROMKAN_TABLE_FILE,String(SCIM_DEFAULT_WNN_ROMKAN_TABLE_FILE)); |
---|
| | |
---|
| | if (rk_table.size()) { |
---|
| | loadTable(rk_table); |
---|
| | } else { |
---|
| | unsigned int i = 0; |
---|
| | while(strcmp(_RomkanTable[i],"") != 0) { |
---|
| | WideString w; |
---|
| | String s = _RomkanTable[i]; |
---|
| | iconvert.convert(w,String(_RomkanTable[i + 1])); |
---|
| | RomkanTable.insert(pair<String,WideString>(s,w)); |
---|
| | |
---|
| | for(unsigned int j = s.length();j > 1;j --) { |
---|
| | String k = s.substr(0,j - 1); |
---|
| | if ((keepTable.find(k) == keepTable.end()) && (RomkanTable.find(k) == RomkanTable.end())) { |
---|
| | keepTable.insert(k); |
---|
| | } |
---|
| | } |
---|
| | i += 2; |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | if (tableConfig.find("nnMode") != tableConfig.end()) |
---|
| | nnMode = string2bool(tableConfig["nnMode"]); |
---|
| |
---|
| | |