|
@@ -198,7 +198,7 @@ int AssignWordsFromTest(std::string pathName, std::vector<tuple< string, string>
|
|
int nPos = csFullPath.ReverseFind(_T('\\'));
|
|
int nPos = csFullPath.ReverseFind(_T('\\'));
|
|
CString filepath = csFullPath.Left(nPos);
|
|
CString filepath = csFullPath.Left(nPos);
|
|
CString FilePath1 = filepath + L"\\config.ini";
|
|
CString FilePath1 = filepath + L"\\config.ini";
|
|
- CString FilePath2 = filepath + L"\\words.txt";
|
|
|
|
|
|
+ //CString FilePath2 = filepath + L"\\words.txt";
|
|
WCHAR wflagWord[10],wFourColScaleParam[10],wThreeColScaleParam[10],wTwoColScaleParam[10];
|
|
WCHAR wflagWord[10],wFourColScaleParam[10],wThreeColScaleParam[10],wTwoColScaleParam[10];
|
|
GetPrivateProfileString(L"USER", L"flagWord", L"1", wflagWord, 10, FilePath1);
|
|
GetPrivateProfileString(L"USER", L"flagWord", L"1", wflagWord, 10, FilePath1);
|
|
GetPrivateProfileString(L"USER", L"TwoColScaleParam", L"6", wTwoColScaleParam, 10, FilePath1);
|
|
GetPrivateProfileString(L"USER", L"TwoColScaleParam", L"6", wTwoColScaleParam, 10, FilePath1);
|
|
@@ -212,100 +212,64 @@ int AssignWordsFromTest(std::string pathName, std::vector<tuple< string, string>
|
|
nTwoColScaleParam = _wtoi(wTwoColScaleParam);
|
|
nTwoColScaleParam = _wtoi(wTwoColScaleParam);
|
|
nTwoColScaleParam = nTwoColScaleParam > 0 ? nTwoColScaleParam : 6;
|
|
nTwoColScaleParam = nTwoColScaleParam > 0 ? nTwoColScaleParam : 6;
|
|
CString lpszflagWord(wflagWord);
|
|
CString lpszflagWord(wflagWord);
|
|
- std::vector<std::string> WordList;
|
|
|
|
- WordList.push_back("vt.");
|
|
|
|
- WordList.push_back("vi.");
|
|
|
|
- WordList.push_back("n.");
|
|
|
|
- WordList.push_back("pron.");
|
|
|
|
- WordList.push_back("adj.");
|
|
|
|
- WordList.push_back("num.");
|
|
|
|
- WordList.push_back("v.");
|
|
|
|
- WordList.push_back("adv.");
|
|
|
|
- WordList.push_back("art.");
|
|
|
|
- WordList.push_back("prep.");
|
|
|
|
- WordList.push_back("conj.");
|
|
|
|
- WordList.push_back("int.");
|
|
|
|
-
|
|
|
|
- // Ëæ»úÌæ»»¹æÔò
|
|
|
|
- std::vector<std::string> rePlaceList;
|
|
|
|
- std::string strFilePath2 = CT2A(FilePath2);
|
|
|
|
- if (_access(strFilePath2.c_str(), 00) != -1)
|
|
|
|
- {
|
|
|
|
- char line[100] = { 0 };
|
|
|
|
- std::ifstream finfile(strFilePath2.c_str(), std::ios::in);
|
|
|
|
- while (finfile.getline(line, sizeof(line)))
|
|
|
|
- {
|
|
|
|
- std::vector<std::string> retlist;
|
|
|
|
- std::string strTemp = line;
|
|
|
|
- UTF8toANSI(strTemp);
|
|
|
|
- split(strTemp, "@", &retlist);
|
|
|
|
- if (retlist.size() == 2)
|
|
|
|
- {
|
|
|
|
- int x = atoi(retlist[1].c_str());
|
|
|
|
- if (x > 0)
|
|
|
|
- {
|
|
|
|
- for (int i = 0; i < x; i++)
|
|
|
|
- {
|
|
|
|
- rePlaceList.push_back(retlist[0]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- memset(line, 0, 100);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+
|
|
int cout = 0;
|
|
int cout = 0;
|
|
if (_access(pathName.c_str(), 00) != -1)
|
|
if (_access(pathName.c_str(), 00) != -1)
|
|
{
|
|
{
|
|
|
|
+ std::string otherPathName;
|
|
|
|
+ otherPathName = pathName;
|
|
|
|
+ size_t lenthOtherName = otherPathName.length();
|
|
|
|
+ otherPathName.replace(lenthOtherName - 4, lenthOtherName, "-other.txt");
|
|
|
|
+ if (_access(otherPathName.c_str(), 00) == -1)
|
|
|
|
+ {
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ int maxOneWith = main_wdith;
|
|
int maxTwoWith = main_wdith / 2 - main_wdith / nTwoColScaleParam - chk_width;
|
|
int maxTwoWith = main_wdith / 2 - main_wdith / nTwoColScaleParam - chk_width;
|
|
int maxTreeWith = main_wdith / 3 - main_wdith / nThreeColScaleParam - chk_width;
|
|
int maxTreeWith = main_wdith / 3 - main_wdith / nThreeColScaleParam - chk_width;
|
|
int maxFourWith = main_wdith / 4 - main_wdith/ nFourColScaleParam - chk_width;
|
|
int maxFourWith = main_wdith / 4 - main_wdith/ nFourColScaleParam - chk_width;
|
|
std::ifstream fin(pathName.c_str(), std::ios::in);
|
|
std::ifstream fin(pathName.c_str(), std::ios::in);
|
|
|
|
+ std::ifstream finOther(otherPathName.c_str(), std::ios::in);
|
|
char line[4096] = { 0 };
|
|
char line[4096] = { 0 };
|
|
|
|
+ char lineOther[4096] = { 0 };
|
|
while (fin.getline(line, sizeof(line)))
|
|
while (fin.getline(line, sizeof(line)))
|
|
{
|
|
{
|
|
- std::string strTemp = line;
|
|
|
|
- UTF8toANSI(strTemp);
|
|
|
|
- if (lpszflagWord == "0")
|
|
|
|
|
|
+ if (!finOther.getline(lineOther, sizeof(lineOther)))
|
|
{
|
|
{
|
|
- ReplaceFlagWord(WordList, strTemp);
|
|
|
|
|
|
+ return -2;
|
|
}
|
|
}
|
|
- if (strTemp == "")
|
|
|
|
|
|
+ std::string strTemp = line,strTempAnother = lineOther;
|
|
|
|
+ UTF8toANSI(strTemp);
|
|
|
|
+ UTF8toANSI(strTempAnother);
|
|
|
|
+ if (strTemp == "" && strTempAnother=="")
|
|
continue;
|
|
continue;
|
|
-
|
|
|
|
- cv::Size WordsWith = GetTextSize(strTemp.c_str(), font_size, font_family);
|
|
|
|
- if (WordsWith.width < maxFourWith)
|
|
|
|
|
|
+ else if (strTemp == "")
|
|
{
|
|
{
|
|
- if (rePlaceList.size() > 0)
|
|
|
|
- {
|
|
|
|
- RandReplaceStr(rePlaceList, strTemp);
|
|
|
|
- }
|
|
|
|
- fourList.push_back(strTemp);
|
|
|
|
|
|
+ return -3;
|
|
}
|
|
}
|
|
- else if (WordsWith.width < maxTreeWith)
|
|
|
|
|
|
+ else if (strTempAnother == "")
|
|
|
|
+ {
|
|
|
|
+ return -4;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cv::Size WordsWith = GetTextSize(strTemp.c_str(), font_size, font_family);
|
|
|
|
+ if (WordsWith.width < maxTwoWith)
|
|
{
|
|
{
|
|
- if (rePlaceList.size() > 0)
|
|
|
|
- {
|
|
|
|
- RandReplaceStr(rePlaceList, strTemp);
|
|
|
|
- }
|
|
|
|
- threeList.push_back(strTemp);
|
|
|
|
|
|
+ auto test2 = make_tuple(strTemp, strTempAnother);
|
|
|
|
+ twoList.push_back(test2);
|
|
}
|
|
}
|
|
- else if (WordsWith.width < maxTwoWith)
|
|
|
|
|
|
+ else if (WordsWith.width < maxOneWith)
|
|
{
|
|
{
|
|
- if (rePlaceList.size() > 0)
|
|
|
|
- {
|
|
|
|
- RandReplaceStr(rePlaceList, strTemp);
|
|
|
|
- }
|
|
|
|
- twoList.push_back(strTemp);
|
|
|
|
|
|
+ auto test2 = make_tuple(strTemp, strTempAnother);
|
|
|
|
+ oneList.push_back(test2);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- char left[2048] = { 0 }, right[2048] = { 0 };
|
|
|
|
- DivideEquallyStr(strTemp.c_str(), strTemp.length(), left,right);
|
|
|
|
- AssignWordsFromString(left, maxTwoWith, maxTreeWith, maxFourWith, rePlaceList, twoList, threeList, fourList);
|
|
|
|
- AssignWordsFromString(right, maxTwoWith, maxTreeWith, maxFourWith, rePlaceList, twoList, threeList, fourList);
|
|
|
|
|
|
+ auto test2 = make_tuple(strTemp, strTempAnother);
|
|
|
|
+ threeList.push_back(test2);
|
|
}
|
|
}
|
|
memset(line, 0, 4096);
|
|
memset(line, 0, 4096);
|
|
|
|
+ memset(lineOther, 0, 4096);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|