2014-12-02 20:10:20 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "OutputFileStream.h"
|
|
|
|
|
|
|
|
#include "Options.h"
|
|
|
|
#include "TokenizedRuleHalf.h"
|
|
|
|
|
2014-12-07 17:27:51 +03:00
|
|
|
namespace MosesTraining
|
|
|
|
{
|
|
|
|
namespace Syntax
|
2014-12-02 20:10:20 +03:00
|
|
|
{
|
|
|
|
namespace ScoreStsg
|
|
|
|
{
|
|
|
|
|
|
|
|
class RuleTableWriter
|
|
|
|
{
|
|
|
|
public:
|
2014-12-07 17:27:51 +03:00
|
|
|
RuleTableWriter(const Options &options, Moses::OutputFileStream &out)
|
2015-01-14 14:07:42 +03:00
|
|
|
: m_options(options)
|
|
|
|
, m_out(out) {}
|
2014-12-02 20:10:20 +03:00
|
|
|
|
|
|
|
void WriteLine(const TokenizedRuleHalf &, const TokenizedRuleHalf &,
|
2014-12-30 21:57:23 +03:00
|
|
|
const std::string &, double, double, int, int, int);
|
2014-12-02 20:10:20 +03:00
|
|
|
|
|
|
|
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;
|
2014-12-07 17:27:51 +03:00
|
|
|
Moses::OutputFileStream &m_out;
|
2014-12-02 20:10:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ScoreStsg
|
2014-12-07 17:27:51 +03:00
|
|
|
} // namespace Syntax
|
|
|
|
} // namespace MosesTraining
|