#include <Scorer.h>


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::Vocabulary * | GetVocab () 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 | |
| ScoreData * | m_score_data |
| bool | m_enable_preserve_case |
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.
| MosesTuning::Scorer::Scorer | ( | const std::string & | name, | |
| const std::string & | config | |||
| ) |
| Scorer::~Scorer | ( | ) | [virtual] |
Definition at line 37 of file Scorer.cpp.
| virtual float MosesTuning::Scorer::calculateScore | ( | const std::vector< ScoreStatsType > & | totals | ) | const [pure virtual] |
Calculate score based on a vector of sufficient statistics.
Implemented in MosesTuning::BleuScorer, MosesTuning::CderScorer, MosesTuning::HwcmScorer, MosesTuning::InterpolatedScorer, MosesTuning::M2Scorer, MosesTuning::MeteorScorer, MosesTuning::PermutationScorer, MosesTuning::PerScorer, MosesTuning::SemposScorer, MosesTuning::SentenceLevelScorer, MosesTuning::StatisticsBasedScorer, and MosesTuning::TerScorer.
Referenced by calculateSentenceLevelBackgroundScore(), and MosesTuning::HopeFearDecoder::Evaluate().

| 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().


| 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().

| const std::string& MosesTuning::Scorer::getName | ( | ) | const [inline] |
Definition at line 101 of file Scorer.h.
Referenced by MosesTuning::ScoreData::ScoreData().

| 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().

| std::size_t MosesTuning::Scorer::getReferenceSize | ( | ) | const [inline] |
Definition at line 105 of file Scorer.h.
References m_score_data, and MosesTuning::ScoreData::size().

| mert::Vocabulary* MosesTuning::Scorer::GetVocab | ( | ) | const [inline] |
Definition at line 138 of file Scorer.h.
Referenced by BOOST_AUTO_TEST_CASE().

| virtual std::size_t MosesTuning::Scorer::NumberOfScores | ( | ) | const [pure virtual] |
Return the number of statistics needed for the computation of the score.
Implemented in MosesTuning::BleuScorer, MosesTuning::CderScorer, MosesTuning::HwcmScorer, MosesTuning::InterpolatedScorer, MosesTuning::M2Scorer, MosesTuning::MeteorScorer, MosesTuning::PermutationScorer, MosesTuning::PerScorer, MosesTuning::SemposScorer, and MosesTuning::TerScorer.
Referenced by MosesTuning::HopeFearDecoder::Evaluate(), and MosesTuning::ScoreData::ScoreData().

| 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().

| 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().

| 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().

| 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().

| 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().

| 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().

| 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().

| 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().

| 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().

| 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.
bool MosesTuning::Scorer::m_enable_preserve_case [protected] |
ScoreData* MosesTuning::Scorer::m_score_data [protected] |
Definition at line 170 of file Scorer.h.
Referenced by getReferenceSize(), MosesTuning::StatisticsBasedScorer::score(), MosesTuning::SentenceLevelScorer::score(), setScoreData(), and MosesTuning::InterpolatedScorer::setScoreData().
1.5.9