mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-28 14:32:38 +03:00
73 lines
1.7 KiB
C++
73 lines
1.7 KiB
C++
// $Id$
|
|
|
|
#ifndef moses_ScoreProducer_h
|
|
#define moses_ScoreProducer_h
|
|
|
|
#include <set>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "FeatureVector.h"
|
|
|
|
namespace Moses
|
|
{
|
|
class InputType;
|
|
|
|
/*
|
|
* @note do not confuse this with a producer/consumer pattern.
|
|
* this is not a producer in that sense.
|
|
*/
|
|
class ScoreProducer
|
|
{
|
|
protected:
|
|
std::string m_description;
|
|
bool m_reportSparseFeatures;
|
|
size_t m_numScoreComponents;
|
|
//In case there's multiple producers with the same description
|
|
static std::multiset<std::string> description_counts;
|
|
|
|
ScoreProducer(const ScoreProducer&); // don't implement
|
|
ScoreProducer(const std::string& description, size_t numScoreComponents);
|
|
|
|
public:
|
|
|
|
static const size_t unlimited;
|
|
|
|
static void ResetDescriptionCounts() {
|
|
description_counts.clear();
|
|
}
|
|
|
|
virtual ~ScoreProducer();
|
|
|
|
//! returns the number of scores that a subclass produces.
|
|
//! For example, a language model conventionally produces 1, a translation table some arbitrary number, etc
|
|
//! sparse features returned unlimited
|
|
size_t GetNumScoreComponents() const {return m_numScoreComponents;}
|
|
|
|
//! returns a string description of this producer
|
|
const std::string& GetScoreProducerDescription() const
|
|
{ return m_description; }
|
|
|
|
virtual bool IsStateless() const = 0;
|
|
|
|
void SetSparseFeatureReporting() { m_reportSparseFeatures = true; }
|
|
bool GetSparseFeatureReporting() const { return m_reportSparseFeatures; }
|
|
|
|
virtual float GetSparseProducerWeight() const { return 1; }
|
|
|
|
virtual bool IsTuneable() const { return true; }
|
|
|
|
//!
|
|
virtual void InitializeForInput(InputType const& source)
|
|
{}
|
|
|
|
// clean up temporary memory, called after processing each sentence
|
|
virtual void CleanUpAfterSentenceProcessing(const InputType& source)
|
|
{}
|
|
};
|
|
|
|
|
|
}
|
|
|
|
#endif
|