mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
small changes
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1641 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
parent
40c93618fc
commit
36b25323c9
@ -27,8 +27,6 @@ void FeatureArray::savetxt(std::ofstream& outFile)
|
||||
|
||||
void FeatureArray::savebin(std::ofstream& outFile)
|
||||
{
|
||||
FeatureStats entry;
|
||||
|
||||
TRACE_ERR("binary saving is not yet implemented!" << std::endl);
|
||||
|
||||
/*
|
||||
@ -39,15 +37,21 @@ NOT YET IMPLEMENTED
|
||||
|
||||
}
|
||||
|
||||
void FeatureArray::savetxt(const std::string &file)
|
||||
|
||||
void FeatureArray::save(std::ofstream& inFile, bool bin)
|
||||
{
|
||||
(bin)?savebin(inFile):savetxt(inFile);
|
||||
}
|
||||
|
||||
void FeatureArray::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
|
||||
|
||||
FeatureStats entry;
|
||||
save(outFile);
|
||||
|
||||
savetxt(outFile);
|
||||
outFile.close();
|
||||
}
|
||||
|
||||
void FeatureArray::loadtxt(ifstream& inFile)
|
||||
@ -71,7 +75,11 @@ void FeatureArray::loadtxt(ifstream& inFile)
|
||||
|
||||
if (!stringBuf.empty()){
|
||||
// TRACE_ERR("Reading: " << stringBuf << std::endl);
|
||||
nextPound = getNextPound(stringBuf, substring);
|
||||
if ((loc = stringBuf.find(FEATURES_TXT_BEGIN)) != 0){
|
||||
TRACE_ERR("ERROR: FeatureArray::loadtxt(): Wrong header");
|
||||
return;
|
||||
}
|
||||
nextPound = getNextPound(stringBuf, substring);
|
||||
nextPound = getNextPound(stringBuf, substring);
|
||||
idx = atoi(substring.c_str());
|
||||
nextPound = getNextPound(stringBuf, substring);
|
||||
@ -90,20 +98,35 @@ void FeatureArray::loadtxt(ifstream& inFile)
|
||||
std::getline(inFile, stringBuf);
|
||||
if (!stringBuf.empty()){
|
||||
// TRACE_ERR("Reading: " << stringBuf << std::endl);
|
||||
if ((loc = stringBuf.find(FEATURES_END)) != 0){
|
||||
if ((loc = stringBuf.find(FEATURES_TXT_END)) != 0){
|
||||
TRACE_ERR("ERROR: FeatureArray::loadtxt(): Wrong footer");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FeatureArray::loadtxt(const std::string &file)
|
||||
void FeatureArray::loadbin(ifstream& inFile)
|
||||
{
|
||||
TRACE_ERR("binary saving is not yet implemented!" << std::endl);
|
||||
|
||||
/*
|
||||
NOT YET IMPLEMENTED
|
||||
*/
|
||||
}
|
||||
|
||||
void FeatureArray::load(ifstream& inFile, bool bin)
|
||||
{
|
||||
(bin)?loadbin(inFile):loadtxt(inFile);
|
||||
}
|
||||
|
||||
void FeatureArray::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();
|
||||
|
||||
}
|
||||
|
@ -53,12 +53,16 @@ public:
|
||||
inline size_t memsize(){ return bufLen_; }
|
||||
|
||||
|
||||
void savetxt(const std::string &file);
|
||||
void savetxt(ofstream& outFile);
|
||||
inline void savetxt(){ savetxt("/dev/stdout"); }
|
||||
void savebin(ofstream& outFile);
|
||||
void save(ofstream& outFile, bool bin=false);
|
||||
void save(const std::string &file, bool bin=false);
|
||||
inline void save(bool bin=false){ save("/dev/stdout",bin); }
|
||||
|
||||
void loadtxt(ifstream& inFile);
|
||||
void loadtxt(const std::string &file);
|
||||
void loadbin(ifstream& inFile);
|
||||
void load(ifstream& inFile, bool bin=false);
|
||||
void load(const std::string &file, bool bin=false);
|
||||
|
||||
};
|
||||
|
||||
|
@ -19,7 +19,7 @@ void FeatureData::savetxt(std::ofstream& outFile)
|
||||
{
|
||||
FeatureArray entry;
|
||||
for (vector<FeatureArray>::iterator i = array_.begin(); i !=array_.end(); i++)
|
||||
(*i).savetxt(outFile);
|
||||
(*i).save(outFile);
|
||||
}
|
||||
|
||||
void FeatureData::savetxt(const std::string &file)
|
||||
@ -28,9 +28,9 @@ void FeatureData::savetxt(const std::string &file)
|
||||
|
||||
std::ofstream outFile(file.c_str(), std::ios::out); // matches a stream with a file. Opens the file
|
||||
|
||||
FeatureStats entry;
|
||||
|
||||
savetxt(outFile);
|
||||
|
||||
outFile.close();
|
||||
}
|
||||
|
||||
void FeatureData::loadtxt(ifstream& inFile)
|
||||
@ -42,13 +42,13 @@ void FeatureData::loadtxt(ifstream& inFile)
|
||||
TRACE_ERR("iter " << iter << " size " << size() << std::endl);
|
||||
|
||||
entry.clear();
|
||||
entry.loadtxt(inFile);
|
||||
entry.load(inFile);
|
||||
|
||||
if (entry.size() == 0){
|
||||
TRACE_ERR("no more data" << std::endl);
|
||||
continue;
|
||||
}
|
||||
entry.savetxt();
|
||||
entry.save();
|
||||
|
||||
add(entry);
|
||||
|
||||
@ -103,7 +103,7 @@ void FeatureData::loadnbest(const std::string &file)
|
||||
entry.add(ATOFST(subsubstring.c_str()));
|
||||
}
|
||||
}
|
||||
// entry.savetxt();
|
||||
// entry.save();
|
||||
add(entry,sentence_index);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user