mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-10-27 03:49:57 +03:00
Allow hypergraph output to be in plain text, gzip, or bzip2.
The output-search-graph-hypergraph flag now takes two params: * The first param must be "none", "gzip", or "bzip2" * The second param is the hypergraph directory, which must already exist
This commit is contained in:
parent
22c77f7331
commit
28c980d58e
@ -1,4 +1,4 @@
|
||||
alias deps : IOWrapper.cpp mbr.cpp LatticeMBR.cpp TranslationAnalysis.cpp ../moses//moses ;
|
||||
alias deps : IOWrapper.cpp mbr.cpp LatticeMBR.cpp TranslationAnalysis.cpp ..//z ..//boost_iostreams ../moses//moses ;
|
||||
|
||||
exe moses : Main.cpp deps ;
|
||||
exe lmbrgrid : LatticeMBRGrid.cpp deps ;
|
||||
|
@ -23,6 +23,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* Moses main, for single-threaded and multi-threaded.
|
||||
**/
|
||||
|
||||
#include <boost/iostreams/device/file.hpp>
|
||||
#include <boost/iostreams/filter/bzip2.hpp>
|
||||
#include <boost/iostreams/filter/gzip.hpp>
|
||||
#include <boost/iostreams/filtering_stream.hpp>
|
||||
|
||||
#include <exception>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
@ -167,10 +172,18 @@ public:
|
||||
// Output search graph in hypergraph format for Kenneth Heafield's lazy hypergraph decoder
|
||||
if (m_outputSearchGraphHypergraph) {
|
||||
stringstream fileName;
|
||||
fileName << staticData.GetParam("output-search-graph-hypergraph")[0] << "/" << m_lineNumber;
|
||||
std::ofstream *file = new std::ofstream;
|
||||
file->open(fileName.str().c_str());
|
||||
if (file->is_open() && file->good()) {
|
||||
fileName << staticData.GetParam("output-search-graph-hypergraph")[1] << "/" << m_lineNumber;
|
||||
boost::iostreams::filtering_ostream *file = new boost::iostreams::filtering_ostream;
|
||||
// file->open(fileName.str().c_str());
|
||||
string compression = staticData.GetParam("output-search-graph-hypergraph")[0];
|
||||
if ( compression == "gzip" || compression == "gz" ) {
|
||||
file->push( boost::iostreams::gzip_compressor() );
|
||||
} else if ( compression == "bzip2" || compression == "bz2" ) {
|
||||
file->push( boost::iostreams::bzip2_compressor() );
|
||||
}
|
||||
file->push( boost::iostreams::file_sink(fileName.str(), ios_base::out) );
|
||||
// if (file->is_open() && file->good()) {
|
||||
if (file->is_complete() && file->good()) {
|
||||
// ostringstream out;
|
||||
// fix(out,PRECISION);
|
||||
fix(*file,PRECISION);
|
||||
@ -180,7 +193,7 @@ public:
|
||||
} else {
|
||||
TRACE_ERR("Cannot output hypergraph for line " << m_lineNumber << " because the output file is not open or not ready for writing" << std::endl);
|
||||
}
|
||||
file -> close();
|
||||
file -> pop();
|
||||
delete file;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user