2015-10-27 19:54:15 +03:00
|
|
|
/*
|
|
|
|
* FeatureFunctions.h
|
|
|
|
*
|
|
|
|
* Created on: 27 Oct 2015
|
|
|
|
* Author: hieu
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FEATUREFUNCTIONS_H_
|
|
|
|
#define FEATUREFUNCTIONS_H_
|
|
|
|
|
|
|
|
#include <vector>
|
2015-10-27 20:35:42 +03:00
|
|
|
#include <string>
|
2015-11-13 13:40:55 +03:00
|
|
|
#include "../legacy/Parameter.h"
|
2015-10-27 19:54:15 +03:00
|
|
|
|
2015-12-10 23:49:30 +03:00
|
|
|
namespace Moses2
|
|
|
|
{
|
|
|
|
|
2015-10-27 19:54:15 +03:00
|
|
|
class System;
|
|
|
|
class FeatureFunction;
|
|
|
|
class StatefulFeatureFunction;
|
|
|
|
class PhraseTable;
|
2015-10-29 03:47:06 +03:00
|
|
|
class Manager;
|
2015-11-02 17:06:03 +03:00
|
|
|
class MemPool;
|
2015-10-29 03:47:06 +03:00
|
|
|
class Phrase;
|
2015-11-03 17:20:10 +03:00
|
|
|
class PhraseImpl;
|
2015-10-29 03:47:06 +03:00
|
|
|
class TargetPhrase;
|
2015-12-20 19:21:34 +03:00
|
|
|
class TargetPhrases;
|
2015-10-29 03:47:06 +03:00
|
|
|
class Scores;
|
2015-10-27 19:54:15 +03:00
|
|
|
|
|
|
|
class FeatureFunctions {
|
|
|
|
public:
|
2016-01-21 14:22:55 +03:00
|
|
|
std::vector<const PhraseTable*> m_phraseTables;
|
2015-11-18 14:47:50 +03:00
|
|
|
|
|
|
|
FeatureFunctions(System &system);
|
2015-10-27 19:54:15 +03:00
|
|
|
virtual ~FeatureFunctions();
|
|
|
|
|
2015-12-16 19:53:00 +03:00
|
|
|
const std::vector<const FeatureFunction*> &GetFeatureFunctions() const
|
|
|
|
{ return m_featureFunctions; }
|
|
|
|
|
2015-10-27 19:54:15 +03:00
|
|
|
const std::vector<const StatefulFeatureFunction*> &GetStatefulFeatureFunctions() const
|
|
|
|
{ return m_statefulFeatureFunctions; }
|
|
|
|
|
2015-12-17 20:08:49 +03:00
|
|
|
const std::vector<const FeatureFunction*> &GetWithPhraseTableInd() const
|
|
|
|
{ return m_withPhraseTableInd; }
|
|
|
|
|
2015-10-27 20:00:38 +03:00
|
|
|
size_t GetNumScores() const
|
2015-10-27 19:54:15 +03:00
|
|
|
{ return m_ffStartInd; }
|
|
|
|
|
2015-10-29 21:15:12 +03:00
|
|
|
void Create();
|
|
|
|
void Load();
|
2015-10-27 19:54:15 +03:00
|
|
|
|
2015-12-07 21:16:51 +03:00
|
|
|
const FeatureFunction *FindFeatureFunction(const std::string &name) const;
|
2015-10-31 05:45:01 +03:00
|
|
|
const PhraseTable *GetPhraseTablesExcludeUnknownWordPenalty(size_t ptInd);
|
2015-10-27 20:35:42 +03:00
|
|
|
|
2015-12-17 21:01:00 +03:00
|
|
|
// the pool here must be the system pool if the rule was loaded during load, or the mgr if it was loaded on demand
|
2015-12-20 19:21:34 +03:00
|
|
|
void EvaluateInIsolation(MemPool &pool, const System &system,
|
2015-11-03 17:20:10 +03:00
|
|
|
const Phrase &source, TargetPhrase &targetPhrase) const;
|
2015-12-20 20:03:16 +03:00
|
|
|
void EvaluateAfterTablePruning(MemPool &pool, const TargetPhrases &tps, const Phrase &sourcePhrase) const;
|
2015-10-29 03:47:06 +03:00
|
|
|
|
2015-10-27 19:54:15 +03:00
|
|
|
protected:
|
|
|
|
std::vector<const FeatureFunction*> m_featureFunctions;
|
|
|
|
std::vector<const StatefulFeatureFunction*> m_statefulFeatureFunctions;
|
2015-12-17 20:08:49 +03:00
|
|
|
std::vector<const FeatureFunction*> m_withPhraseTableInd;
|
2015-10-27 19:54:15 +03:00
|
|
|
|
|
|
|
System &m_system;
|
|
|
|
size_t m_ffStartInd;
|
|
|
|
|
|
|
|
FeatureFunction *Create(const std::string &line);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-12-10 23:49:30 +03:00
|
|
|
}
|
|
|
|
|
2015-10-27 19:54:15 +03:00
|
|
|
#endif /* FEATUREFUNCTIONS_H_ */
|