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-15 12:35:56 +0400
committernicolabertoldi <nicolabertoldi@1f5c12ca-751b-0410-a591-d2e778427230>2008-05-15 12:35:56 +0400
commit2ef6f3e2d86ec160ecec505f69c46a2d08c3ee40 (patch)
tree901c973a91521a934e925fe05a75e5eace80dc0a /mert/ScoreArray.cpp
parent1f84c9eab7189380d5bdb1756905e88b44e72259 (diff)
main command for managing feature and error statistics is ready; small example fortesting is available in directory example
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1692 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'mert/ScoreArray.cpp')
-rw-r--r--mert/ScoreArray.cpp53
1 files changed, 42 insertions, 11 deletions
diff --git a/mert/ScoreArray.cpp b/mert/ScoreArray.cpp
index b6372c6af..4584a0c90 100644
--- a/mert/ScoreArray.cpp
+++ b/mert/ScoreArray.cpp
@@ -19,21 +19,39 @@ void ScoreArray::savetxt(std::ofstream& outFile)
{
ScoreStats entry;
- outFile << SCORES_BEGIN << " " << idx << " " << array_.size() << std::endl;
+ 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_END << std::endl;
+ outFile << SCORES_TXT_END << std::endl;
}
-void ScoreArray::savetxt(const std::string &file)
+void ScoreArray::savebin(std::ofstream& outFile)
{
- TRACE_ERR("saving the array into " << file << std::endl);
+ TRACE_ERR("binary saving is not yet implemented!" << std::endl);
- std::ofstream outFile(file.c_str(), std::ios::out); // matches a stream with a file. Opens the file
+/*
+NOT YET IMPLEMENTED
+*/
+ outFile << SCORES_BIN_BEGIN << " " << idx << " " << array_.size() << std::endl;
+ outFile << SCORES_BIN_END << std::endl;
- ScoreStats entry;
+}
+
+
+void ScoreArray::save(std::ofstream& inFile, bool bin)
+{
+ (bin)?savebin(inFile):savetxt(inFile);
+}
+
+void ScoreArray::save(const std::string &file, 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
- savetxt(outFile);
+ save(outFile);
+
+ outFile.close();
}
void ScoreArray::loadtxt(ifstream& inFile)
@@ -76,20 +94,33 @@ void ScoreArray::loadtxt(ifstream& inFile)
std::getline(inFile, stringBuf);
if (!stringBuf.empty()){
// TRACE_ERR("Reading: " << stringBuf << std::endl);
- if ((loc = stringBuf.find(SCORES_END)) != 0){
+ if ((loc = stringBuf.find(SCORES_TXT_END)) != 0){
TRACE_ERR("ERROR: ScoreArray::loadtxt(): Wrong footer");
return;
}
}
}
-void ScoreArray::loadtxt(const std::string &file)
+void ScoreArray::loadbin(ifstream& inFile)
+{
+ TRACE_ERR("binary saving is not yet implemented!" << std::endl);
+
+/*
+NOT YET IMPLEMENTED
+*/
+}
+
+void ScoreArray::load(ifstream& inFile, bool bin)
+{
+ (bin)?loadbin(inFile):loadtxt(inFile);
+}
+
+void ScoreArray::load(const std::string &file , bool bin)
{
TRACE_ERR("loading data from " << file << std::endl);
std::ifstream inFile(file.c_str(), std::ios::in); // matches a stream with a file. Opens the file
- loadtxt(inFile);
+ load(inFile, bin);
inFile.close();
-
}