📄 configini.cpp
字号:
#include "ConfigINI.h"
using namespace std;
extern bool printmore;
ConfigINI::ConfigINI()
{
}
void ConfigINI::load(string fileName, Para& parameter)
{
string strTmp;
iniFile.open(fileName.c_str(), std::ios::in);
if (!iniFile) {
cout << "Open Configuration file Error!!!" << endl;
return;
}
cout << "reading config from file " << fileName << endl;
while (getline(iniFile, strTmp)) //
{
if(strTmp == "[ttable-file]")
{
getline(iniFile, strTmp);
parameter.ttable_file = strTmp;
}
else if (strTmp == "[lmodel-file]") {
getline(iniFile, strTmp);
parameter.lmodel_file = strTmp;
}
else if (strTmp == "[vocab-file-foreign]") {
getline(iniFile, strTmp);
parameter.cn_vcb = strTmp;
}
else if (strTmp == "[vocab-file-native]") {
getline(iniFile, strTmp);
parameter.en_vcb = strTmp;
}
else if (strTmp == "[ttable-limit]") {
getline(iniFile, strTmp);
parameter.ttable_limit = atoi(strTmp.c_str());
}
else if (strTmp == "[phrase-limit]") {
getline(iniFile, strTmp);
parameter.phrase_limit = atoi(strTmp.c_str());
}
else if (strTmp == "[weight-d]") {
getline(iniFile, strTmp);
parameter.weight_d = atof(strTmp.c_str());
}
else if (strTmp == "[weight-l]") {
getline(iniFile, strTmp);
parameter.weight_l = atof(strTmp.c_str());
}
else if (strTmp == "[weight-t]") {
getline(iniFile, strTmp);
parameter.weight_ef = atof(strTmp.c_str());
getline(iniFile, strTmp);
parameter.weight_lexef = atof(strTmp.c_str());
getline(iniFile, strTmp);
parameter.weight_fe = atof(strTmp.c_str());
getline(iniFile, strTmp);
parameter.weight_lexfe = atof(strTmp.c_str());
getline(iniFile, strTmp);
parameter.penalty = atof(strTmp.c_str());
}
else if (strTmp == "[weight-w]") {
getline(iniFile, strTmp);
parameter.word_penalty = atof(strTmp.c_str());
}
}
iniFile.clear();
iniFile.close();
if(printmore) {
cout << "set ttable-file to " << parameter.ttable_file << endl;
cout << "set lmodel-file to " << parameter.lmodel_file << endl;
cout << "set ttable-limit to " << parameter.ttable_limit << endl;
cout << "set weight-d to " << parameter.weight_d << endl;
cout << "set other parameter" << endl;
}
return ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -