2008-06-11 14:52:57 +04:00
|
|
|
// $Id$
|
|
|
|
|
2010-02-24 14:15:44 +03:00
|
|
|
#ifndef moses_ScoreProducer_h
|
|
|
|
#define moses_ScoreProducer_h
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2010-10-11 18:09:39 +04:00
|
|
|
#include <set>
|
2008-06-11 14:52:57 +04:00
|
|
|
#include <string>
|
2010-10-07 02:06:49 +04:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "FeatureVector.h"
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2010-10-07 02:06:49 +04:00
|
|
|
/*
|
2008-06-11 14:52:57 +04:00
|
|
|
* @note do not confuse this with a producer/consumer pattern.
|
|
|
|
* this is not a producer in that sense.
|
|
|
|
*/
|
|
|
|
class ScoreProducer
|
|
|
|
{
|
|
|
|
private:
|
2010-10-11 18:09:39 +04:00
|
|
|
std::string m_description;
|
2011-08-07 04:58:56 +04:00
|
|
|
bool m_reportSparseFeatures;
|
2011-11-09 01:22:34 +04:00
|
|
|
size_t m_numScoreComponents;
|
2010-10-11 18:09:39 +04:00
|
|
|
//In case there's multiple producers with the same description
|
|
|
|
static std::multiset<std::string> description_counts;
|
2008-06-11 14:52:57 +04:00
|
|
|
ScoreProducer(const ScoreProducer&); // don't implement
|
|
|
|
|
|
|
|
protected:
|
2011-11-09 01:22:34 +04:00
|
|
|
ScoreProducer(const std::string& description, size_t numScoreComponents);
|
2008-06-11 14:52:57 +04:00
|
|
|
virtual ~ScoreProducer();
|
|
|
|
|
|
|
|
public:
|
2010-10-15 01:52:35 +04:00
|
|
|
|
|
|
|
static const size_t unlimited;
|
|
|
|
|
2012-04-29 08:37:48 +04:00
|
|
|
static void ResetDescriptionCounts() {
|
|
|
|
description_counts.clear();
|
|
|
|
}
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
//! returns the number of scores that a subclass produces.
|
|
|
|
//! For example, a language model conventionally produces 1, a translation table some arbitrary number, etc
|
2010-10-15 01:52:35 +04:00
|
|
|
//! sparse features returned unlimited
|
2011-11-09 01:22:34 +04:00
|
|
|
size_t GetNumScoreComponents() const {return m_numScoreComponents;}
|
2008-06-11 14:52:57 +04:00
|
|
|
|
|
|
|
//! returns a string description of this producer
|
2010-10-11 18:09:39 +04:00
|
|
|
const std::string& GetScoreProducerDescription() const {return m_description;}
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
//! returns the number of scores gathered from the input (0 by default)
|
|
|
|
virtual size_t GetNumInputScores() const {
|
|
|
|
return 0;
|
|
|
|
};
|
2009-02-06 18:43:06 +03:00
|
|
|
|
|
|
|
virtual bool IsStateless() const = 0;
|
|
|
|
|
2011-08-07 04:58:56 +04:00
|
|
|
void SetSparseFeatureReporting() { m_reportSparseFeatures = true; }
|
|
|
|
bool GetSparseFeatureReporting() const { return m_reportSparseFeatures; }
|
2011-12-13 23:13:13 +04:00
|
|
|
|
|
|
|
virtual float GetSparseProducerWeight() const { return 1; }
|
2008-06-11 14:52:57 +04:00
|
|
|
};
|
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
#endif
|