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:
authornicolabertoldi <nicolabertoldi@1f5c12ca-751b-0410-a591-d2e778427230>2008-05-27 20:50:52 +0400
committernicolabertoldi <nicolabertoldi@1f5c12ca-751b-0410-a591-d2e778427230>2008-05-27 20:50:52 +0400
commit291260abf74ed3fe0c9218465cff6e658d0a1b23 (patch)
tree474b29cf0ba2b37c5ed41b4c805a85121362a3a7 /mert/ScoreArray.cpp
parent89194be5ebb641072795d9e949312002ac6262e6 (diff)
- made output more compliant with old version
- added PerSCorer.h and BleuScorer.h - stored feature names - fixed bug about output of best Point git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1796 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'mert/ScoreArray.cpp')
-rw-r--r--mert/ScoreArray.cpp70
1 files changed, 47 insertions, 23 deletions
diff --git a/mert/ScoreArray.cpp b/mert/ScoreArray.cpp
index 2eb5361e4..067b02592 100644
--- a/mert/ScoreArray.cpp
+++ b/mert/ScoreArray.cpp
@@ -10,59 +10,57 @@
#include "ScoreArray.h"
#include "Util.h"
-
-ScoreArray::ScoreArray(): idx(0)
+ScoreArray::ScoreArray(): idx("")
{};
-void ScoreArray::savetxt(std::ofstream& outFile)
+void ScoreArray::savetxt(std::ofstream& outFile, const std::string& sctype)
{
- ScoreStats entry;
-
- outFile << SCORES_TXT_BEGIN << " " << idx << " " << array_.size() << std::endl;
- for (vector<ScoreStats>::iterator i = array_.begin(); i !=array_.end(); i++)
- (*i).savetxt(outFile);
+ outFile << SCORES_TXT_BEGIN << " " << sctype << " " << idx << " " << array_.size() << std::endl;
+ for (scorearray_t::iterator i = array_.begin(); i !=array_.end(); i++){
+ i->savetxt(outFile);
+ outFile << std::endl;
+ }
outFile << SCORES_TXT_END << std::endl;
}
-void ScoreArray::savebin(std::ofstream& outFile)
+void ScoreArray::savebin(std::ofstream& outFile, const std::string& sctype)
{
TRACE_ERR("binary saving is not yet implemented!" << std::endl);
/*
NOT YET IMPLEMENTED
*/
- outFile << SCORES_BIN_BEGIN << " " << idx << " " << array_.size() << std::endl;
+ outFile << SCORES_BIN_BEGIN << " " << sctype << " " << idx << " " << array_.size() << std::endl;
outFile << SCORES_BIN_END << std::endl;
}
-void ScoreArray::save(std::ofstream& inFile, bool bin)
+void ScoreArray::save(std::ofstream& inFile, const std::string& sctype, bool bin)
{
- (bin)?savebin(inFile):savetxt(inFile);
+ (bin)?savebin(inFile, sctype):savetxt(inFile, sctype);
}
-void ScoreArray::save(const std::string &file, bool bin)
+void ScoreArray::save(const std::string &file, const std::string& sctype, bool bin)
{
TRACE_ERR("saving the array into " << file << std::endl);
std::ofstream outFile(file.c_str(), std::ios::out); // matches a stream with a file. Opens the file
- save(outFile);
+ save(outFile, sctype, bin);
outFile.close();
}
void ScoreArray::loadtxt(ifstream& inFile)
{
- ScoreStats entry;
+ ScoreStats entry;
- int sentence_index;
- int number_of_entries;
+ int number_of_entries=0;
int nextPound;
- std::string substring, stringBuf, sentence_code = "";
- std::string::size_type loc;
+ std::string substring, stringBuf, sentence_code = "";
+ std::string::size_type loc;
TRACE_ERR("starting loadtxt..." << std::endl);
@@ -75,16 +73,19 @@ void ScoreArray::loadtxt(ifstream& inFile)
// TRACE_ERR("Reading: " << stringBuf << std::endl);
nextPound = getNextPound(stringBuf, substring);
nextPound = getNextPound(stringBuf, substring);
- idx = atoi(substring.c_str());
+ score_type = substring;
+ nextPound = getNextPound(stringBuf, substring);
+ idx = substring;
nextPound = getNextPound(stringBuf, substring);
- number_of_entries = atoi(substring.c_str());
+ number_of_entries = atoi(substring.c_str());
// TRACE_ERR("idx: " << idx " nbest: " << number_of_entries << std::endl);
+ /*PUT HERE A CONSISTENCY CHECK ABOUT THE FORMAT OF THE FILE*/
}
for (int i=0 ; i < number_of_entries; i++)
{
- entry.clear();
- std::getline(inFile, stringBuf);
+ entry.clear();
+ std::getline(inFile, stringBuf);
entry.set(stringBuf);
add(entry);
}
@@ -123,3 +124,26 @@ void ScoreArray::load(const std::string &file , bool bin)
inFile.close();
}
+
+
+void ScoreArray::merge(ScoreArray& e)
+{
+ //dummy implementation
+ for (size_t i=0; i<e.size(); i++)
+ add(e.get(i));
+}
+
+bool ScoreArray::check_consistency()
+{
+ size_t sz = NumberOfScores();
+
+ if (sz == 0)
+ return true;
+
+ for (scorearray_t::iterator i=array_.begin(); i!=array_.end(); i++)
+ if (i->size()!=sz)
+ return false;
+ return true;
+}
+
+