00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef moses_TargetPhrase_h
00023 #define moses_TargetPhrase_h
00024
00025 #include <vector>
00026 #include "TypeDef.h"
00027 #include "Phrase.h"
00028 #include "ScoreComponentCollection.h"
00029 #include "AlignmentInfo.h"
00030
00031 #include "util/string_piece.hh"
00032
00033 #ifdef HAVE_PROTOBUF
00034 #include "rule.pb.h"
00035 #endif
00036
00037 namespace Moses
00038 {
00039
00040 class LMList;
00041 class ScoreProducer;
00042 class TranslationSystem;
00043 class WordPenaltyProducer;
00044
00047 class TargetPhrase: public Phrase
00048 {
00049 friend std::ostream& operator<<(std::ostream&, const TargetPhrase&);
00050 protected:
00051 float m_transScore;
00052 float m_fullScore;
00053 ScoreComponentCollection m_scoreBreakdown;
00054 const AlignmentInfo *m_alignmentInfo;
00055
00056
00057 Phrase const* m_sourcePhrase;
00058 Word m_lhsTarget;
00059
00060 public:
00061 TargetPhrase();
00062 TargetPhrase(std::string out_string);
00063 TargetPhrase(const Phrase &);
00064 ~TargetPhrase();
00065
00068 void SetScore(const TranslationSystem* system);
00069
00071 void SetScore(float score);
00072
00074 void SetScore(const TranslationSystem* system, const Scores &scoreVector);
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 void SetScore(const ScoreProducer* translationScoreProducer,
00089 const Scores &scoreVector,
00090 const std::vector<float> &weightT,
00091 float weightWP,
00092 const LMList &languageModels);
00093
00094 void SetScoreChart(const ScoreProducer* translationScoreProducer
00095 ,const Scores &scoreVector
00096 ,const std::vector<float> &weightT
00097 ,const LMList &languageModels
00098 ,const WordPenaltyProducer* wpProducer);
00099
00100
00101 void SetScore(const ScoreProducer* producer, const Scores &scoreVector);
00102
00103
00104
00105 void ResetScore();
00106 void SetWeights(const ScoreProducer*, const std::vector<float> &weightT);
00107
00108 TargetPhrase *MergeNext(const TargetPhrase &targetPhrase) const;
00109
00110
00111 #ifdef HAVE_PROTOBUF
00112 void WriteToRulePB(hgmert::Rule* pb) const;
00113 #endif
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 inline float GetFutureScore() const {
00126 return m_fullScore;
00127 }
00128 inline const ScoreComponentCollection &GetScoreBreakdown() const {
00129 return m_scoreBreakdown;
00130 }
00131
00133 void SetSourcePhrase(Phrase const* p) {
00134 m_sourcePhrase=p;
00135 }
00136 Phrase const* GetSourcePhrase() const {
00137 return m_sourcePhrase;
00138 }
00139
00140 void SetTargetLHS(const Word &lhs) {
00141 m_lhsTarget = lhs;
00142 }
00143 const Word &GetTargetLHS() const {
00144 return m_lhsTarget;
00145 }
00146
00147 void SetAlignmentInfo(const StringPiece &alignString);
00148 void SetAlignmentInfo(const std::set<std::pair<size_t,size_t> > &alignmentInfo);
00149 void SetAlignmentInfo(const AlignmentInfo *alignmentInfo) {
00150 m_alignmentInfo = alignmentInfo;
00151 }
00152
00153 const AlignmentInfo &GetAlignmentInfo() const {
00154 return *m_alignmentInfo;
00155 }
00156
00157 TO_STRING();
00158 };
00159
00160 std::ostream& operator<<(std::ostream&, const TargetPhrase&);
00161
00162 }
00163
00164 #endif