Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieu@hoang.co.uk>2013-05-29 21:16:15 +0400
committerHieu Hoang <hieu@hoang.co.uk>2013-05-29 21:16:15 +0400
commit6249432407af8730c10bccc7894c0725fcaf5e47 (patch)
tree3ac1f094b9fdc199b04bc5ef209ce00e3596e37d /mert/SemposScorer.cpp
parent59bd7deb4b6b9c4f7b3b7dbb055783528fbc31ca (diff)
beautify
Diffstat (limited to 'mert/SemposScorer.cpp')
-rw-r--r--mert/SemposScorer.cpp60
1 files changed, 26 insertions, 34 deletions
diff --git a/mert/SemposScorer.cpp b/mert/SemposScorer.cpp
index 8dd1fc8ee..235f73fbf 100644
--- a/mert/SemposScorer.cpp
+++ b/mert/SemposScorer.cpp
@@ -12,7 +12,7 @@ using namespace std;
namespace MosesTuning
{
-
+
SemposScorer::SemposScorer(const string& config)
: StatisticsBasedScorer("SEMPOS", config),
@@ -25,8 +25,7 @@ SemposScorer::SemposScorer(const string& config)
m_semposMap.clear();
string weightsfile = getConfig("weightsfile", "");
- if (weightsfile != "")
- {
+ if (weightsfile != "") {
loadWeights(weightsfile);
}
}
@@ -144,42 +143,35 @@ int SemposScorer::encodeSempos(const string& sempos)
float SemposScorer::weight(int item) const
{
- std::map<int,float>::const_iterator it = weightsMap.find(item);
- if (it == weightsMap.end())
- {
- return 1.0f;
- }
- else
- {
- return it->second;
- }
+ std::map<int,float>::const_iterator it = weightsMap.find(item);
+ if (it == weightsMap.end()) {
+ return 1.0f;
+ } else {
+ return it->second;
+ }
}
void SemposScorer::loadWeights(const string& weightsfile)
{
- string line;
- ifstream myfile;
- myfile.open(weightsfile.c_str(), ifstream::in);
- if (myfile.is_open())
- {
- while ( myfile.good() )
- {
- getline (myfile,line);
- vector<string> fields;
- if (line == "") continue;
- split(line, '\t', fields);
- if (fields.size() != 2) throw std::runtime_error("Bad format of a row in weights file.");
- int encoded = encodeString(fields[0]);
- float weight = atof(fields[1].c_str());
- weightsMap[encoded] = weight;
- }
- myfile.close();
- }
- else
- {
- cerr << "Unable to open file "<< weightsfile << endl;
- exit(1);
+ string line;
+ ifstream myfile;
+ myfile.open(weightsfile.c_str(), ifstream::in);
+ if (myfile.is_open()) {
+ while ( myfile.good() ) {
+ getline (myfile,line);
+ vector<string> fields;
+ if (line == "") continue;
+ split(line, '\t', fields);
+ if (fields.size() != 2) throw std::runtime_error("Bad format of a row in weights file.");
+ int encoded = encodeString(fields[0]);
+ float weight = atof(fields[1].c_str());
+ weightsMap[encoded] = weight;
}
+ myfile.close();
+ } else {
+ cerr << "Unable to open file "<< weightsfile << endl;
+ exit(1);
+ }
}