Skip to content

Commit 122d4cc

Browse files
committed
improve hidden features 2
1 parent 2196db3 commit 122d4cc

File tree

5 files changed

+152
-38
lines changed

5 files changed

+152
-38
lines changed

XG_PatEditDialog.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class XG_PatEditDialog : public XG_Dialog
1313
TYPE_DELETE,
1414
TYPE_SHOWINFO
1515
};
16-
static inline TYPE s_nType = TYPE_ADD;
16+
static inline TYPE s_nType = TYPE_SHOWINFO;
1717
static inline HBITMAP s_hbm = NULL;
1818

1919
XG_PatEditDialog() noexcept

XWordGiver.cpp

+124-37
Original file line numberDiff line numberDiff line change
@@ -7960,43 +7960,8 @@ bool __fastcall XgIsAnyThreadTerminated(void) noexcept
79607960
// パターンの統計情報を表示。
79617961
void XgShowPatInfo(HWND hwndInfo)
79627962
{
7963-
std::wstring text;
7964-
7965-
// 使用文字の頻度分布。
7966-
{
7967-
std::map<WCHAR, DWORD> ch2num;
7968-
{
7969-
const XG_Board *xw = (xg_bSolved ? &xg_solution : &xg_xword);
7970-
for (int i = 0; i < xg_nRows; i++) {
7971-
for (int j = 0; j < xg_nCols; j++) {
7972-
auto ch = xw->GetAt(i, j);
7973-
ch2num[ch] += 1;
7974-
}
7975-
}
7976-
}
7977-
std::vector<std::pair<DWORD, DWORD>> pairs;
7978-
for (auto& pair : ch2num) {
7979-
pairs.push_back(pair);
7980-
}
7981-
std::sort(pairs.begin(), pairs.end(), [](auto& a, auto& b){
7982-
return a.second > b.second;
7983-
});
7984-
text += L"\r\n";
7985-
text += L"[[ ";
7986-
text += XgLoadStringDx1(IDS_CHARUSAGEDIST);
7987-
text += L" ]]";
7988-
text += L"\r\n";
7989-
for (auto& pair : pairs) {
7990-
text += (WCHAR)0x3010; //
7991-
text += pair.first;
7992-
text += (WCHAR)0x3011; //
7993-
text += L" : ";
7994-
text += std::to_wstring(pair.second);
7995-
text += L"\r\n";
7996-
}
7997-
}
7963+
std::wstring text; // この関数では、この変数にテキストを追加していく。
79987964

7999-
// 単語の長さの頻度分布。
80007965
if (xg_bSolved) {
80017966
std::map<WCHAR, DWORD> len2num;
80027967
std::vector<XG_WordData> dict = XgCreateMiniDict();
@@ -8010,6 +7975,14 @@ void XgShowPatInfo(HWND hwndInfo)
80107975
std::sort(pairs.begin(), pairs.end(), [](auto& a, auto& b){
80117976
return a.second > b.second;
80127977
});
7978+
// 使用単語数。
7979+
text += L"\r\n";
7980+
text += L"[[ ";
7981+
text += XgLoadStringDx1(IDS_WORDCOUNT);
7982+
text += L" ]] : ";
7983+
text += std::to_wstring(dict.size());
7984+
text += L"\r\n";
7985+
// 単語の長さの頻度分布。
80137986
text += L"\r\n";
80147987
text += L"[[ ";
80157988
text += XgLoadStringDx1(IDS_WORDLENDIST);
@@ -8057,7 +8030,113 @@ void XgShowPatInfo(HWND hwndInfo)
80578030
text += L"\r\n";
80588031
}
80598032

8060-
// パターンの頻度分布。
8033+
{
8034+
size_t count = xg_dict_1.size();
8035+
size_t sum = 0, min = 999999, max = 0;
8036+
for (auto& data : xg_dict_1) {
8037+
auto len = data.m_word.size();
8038+
if (min > len)
8039+
min = len;
8040+
if (max < len)
8041+
max = len;
8042+
sum += data.m_word.size();
8043+
}
8044+
// 辞書中の単語の個数。
8045+
text += L"\r\n";
8046+
text += L"[[ ";
8047+
text += XgLoadStringDx1(IDS_DICTWORDCOUNT);
8048+
text += L" ]]";
8049+
text += L" : ";
8050+
text += std::to_wstring(count);
8051+
// 辞書中の単語の長さ。
8052+
text += L"\r\n";
8053+
text += L"[[ ";
8054+
text += XgLoadStringDx1(IDS_DICTWORDLENAVG); // 平均値。
8055+
text += L" ]]";
8056+
text += L" : ";
8057+
text += std::to_wstring(sum / (double)count);
8058+
text += L"\r\n";
8059+
text += L"[[ ";
8060+
text += XgLoadStringDx1(IDS_DICTWORDLENMIN); // 最小値。
8061+
text += L" ]]";
8062+
text += L" : ";
8063+
text += std::to_wstring(min);
8064+
text += L"\r\n";
8065+
text += L"[[ ";
8066+
text += XgLoadStringDx1(IDS_DICTWORDLENMAX); // 最大値。
8067+
text += L" ]]";
8068+
text += L" : ";
8069+
text += std::to_wstring(max);
8070+
text += L"\r\n";
8071+
}
8072+
8073+
// 辞書中のヒントの長さ。
8074+
{
8075+
size_t count = xg_dict_1.size();
8076+
size_t sum = 0, min = 999999, max = 0;
8077+
for (auto& data : xg_dict_1) {
8078+
auto len = data.m_hint.size();
8079+
if (min > len)
8080+
min = len;
8081+
if (max < len)
8082+
max = len;
8083+
sum += data.m_hint.size();
8084+
}
8085+
text += L"\r\n";
8086+
text += L"[[ ";
8087+
text += XgLoadStringDx1(IDS_DICTHINTLENAVG); // 平均値。
8088+
text += L" ]]";
8089+
text += L" : ";
8090+
text += std::to_wstring(sum / (double)count);
8091+
text += L"\r\n";
8092+
text += L"[[ ";
8093+
text += XgLoadStringDx1(IDS_DICTHINTLENMIN); // 最小値。
8094+
text += L" ]]";
8095+
text += L" : ";
8096+
text += std::to_wstring(min);
8097+
text += L"\r\n";
8098+
text += L"[[ ";
8099+
text += XgLoadStringDx1(IDS_DICTHINTLENMAX); // 最大値。
8100+
text += L" ]]";
8101+
text += L" : ";
8102+
text += std::to_wstring(max);
8103+
text += L"\r\n";
8104+
}
8105+
8106+
// 使用文字の頻度分布。
8107+
{
8108+
std::map<WCHAR, DWORD> ch2num;
8109+
{
8110+
const XG_Board *xw = (xg_bSolved ? &xg_solution : &xg_xword);
8111+
for (int i = 0; i < xg_nRows; i++) {
8112+
for (int j = 0; j < xg_nCols; j++) {
8113+
auto ch = xw->GetAt(i, j);
8114+
ch2num[ch] += 1;
8115+
}
8116+
}
8117+
}
8118+
std::vector<std::pair<DWORD, DWORD>> pairs;
8119+
for (auto& pair : ch2num) {
8120+
pairs.push_back(pair);
8121+
}
8122+
std::sort(pairs.begin(), pairs.end(), [](auto& a, auto& b){
8123+
return a.second > b.second;
8124+
});
8125+
text += L"\r\n";
8126+
text += L"[[ ";
8127+
text += XgLoadStringDx1(IDS_CHARUSAGEDIST);
8128+
text += L" ]]";
8129+
text += L"\r\n";
8130+
for (auto& pair : pairs) {
8131+
text += (WCHAR)0x3010; //
8132+
text += pair.first;
8133+
text += (WCHAR)0x3011; //
8134+
text += L" : ";
8135+
text += std::to_wstring(pair.second);
8136+
text += L"\r\n";
8137+
}
8138+
}
8139+
80618140
{
80628141
// パターンを読み込む。
80638142
patterns_t patterns;
@@ -8075,6 +8154,14 @@ void XgShowPatInfo(HWND hwndInfo)
80758154
for (const auto& pat : patterns) {
80768155
size2num[MAKELONG(pat.num_rows, pat.num_columns)] += 1;
80778156
}
8157+
// パターンの個数。
8158+
text += L"\r\n";
8159+
text += L"[[ ";
8160+
text += XgLoadStringDx1(IDS_PATCOUNT);
8161+
text += L" ]] : ";
8162+
text += std::to_wstring(patterns.size());
8163+
text += L"\r\n";
8164+
// パターンの頻度分布。
80788165
text += L"\r\n";
80798166
text += L"[[ ";
80808167
text += XgLoadStringDx1(IDS_PATSIZEDIST);

lang/en_US.rc

+9
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,15 @@ STRINGTABLE
17551755
IDS_HINTLENAVG, "Clue length average"
17561756
IDS_HINTLENMIN, "Clue length min."
17571757
IDS_HINTLENMAX, "Clue length max."
1758+
IDS_DICTWORDLENAVG, "Word length Average in the dictionary"
1759+
IDS_DICTWORDLENMIN, "Word length min. in the dictionary"
1760+
IDS_DICTWORDLENMAX, "Word length max. in the dictionary"
1761+
IDS_DICTHINTLENAVG, "Clue length Average in the dictionary"
1762+
IDS_DICTHINTLENMIN, "Clue length min. in the dictionary"
1763+
IDS_DICTHINTLENMAX, "Clue length max. in the dictionary"
1764+
IDS_WORDCOUNT, "Word usage count"
1765+
IDS_PATCOUNT, "The # of patters in PAT.txt"
1766+
IDS_DICTWORDCOUNT, "The # of words in the dictionary"
17581767
IDS_TT_NEW, "New crossword"
17591768
IDS_TT_GENERATE, "Generate crossword"
17601769
IDS_TT_OPEN, "Open crossword"

lang/ja_JP.rc

+9
Original file line numberDiff line numberDiff line change
@@ -1758,6 +1758,15 @@ STRINGTABLE
17581758
IDS_HINTLENAVG, "ヒントの長さの平均値"
17591759
IDS_HINTLENMIN, "ヒントの長さの最小値"
17601760
IDS_HINTLENMAX, "ヒントの長さの最大値"
1761+
IDS_DICTWORDLENAVG, "辞書中の単語長の平均値"
1762+
IDS_DICTWORDLENMIN, "辞書中の単語長の最小値"
1763+
IDS_DICTWORDLENMAX, "辞書中の単語長の最大値"
1764+
IDS_DICTHINTLENAVG, "辞書中のヒント長の平均値"
1765+
IDS_DICTHINTLENMIN, "辞書中のヒント長の最小値"
1766+
IDS_DICTHINTLENMAX, "辞書中のヒント長の最大値"
1767+
IDS_WORDCOUNT, "使用単語数"
1768+
IDS_PATCOUNT, "PAT.txt中のパターンの個数"
1769+
IDS_DICTWORDCOUNT, "辞書中の単語の個数"
17611770
IDS_TT_NEW, "新規作成"
17621771
IDS_TT_GENERATE, "問題を自動生成する"
17631772
IDS_TT_OPEN, "問題を開く"

resource.h

+9
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,15 @@
234234
#define IDS_HINTLENAVG 314
235235
#define IDS_HINTLENMIN 315
236236
#define IDS_HINTLENMAX 316
237+
#define IDS_DICTWORDLENAVG 317
238+
#define IDS_DICTWORDLENMIN 318
239+
#define IDS_DICTWORDLENMAX 319
240+
#define IDS_DICTHINTLENAVG 320
241+
#define IDS_DICTHINTLENMIN 321
242+
#define IDS_DICTHINTLENMAX 322
243+
#define IDS_WORDCOUNT 323
244+
#define IDS_PATCOUNT 324
245+
#define IDS_DICTWORDCOUNT 325
237246
#define IDS_TT_NEW 10100
238247
#define IDS_TT_GENERATE 10101
239248
#define IDS_TT_OPEN 10102

0 commit comments

Comments
 (0)