00001 #pragma once 00002 00003 #include <ostream> 00004 #include <string> 00005 #include <vector> 00006 00007 #include "Types.h" 00008 #include "ScoreData.h" 00009 #include "StatisticsBasedScorer.h" 00010 #include "ScopedVector.h" 00011 #include "BleuScorer.h" 00012 00013 namespace MosesTuning 00014 { 00015 00021 class BleuDocScorer : public BleuScorer 00022 { 00023 public: 00024 00025 explicit BleuDocScorer(const std::string& config = ""); 00026 ~BleuDocScorer(); 00027 00028 virtual void prepareStats(std::size_t sid, const std::string& text, ScoreStats& entry); 00029 virtual statscore_t calculateScore(const std::vector<int>& comps) const; 00030 00031 int CalcReferenceLength(std::size_t doc_id, std::size_t sentence_id, std::size_t length); 00032 00033 // NOTE: this function is used for unit testing. 00034 virtual bool OpenReferenceStream(std::istream* is, std::size_t file_id); 00035 00036 private: 00037 ReferenceLengthType m_ref_length_type; 00038 00039 // reference translations. 00040 ScopedVector<ScopedVector<Reference> > m_references; 00041 00042 // no copying allowed 00043 BleuDocScorer(const BleuDocScorer&); 00044 BleuDocScorer& operator=(const BleuDocScorer&); 00045 00046 std::vector<std::string> splitDoc(const std::string& text); 00047 }; 00048 00049 /* /\** Computes sentence-level BLEU+1 score. */ 00050 /* * This function is used in PRO. */ 00051 /* *\/ */ 00052 /* float sentenceLevelBleuPlusOne(const std::vector<float>& stats); */ 00053 00054 /* /\** Computes sentence-level BLEU score given a background corpus. */ 00055 /* * This function is used in batch MIRA. */ 00056 /* *\/ */ 00057 /* float sentenceLevelBackgroundBleu(const std::vector<float>& sent, const std::vector<float>& bg); */ 00058 00059 /* /\** */ 00060 /* * Computes plain old BLEU from a vector of stats */ 00061 /* *\/ */ 00062 /* float unsmoothedBleu(const std::vector<float>& stats); */ 00063 00064 } 00065