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
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <limits>
|
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
2009-02-06 18:43:06 +03:00
|
|
|
class Hypothesis;
|
|
|
|
class ScoreComponentCollection;
|
2008-06-11 14:52:57 +04:00
|
|
|
class ScoreIndexManager;
|
2009-02-06 18:43:06 +03:00
|
|
|
class FFState;
|
2008-06-11 14:52:57 +04:00
|
|
|
|
|
|
|
/** to keep track of the various things that can produce a score,
|
|
|
|
* we use this evil implementation-inheritance to give them each
|
|
|
|
* a unique, sequential (read: good for vector indices) ID
|
|
|
|
*
|
|
|
|
* @note do not confuse this with a producer/consumer pattern.
|
|
|
|
* this is not a producer in that sense.
|
|
|
|
*/
|
|
|
|
class ScoreProducer
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
static unsigned int s_globalScoreBookkeepingIdCounter;
|
|
|
|
unsigned int m_scoreBookkeepingId;
|
|
|
|
|
|
|
|
ScoreProducer(const ScoreProducer&); // don't implement
|
|
|
|
|
|
|
|
#define UNASSIGNED std::numeric_limits<unsigned int>::max()
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// it would be nice to force registration here, but some Producer objects
|
|
|
|
// are constructed before they know how many scores they have
|
|
|
|
ScoreProducer();
|
|
|
|
virtual ~ScoreProducer();
|
|
|
|
|
|
|
|
public:
|
|
|
|
//! contiguous id
|
|
|
|
unsigned int GetScoreBookkeepingID() const { return m_scoreBookkeepingId; }
|
|
|
|
void CreateScoreBookkeepingID() { m_scoreBookkeepingId = s_globalScoreBookkeepingIdCounter++;}
|
|
|
|
//! returns the number of scores that a subclass produces.
|
|
|
|
//! For example, a language model conventionally produces 1, a translation table some arbitrary number, etc
|
|
|
|
virtual size_t GetNumScoreComponents() const = 0;
|
|
|
|
|
|
|
|
//! returns a string description of this producer
|
|
|
|
virtual std::string GetScoreProducerDescription() const = 0;
|
|
|
|
|
2009-05-26 23:30:35 +04:00
|
|
|
//! returns the weight parameter name of this producer (used in n-best list)
|
|
|
|
virtual std::string GetScoreProducerWeightShortName() const = 0;
|
|
|
|
|
2008-06-11 14:52:57 +04: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;
|
|
|
|
|
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
|