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
|
|
|
|
{
|
2012-12-24 19:17:13 +04:00
|
|
|
class InputType;
|
2008-10-09 03:51:26 +04:00
|
|
|
|
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
|
|
|
|
{
|
2013-01-02 15:31:59 +04:00
|
|
|
protected:
|
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;
|
2013-01-02 15:31:59 +04:00
|
|
|
|
|
|
|
ScoreProducer(const ScoreProducer&); // don't implement
|
2011-11-09 01:22:34 +04:00
|
|
|
ScoreProducer(const std::string& description, size_t numScoreComponents);
|
2008-06-11 14:52:57 +04:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2012-12-27 15:41:52 +04:00
|
|
|
virtual ~ScoreProducer();
|
|
|
|
|
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
|
2012-12-07 20:05:50 +04:00
|
|
|
const std::string& GetScoreProducerDescription() const
|
|
|
|
{ return m_description; }
|
2008-06-11 14:52:57 +04:00
|
|
|
|
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; }
|
2012-12-15 23:20:07 +04:00
|
|
|
|
|
|
|
virtual bool IsTuneable() const { return true; }
|
2012-12-24 19:17:13 +04:00
|
|
|
|
2012-12-24 20:52:40 +04:00
|
|
|
//!
|
|
|
|
virtual void InitializeForInput(InputType const& source)
|
|
|
|
{}
|
|
|
|
|
2012-12-24 19:17:13 +04:00
|
|
|
// clean up temporary memory, called after processing each sentence
|
|
|
|
virtual void CleanUpAfterSentenceProcessing(const InputType& source)
|
|
|
|
{}
|
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
|