mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-06 19:49:41 +03:00
80 lines
1.8 KiB
C++
80 lines
1.8 KiB
C++
/*
|
|
* FeatureFunction.h
|
|
*
|
|
* Created on: 23 Oct 2015
|
|
* Author: hieu
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <string>
|
|
#include <vector>
|
|
#include "../TypeDef.h"
|
|
|
|
namespace Moses2
|
|
{
|
|
|
|
class System;
|
|
class Phrase;
|
|
class PhraseImpl;
|
|
class TargetPhrase;
|
|
class TargetPhrases;
|
|
class Scores;
|
|
class Manager;
|
|
class MemPool;
|
|
|
|
class FeatureFunction {
|
|
public:
|
|
|
|
FeatureFunction(size_t startInd, const std::string &line);
|
|
virtual ~FeatureFunction();
|
|
virtual void Load(System &system)
|
|
{}
|
|
|
|
size_t GetStartInd() const
|
|
{ return m_startInd; }
|
|
size_t GetNumScores() const
|
|
{ return m_numScores; }
|
|
const std::string &GetName() const
|
|
{ return m_name; }
|
|
|
|
virtual size_t HasPhraseTableInd() const
|
|
{ return false; }
|
|
void SetPhraseTableInd(size_t ind)
|
|
{ m_PhraseTableInd = ind; }
|
|
|
|
// may have more factors than actually need, but not guaranteed.
|
|
// For SCFG decoding, the source contains non-terminals, NOT the raw
|
|
// source from the input sentence
|
|
virtual void
|
|
EvaluateInIsolation(MemPool &pool, const System &system,
|
|
const Phrase &source, const TargetPhrase &targetPhrase,
|
|
Scores &scores,
|
|
SCORE *estimatedScore) const = 0;
|
|
|
|
virtual void
|
|
EvaluateAfterTablePruning(MemPool &pool, const TargetPhrases &tps, const Phrase &sourcePhrase) const
|
|
{}
|
|
|
|
virtual void InitializeForInput(const Manager &mgr) const { };
|
|
|
|
// clean up temporary memory, called after processing each sentence
|
|
virtual void CleanUpAfterSentenceProcessing(const Manager &mgr) const {}
|
|
|
|
protected:
|
|
size_t m_startInd;
|
|
size_t m_numScores;
|
|
size_t m_PhraseTableInd;
|
|
std::string m_name;
|
|
std::vector<std::vector<std::string> > m_args;
|
|
bool m_tuneable;
|
|
|
|
virtual void SetParameter(const std::string& key, const std::string& value);
|
|
virtual void ReadParameters();
|
|
void ParseLine(const std::string &line);
|
|
};
|
|
|
|
}
|
|
|