Skip to content

Commit

Permalink
1.5.9
Browse files Browse the repository at this point in the history
・辞書の注釈も実行変換するようにしました。

・補完が使用できなくなっていたバグを修正しました。

・内部データ構造の見直しを行いました。
  • Loading branch information
nathancorvussolis committed Apr 23, 2014
1 parent fa6271a commit f487379
Show file tree
Hide file tree
Showing 27 changed files with 432 additions and 332 deletions.
6 changes: 3 additions & 3 deletions common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define COMMON_H

#define TEXTSERVICE_NAME L"CorvusSKK"
#define TEXTSERVICE_VER L"1.5.8"
#define TEXTSERVICE_VER L"1.5.9"

#ifndef _DEBUG
#define TEXTSERVICE_DESC TEXTSERVICE_NAME
Expand All @@ -14,8 +14,8 @@
//for resource
#define RC_AUTHOR "nathancorvussolis"
#define RC_PRODUCT "CorvusSKK"
#define RC_VERSION "1.5.8"
#define RC_VERSION_D 1,5,8,0
#define RC_VERSION "1.5.9"
#define RC_VERSION_D 1,5,9,0

#define DICBUFSIZE 0x2000
#define PIPEBUFSIZE 0x2000
Expand Down
4 changes: 2 additions & 2 deletions common/parseskkdic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ int ReadSKKDicLine(FILE *fp, WCHAR bom, int &okuri, std::wstring &key,

if(okuri == 1)
{
//送りありエントリのブロック形式
//送りありエントリのブロック
ParseSKKDicOkuriBlock(s, o);

//送りありエントリのブロック形式を除去
//送りありエントリのブロックを除去
re.assign(L"\\[[^\\[\\]]+?/[^\\[\\]]+?/\\]/");
fmt.assign(L"");
s = std::regex_replace(s, re, fmt);
Expand Down
23 changes: 21 additions & 2 deletions common/parseskkdic.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,30 @@
#ifndef PARSESKKDIC_H
#define PARSESKKDIC_H

typedef std::pair< std::wstring, std::wstring > SKKDICCANDIDATE;
//変換済み検索結果
typedef std::pair< std::wstring, std::wstring > CANDIDATEBASE; //候補、注釈
typedef std::pair< CANDIDATEBASE, CANDIDATEBASE > CANDIDATE; //表示用、辞書登録用
typedef std::vector< CANDIDATE > CANDIDATES;

//検索結果
typedef std::pair< std::wstring, std::wstring > SKKDICCANDIDATE; //候補、注釈
typedef std::vector< SKKDICCANDIDATE > SKKDICCANDIDATES;

typedef std::pair< std::wstring, SKKDICCANDIDATES > SKKDICOKURIBLOCK;
//送りありエントリのブロック
typedef std::pair< std::wstring, SKKDICCANDIDATES > SKKDICOKURIBLOCK; //送り仮名、候補
typedef std::vector< SKKDICOKURIBLOCK > SKKDICOKURIBLOCKS;
struct OKURIBLOCKS { //avoid C4503
SKKDICOKURIBLOCKS o;
};
typedef std::pair< std::wstring, OKURIBLOCKS > USEROKURIENTRY; //見出し語、送りブロック
typedef std::map< std::wstring, OKURIBLOCKS > USEROKURI;

//見出し語順序
typedef std::vector< std::wstring > KEYORDER;

//辞書
typedef std::pair< std::wstring, SKKDICCANDIDATES > SKKDICENTRY; //見出し語、候補
typedef std::map< std::wstring, SKKDICCANDIDATES > SKKDIC;

extern LPCWSTR EntriesAri;
extern LPCWSTR EntriesNasi;
Expand Down
42 changes: 17 additions & 25 deletions imcrvcnf/PropertyConfDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@
#include "imcrvcnf.h"
#include "resource.h"

//候補 pair< candidate, annotation >
typedef std::pair< std::wstring, std::wstring > CANDIDATE;
typedef std::vector< CANDIDATE > CANDIDATES;

//辞書 pair< key, candidates >
typedef std::map< std::wstring, CANDIDATES > SKKDIC;
typedef std::pair< std::wstring, CANDIDATES > SKKDICENTRY;

//見出し語位置
typedef std::map< std::wstring, long > KEYPOS;
typedef std::map< std::wstring, long > KEYPOS; //見出し語、ファイル位置

struct {
HWND parent;
Expand Down Expand Up @@ -88,7 +80,7 @@ void LoadSKKDicAdd(SKKDIC &skkdic, const std::wstring &key, const std::wstring &
{
SKKDIC::iterator skkdic_itr;
SKKDICENTRY skkdicentry;
CANDIDATES::iterator candidates_itr;
SKKDICCANDIDATES::iterator sc_itr;
LPCWSTR seps = L",";
std::wstring annotation_seps;

Expand All @@ -101,32 +93,32 @@ void LoadSKKDicAdd(SKKDIC &skkdic, const std::wstring &key, const std::wstring &
if(skkdic_itr == skkdic.end())
{
skkdicentry.first = key;
skkdicentry.second.push_back(CANDIDATE(candidate, annotation_seps));
skkdicentry.second.push_back(SKKDICCANDIDATE(candidate, annotation_seps));
skkdic.insert(skkdicentry);
}
else
{
for(candidates_itr = skkdic_itr->second.begin(); candidates_itr != skkdic_itr->second.end(); candidates_itr++)
for(sc_itr = skkdic_itr->second.begin(); sc_itr != skkdic_itr->second.end(); sc_itr++)
{
if(candidates_itr->first == candidate)
if(sc_itr->first == candidate)
{
if(candidates_itr->second.find(annotation_seps) == std::wstring::npos)
if(sc_itr->second.find(annotation_seps) == std::wstring::npos)
{
if(candidates_itr->second.empty())
if(sc_itr->second.empty())
{
candidates_itr->second.append(annotation_seps);
sc_itr->second.append(annotation_seps);
}
else
{
candidates_itr->second.append(annotation + seps);
sc_itr->second.append(annotation + seps);
}
}
break;
}
}
if(candidates_itr == skkdic_itr->second.end())
if(sc_itr == skkdic_itr->second.end())
{
skkdic_itr->second.push_back(CANDIDATE(candidate, annotation_seps));
skkdic_itr->second.push_back(SKKDICCANDIDATE(candidate, annotation_seps));
}
}
}
Expand Down Expand Up @@ -208,18 +200,18 @@ void LoadSKKDic(HWND hwnd, SKKDIC &entries_a, SKKDIC &entries_n)
}
}

void WriteSKKDicEntry(FILE *fp, const std::wstring &key, const CANDIDATES &candidates)
void WriteSKKDicEntry(FILE *fp, const std::wstring &key, const SKKDICCANDIDATES &sc)
{
CANDIDATES::const_iterator candidates_itr;
SKKDICCANDIDATES::const_iterator sc_itr;
std::wstring line;

line = key + L" /";
for(candidates_itr = candidates.begin(); candidates_itr != candidates.end(); candidates_itr++)
for(sc_itr = sc.begin(); sc_itr != sc.end(); sc_itr++)
{
line += candidates_itr->first;
if(candidates_itr->second.size() > 2)
line += sc_itr->first;
if(sc_itr->second.size() > 2)
{
line += L";" + candidates_itr->second.substr(1, candidates_itr->second.size() - 2);
line += L";" + sc_itr->second.substr(1, sc_itr->second.size() - 2);
}
line += L"/";
}
Expand Down
44 changes: 28 additions & 16 deletions imcrvmgr/ConvCharacter.cpp → imcrvmgr/SearchCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,48 @@
#include "eucjis2004.h"
#include "imcrvmgr.h"

void ConvUnicode(const std::wstring &text, CANDIDATES &candidates)
std::wstring SearchUnicode(const std::wstring &searchkey)
{
std::wstring candidate;
//Unicode Code Point
UCSCHAR ucp = 0;
WCHAR utf16[3];

// U+XXXXXX (XXXXXX : 0000-FFFF,10000-10FFFF)
if(std::regex_match(text, std::wregex(L"U\\+([1-9A-F]|10)?[0-9A-F]{4}")))
if(std::regex_match(searchkey, std::wregex(L"U\\+([1-9A-F]|10)?[0-9A-F]{4}")))
{
if(swscanf_s(text.c_str(), L"U+%X", &ucp) != 1)
if(swscanf_s(searchkey.c_str(), L"U+%X", &ucp) != 1)
{
return;
return candidate;
}
}
// uxxxxxx (xxxxxx : 0000-ffff,10000-10ffff)
else if(std::regex_match(text, std::wregex(L"u([1-9a-f]|10)?[0-9a-f]{4}")))
else if(std::regex_match(searchkey, std::wregex(L"u([1-9a-f]|10)?[0-9a-f]{4}")))
{
if(swscanf_s(text.c_str(), L"u%x", &ucp) != 1)
if(swscanf_s(searchkey.c_str(), L"u%x", &ucp) != 1)
{
return;
return candidate;
}
}
else
{
return;
return candidate;
}

ZeroMemory(utf16, sizeof(utf16));
if(UcpToWideChar(ucp, &utf16[0], &utf16[1]) != 0)
{
candidates.push_back(CANDIDATE(utf16, L""));
candidate = L"/";
candidate += utf16;
candidate += L"/\n";
}

return candidate;
}

void ConvJISX0213(const std::wstring &text, CANDIDATES &candidates)
std::wstring SearchJISX0213(const std::wstring &searchkey)
{
std::wstring candidate;
//JIS X 0213 面区点番号
int men, ku, ten;
size_t size;
Expand All @@ -48,14 +54,14 @@ void ConvJISX0213(const std::wstring &text, CANDIDATES &candidates)
UCSCHAR ucp[2];
WCHAR sucp[32];

if(!std::regex_match(text, std::wregex(L"[12]-(0[1-9]|[1-8][0-9]|9[0-4])-(0[1-9]|[0-8][0-9]|9[0-4])")))
if(!std::regex_match(searchkey, std::wregex(L"[12]-(0[1-9]|[1-8][0-9]|9[0-4])-(0[1-9]|[0-8][0-9]|9[0-4])")))
{
return;
return candidate;
}

if(swscanf_s(text.c_str(), L"%d-%d-%d", &men, &ku, &ten) != 3)
if(swscanf_s(searchkey.c_str(), L"%d-%d-%d", &men, &ku, &ten) != 3)
{
return;
return candidate;
}

switch(men)
Expand All @@ -72,7 +78,7 @@ void ConvJISX0213(const std::wstring &text, CANDIDATES &candidates)
euc[3] = L'\0';
break;
default:
return;
return candidate;
break;
}

Expand All @@ -91,6 +97,12 @@ void ConvJISX0213(const std::wstring &text, CANDIDATES &candidates)
size = _countof(utf16);
if(EucJis2004ToWideChar(euc, NULL, utf16, &size))
{
candidates.push_back(CANDIDATE(utf16, sucp));
candidate = L"/";
candidate += utf16;
candidate += L";";
candidate += sucp;
candidate += L"/\n";
}

return candidate;
}
Loading

0 comments on commit f487379

Please sign in to comment.