mosesdecoder/phrase-extract/score-stsg/RuleTableWriter.h
2015-01-14 11:07:42 +00:00

45 lines
843 B
C++

#pragma once
#include <cmath>
#include <string>
#include "OutputFileStream.h"
#include "Options.h"
#include "TokenizedRuleHalf.h"
namespace MosesTraining
{
namespace Syntax
{
namespace ScoreStsg
{
class RuleTableWriter
{
public:
RuleTableWriter(const Options &options, Moses::OutputFileStream &out)
: m_options(options)
, m_out(out) {}
void WriteLine(const TokenizedRuleHalf &, const TokenizedRuleHalf &,
const std::string &, double, double, int, int, int);
private:
double MaybeLog(double a) const {
if (!m_options.logProb) {
return a;
}
return m_options.negLogProb ? -log(a) : log(a);
}
void WriteRuleHalf(const TokenizedRuleHalf &);
const Options &m_options;
Moses::OutputFileStream &m_out;
};
} // namespace ScoreStsg
} // namespace Syntax
} // namespace MosesTraining