MosesTuning::Scorer Class Reference

#include <Scorer.h>

Inheritance diagram for MosesTuning::Scorer:

Inheritance graph
[legend]
Collaboration diagram for MosesTuning::Scorer:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Scorer (const std::string &name, const std::string &config)
virtual ~Scorer ()
virtual std::size_t NumberOfScores () const =0
virtual float calculateScore (const std::vector< ScoreStatsType > &totals) const =0
float calculateSentenceLevelBackgroundScore (const std::vector< ScoreStatsType > &totals, const std::vector< ScoreStatsType > &bg)
virtual void setReferenceFiles (const std::vector< std::string > &referenceFiles)
virtual void prepareStats (std::size_t sindex, const std::string &text, ScoreStats &entry)
virtual void prepareStats (const std::string &sindex, const std::string &text, ScoreStats &entry)
virtual void score (const candidates_t &candidates, const diffs_t &diffs, statscores_t &scores) const =0
float score (const candidates_t &candidates) const
const std::string & getName () const
std::size_t getReferenceSize () const
virtual float getReferenceLength (const std::vector< ScoreStatsType > &totals) const =0
virtual void setScoreData (ScoreData *data)
virtual bool useAlignment () const
virtual void setFactors (const std::string &factors)
mert::VocabularyGetVocab () const
virtual void setFilter (const std::string &filterCommand)

Protected Member Functions

std::string getConfig (const std::string &key, const std::string &def="") const
void TokenizeAndEncode (const std::string &line, std::vector< int > &encoded) const
void TokenizeAndEncodeTesting (const std::string &line, std::vector< int > &encoded) const
std::string preprocessSentence (const std::string &sentence) const

Protected Attributes

ScoreDatam_score_data
bool m_enable_preserve_case


Detailed Description

Superclass of all scorers and dummy implementation.

In order to add a new scorer it should be sufficient to override the members prepareStats(), setReferenceFiles() and score() (or calculateScore()).

Definition at line 33 of file Scorer.h.


Constructor & Destructor Documentation

MosesTuning::Scorer::Scorer ( const std::string &  name,
const std::string &  config 
)

Scorer::~Scorer (  )  [virtual]

Definition at line 37 of file Scorer.cpp.


Member Function Documentation

virtual float MosesTuning::Scorer::calculateScore ( const std::vector< ScoreStatsType > &  totals  )  const [pure virtual]

float MosesTuning::Scorer::calculateSentenceLevelBackgroundScore ( const std::vector< ScoreStatsType > &  totals,
const std::vector< ScoreStatsType > &  bg 
) [inline]

Definition at line 49 of file Scorer.h.

References calculateScore(), getReferenceLength(), and Moses::stats.

Referenced by MosesTuning::NbestHopeFearDecoder::HopeFear().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string MosesTuning::Scorer::getConfig ( const std::string &  key,
const std::string &  def = "" 
) const [inline, protected]

Get value of config variable. If not provided, return default.

Definition at line 176 of file Scorer.h.

Referenced by MosesTuning::SentenceLevelScorer::Init().

Here is the caller graph for this function:

const std::string& MosesTuning::Scorer::getName (  )  const [inline]

Definition at line 101 of file Scorer.h.

Referenced by MosesTuning::ScoreData::ScoreData().

Here is the caller graph for this function:

virtual float MosesTuning::Scorer::getReferenceLength ( const std::vector< ScoreStatsType > &  totals  )  const [pure virtual]

Based on vector of sufficient statistics, return length of reference.

Implemented in MosesTuning::BleuScorer, MosesTuning::HwcmScorer, MosesTuning::InterpolatedScorer, MosesTuning::M2Scorer, MosesTuning::MeteorScorer, and MosesTuning::StatisticsBasedScorer.

Referenced by calculateSentenceLevelBackgroundScore().

Here is the caller graph for this function:

std::size_t MosesTuning::Scorer::getReferenceSize (  )  const [inline]

Definition at line 105 of file Scorer.h.

References m_score_data, and MosesTuning::ScoreData::size().

Here is the call graph for this function:

mert::Vocabulary* MosesTuning::Scorer::GetVocab (  )  const [inline]

Definition at line 138 of file Scorer.h.

Referenced by BOOST_AUTO_TEST_CASE().

Here is the caller graph for this function:

virtual std::size_t MosesTuning::Scorer::NumberOfScores (  )  const [pure virtual]

virtual void MosesTuning::Scorer::prepareStats ( const std::string &  sindex,
const std::string &  text,
ScoreStats entry 
) [inline, virtual]

Definition at line 72 of file Scorer.h.

References prepareStats().

Here is the call graph for this function:

virtual void MosesTuning::Scorer::prepareStats ( std::size_t  sindex,
const std::string &  text,
ScoreStats entry 
) [inline, virtual]

Process the given guessed text, corresponding to the given reference sindex and add the appropriate statistics to the entry.

Reimplemented in MosesTuning::BleuDocScorer, MosesTuning::BleuScorer, MosesTuning::CderScorer, MosesTuning::HwcmScorer, MosesTuning::InterpolatedScorer, MosesTuning::M2Scorer, MosesTuning::MeteorScorer, MosesTuning::PerScorer, MosesTuning::SemposScorer, and MosesTuning::TerScorer.

Definition at line 68 of file Scorer.h.

Referenced by prepareStats().

Here is the caller graph for this function:

std::string MosesTuning::Scorer::preprocessSentence ( const std::string &  sentence  )  const [inline, protected]

Every inherited scorer should call this function for each sentence

Definition at line 199 of file Scorer.h.

Referenced by MosesTuning::BleuScorer::CalcBleuStats(), and MosesTuning::BleuScorer::GetNextReferenceFromStreams().

Here is the caller graph for this function:

float Scorer::score ( const candidates_t candidates  )  const

Calculate the score of the sentences corresponding to the list of candidate indices. Each index indicates the 1-best choice from the n-best list.

Definition at line 185 of file Scorer.cpp.

References score().

Here is the call graph for this function:

virtual void MosesTuning::Scorer::score ( const candidates_t candidates,
const diffs_t diffs,
statscores_t scores 
) const [pure virtual]

Score using each of the candidate index, then go through the diffs applying each in turn, and calculating a new score each time.

Implemented in MosesTuning::InterpolatedScorer, and MosesTuning::StatisticsBasedScorer.

Referenced by MosesTuning::Optimizer::GetStatScore(), and score().

Here is the caller graph for this function:

virtual void MosesTuning::Scorer::setFactors ( const std::string &  factors  )  [virtual]

Set the factors, which should be used for this metric

Reimplemented in MosesTuning::InterpolatedScorer.

Referenced by main().

Here is the caller graph for this function:

virtual void MosesTuning::Scorer::setFilter ( const std::string &  filterCommand  )  [virtual]

Set unix filter, which will be used to preprocess the sentences

Reimplemented in MosesTuning::InterpolatedScorer.

Referenced by main().

Here is the caller graph for this function:

virtual void MosesTuning::Scorer::setReferenceFiles ( const std::vector< std::string > &  referenceFiles  )  [inline, virtual]

Set the reference files. This must be called before prepareStats().

Reimplemented in MosesTuning::BleuScorer, MosesTuning::CderScorer, MosesTuning::HwcmScorer, MosesTuning::InterpolatedScorer, MosesTuning::M2Scorer, MosesTuning::MeteorScorer, MosesTuning::PermutationScorer, MosesTuning::PerScorer, MosesTuning::SemposScorer, and MosesTuning::TerScorer.

Definition at line 60 of file Scorer.h.

Referenced by main().

Here is the caller graph for this function:

virtual void MosesTuning::Scorer::setScoreData ( ScoreData data  )  [inline, virtual]

Set the score data, prior to scoring.

Reimplemented in MosesTuning::InterpolatedScorer.

Definition at line 120 of file Scorer.h.

References m_score_data.

Referenced by MosesTuning::ScoreData::ScoreData().

Here is the caller graph for this function:

void MosesTuning::Scorer::TokenizeAndEncode ( const std::string &  line,
std::vector< int > &  encoded 
) const [protected]

Tokenise line and encode. Note: We assume that all tokens are separated by whitespaces.

void MosesTuning::Scorer::TokenizeAndEncodeTesting ( const std::string &  line,
std::vector< int > &  encoded 
) const [protected]

virtual bool MosesTuning::Scorer::useAlignment (  )  const [inline, virtual]

The scorer returns if it uses the reference alignment data for permutation distance scores

Reimplemented in MosesTuning::HwcmScorer, MosesTuning::InterpolatedScorer, and MosesTuning::PermutationScorer.

Definition at line 128 of file Scorer.h.


Member Data Documentation

Definition at line 171 of file Scorer.h.

Referenced by MosesTuning::SentenceLevelScorer::Init().


The documentation for this class was generated from the following files:

Generated on Thu Jul 6 00:34:20 2017 for Moses by  doxygen 1.5.9