diff --git a/moses/src/Arc.h b/moses/src/Arc.h index f9ae34f26..69c4c18b2 100755 --- a/moses/src/Arc.h +++ b/moses/src/Arc.h @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include #include "Phrase.h" #include "LatticeEdge.h" -#include "TransScoreComponent.h" +#include "ScoreComponent.h" class Arc : public LatticeEdge { @@ -34,7 +34,7 @@ public: Arc(const Arc &arc); // not implemented Arc( const float score[NUM_SCORES] - , const TransScoreComponentCollection &transScoreComponent + , const ScoreComponentCollection &transScoreComponent , const ScoreColl &lmScoreComponent , const ScoreColl &generationScoreColl , const Phrase &phrase diff --git a/moses/src/Hypothesis.cpp b/moses/src/Hypothesis.cpp index f69a6a3ec..c7349cc4d 100755 --- a/moses/src/Hypothesis.cpp +++ b/moses/src/Hypothesis.cpp @@ -53,7 +53,7 @@ Hypothesis::Hypothesis(const Hypothesis ©) SetScore(copy.GetScore()); #ifdef N_BEST m_lmScoreComponent = copy.GetLMScoreComponent(); - m_transScoreComponent = copy.GetTransScoreComponent(); + m_transScoreComponent = copy.GetScoreComponent(); m_generationScoreComponent = copy.GetGenerationScoreComponent(); #endif @@ -94,12 +94,12 @@ Hypothesis::Hypothesis(const Hypothesis &prevHypo, const PossibleTranslation &po } // translation score - const TransScoreComponentCollection &prevComponent= prevHypo.GetTransScoreComponent(); + const ScoreComponentCollection &prevComponent= prevHypo.GetScoreComponent(); m_transScoreComponent = prevComponent; // add components specific to poss trans - const TransScoreComponent &possComponent = possTrans.GetScoreComponents(); - TransScoreComponent &transComponent = m_transScoreComponent.GetTransScoreComponent(possComponent.GetPhraseDictionary()); + const ScoreComponent &possComponent = possTrans.GetScoreComponents(); + ScoreComponent &transComponent = m_transScoreComponent.GetScoreComponent(possComponent.GetPhraseDictionary()); const size_t noScoreComponent = possComponent.GetNoScoreComponent(); for (size_t i = 0 ; i < noScoreComponent ; i++) @@ -151,7 +151,7 @@ Hypothesis *Hypothesis::MergeNext(const PossibleTranslation &possTrans) const } #ifdef N_BEST - const TransScoreComponent &possTransComponent = possTrans.GetScoreComponents(); + const ScoreComponent &possTransComponent = possTrans.GetScoreComponents(); clone->m_transScoreComponent.Add(possTransComponent); #endif @@ -439,7 +439,7 @@ ostream& operator<<(ostream& out, const Hypothesis& hypothesis) } out << "]"; #ifdef N_BEST - out << " " << hypothesis.GetTransScoreComponent(); + out << " " << hypothesis.GetScoreComponent(); out << " " << hypothesis.GetGenerationScoreComponent(); #endif return out; diff --git a/moses/src/Hypothesis.h b/moses/src/Hypothesis.h index def41b3d0..9e4c8ae2c 100755 --- a/moses/src/Hypothesis.h +++ b/moses/src/Hypothesis.h @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "LanguageModel.h" #include "Arc.h" #include "LatticeEdge.h" -#include "TransScoreComponentCollection.h" +#include "ScoreComponentCollection.h" class SquareMatrix; class PossibleTranslation; @@ -150,7 +150,7 @@ public: inline void AddArc(Hypothesis &loserHypo) { Arc *arc = new Arc(loserHypo.m_score - , loserHypo.GetTransScoreComponent() + , loserHypo.GetScoreComponent() , loserHypo.GetLMScoreComponent() , loserHypo.GetGenerationScoreComponent() , loserHypo.GetPhrase() diff --git a/moses/src/LatticeEdge.cpp b/moses/src/LatticeEdge.cpp index b4404fd97..96f9b987b 100755 --- a/moses/src/LatticeEdge.cpp +++ b/moses/src/LatticeEdge.cpp @@ -53,7 +53,7 @@ void LatticeEdge::ResizeComponentScore(const LMList &allLM, const list < DecodeS { case Translate: { - TransScoreComponent &transScoreComponent = m_transScoreComponent.Add(&step.GetPhraseDictionary()); + ScoreComponent &transScoreComponent = m_transScoreComponent.Add(&step.GetPhraseDictionary()); transScoreComponent.Reset(); break; } diff --git a/moses/src/LatticeEdge.h b/moses/src/LatticeEdge.h index 92dfdb3f2..83d604a11 100755 --- a/moses/src/LatticeEdge.h +++ b/moses/src/LatticeEdge.h @@ -25,8 +25,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include #include "TypeDef.h" #include "Phrase.h" -#include "TransScoreComponent.h" -#include "TransScoreComponentCollection.h" +#include "ScoreComponent.h" +#include "ScoreComponentCollection.h" #include "ScoreColl.h" #include "DecodeStep.h" @@ -44,7 +44,7 @@ protected: Phrase m_phrase; #ifdef N_BEST - TransScoreComponentCollection m_transScoreComponent; + ScoreComponentCollection m_transScoreComponent; ScoreColl m_generationScoreComponent ,m_lmScoreComponent; #endif @@ -52,7 +52,7 @@ protected: public: LatticeEdge(const LatticeEdge &edge); // not implemented LatticeEdge(const float score[NUM_SCORES] - , const TransScoreComponentCollection &transScoreComponent + , const ScoreComponentCollection &transScoreComponent , const ScoreColl &lmScoreComponent , const ScoreColl &generationScoreComponent , const Phrase &phrase @@ -109,7 +109,7 @@ public: #ifdef N_BEST virtual const std::list &GetArcList() const = 0; - inline const TransScoreComponentCollection &GetTransScoreComponent() const + inline const ScoreComponentCollection &GetScoreComponent() const { return m_transScoreComponent; } diff --git a/moses/src/LatticePath.cpp b/moses/src/LatticePath.cpp index 6a94782a8..7d7f37ff0 100755 --- a/moses/src/LatticePath.cpp +++ b/moses/src/LatticePath.cpp @@ -35,7 +35,7 @@ LatticePath::LatticePath(const Hypothesis *hypo) } #ifdef N_BEST m_lmScoreComponent = hypo->GetLMScoreComponent(); - m_transScoreComponent = hypo->GetTransScoreComponent(); + m_transScoreComponent = hypo->GetScoreComponent(); m_generationScoreComponent = hypo->GetGenerationScoreComponent(); #endif @@ -104,23 +104,23 @@ void LatticePath::CalcScore(const LatticePath ©, size_t edgeIndex, const Arc } // phrase trans - m_transScoreComponent = copy.GetTransScoreComponent(); + m_transScoreComponent = copy.GetScoreComponent(); - const TransScoreComponentCollection - &arcComponent = arc->GetTransScoreComponent() - ,©Component = copy.m_path[edgeIndex]->GetTransScoreComponent() - ,&totalComponent= copy.GetTransScoreComponent(); + const ScoreComponentCollection + &arcComponent = arc->GetScoreComponent() + ,©Component = copy.m_path[edgeIndex]->GetScoreComponent() + ,&totalComponent= copy.GetScoreComponent(); - TransScoreComponentCollection::iterator iterTrans; + ScoreComponentCollection::iterator iterTrans; for (iterTrans = m_transScoreComponent.begin() ; iterTrans != m_transScoreComponent.end() ; ++iterTrans) { const PhraseDictionary *phraseDictionary = iterTrans->first; - TransScoreComponent &transScore = *iterTrans->second; + ScoreComponent &transScore = *iterTrans->second; const size_t noScoreComponent = phraseDictionary->GetNoScoreComponent(); - const TransScoreComponent &arcScore = arcComponent.GetTransScoreComponent(phraseDictionary) - ,©Score = copyComponent.GetTransScoreComponent(phraseDictionary) - ,&totalScore = totalComponent.GetTransScoreComponent(phraseDictionary); + const ScoreComponent &arcScore = arcComponent.GetScoreComponent(phraseDictionary) + ,©Score = copyComponent.GetScoreComponent(phraseDictionary) + ,&totalScore = totalComponent.GetScoreComponent(phraseDictionary); for (size_t i = 0 ; i < noScoreComponent ; i++) { float adj = arcScore[i] - copyScore[i]; diff --git a/moses/src/LatticePath.h b/moses/src/LatticePath.h index e09931fe3..e3ed0106b 100755 --- a/moses/src/LatticePath.h +++ b/moses/src/LatticePath.h @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "LatticeEdge.h" #include "Hypothesis.h" #include "TypeDef.h" -#include "TransScoreComponent.h" +#include "ScoreComponent.h" #include "ScoreColl.h" class Arc; @@ -42,7 +42,7 @@ protected: size_t m_prevEdgeChanged; float m_score[NUM_SCORES]; - TransScoreComponentCollection m_transScoreComponent; + ScoreComponentCollection m_transScoreComponent; ScoreColl m_generationScoreComponent , m_lmScoreComponent; @@ -86,7 +86,7 @@ public: { return m_lmScoreComponent.GetValue(index); } - inline const TransScoreComponentCollection &GetTransScoreComponent() const + inline const ScoreComponentCollection &GetScoreComponent() const { return m_transScoreComponent; } @@ -116,7 +116,7 @@ inline std::ostream& operator<<(std::ostream& out, const LatticePath& path) } out << "]"; #ifdef N_BEST - out << " " << path.GetTransScoreComponent(); + out << " " << path.GetScoreComponent(); out << " " << path.GetGenerationScoreComponent(); #endif diff --git a/moses/src/PossibleTranslation.h b/moses/src/PossibleTranslation.h index 74c9a29f8..f5f921aad 100755 --- a/moses/src/PossibleTranslation.h +++ b/moses/src/PossibleTranslation.h @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "Hypothesis.h" #include "Util.h" #include "TypeDef.h" -#include "TransScoreComponent.h" +#include "ScoreComponent.h" class PossibleTranslation { @@ -37,7 +37,7 @@ protected: WordsRange m_wordsRange; float m_transScore, m_futureScore, m_ngramScore; #ifdef N_BEST - TransScoreComponent m_transScoreComponent; + ScoreComponent m_transScoreComponent; std::list< std::pair > m_lmScoreComponent; std::list< std::pair > m_trigramComponent; #endif @@ -89,7 +89,7 @@ public: } #ifdef N_BEST - inline const TransScoreComponent &GetScoreComponents() const + inline const ScoreComponent &GetScoreComponents() const { return m_transScoreComponent; } diff --git a/moses/src/TransScoreComponent.h b/moses/src/ScoreComponent.h similarity index 82% rename from moses/src/TransScoreComponent.h rename to moses/src/ScoreComponent.h index c8d3adce1..c54213406 100644 --- a/moses/src/TransScoreComponent.h +++ b/moses/src/ScoreComponent.h @@ -25,17 +25,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA class PhraseDictionary; -class TransScoreComponent +class ScoreComponent { protected: const PhraseDictionary *m_phraseDictionary; float *m_scoreComponent; - TransScoreComponent(); // not implemented + ScoreComponent(); // not implemented public: - TransScoreComponent(const PhraseDictionary *phraseDictionary); - TransScoreComponent(const TransScoreComponent ©); - ~TransScoreComponent(); + ScoreComponent(const PhraseDictionary *phraseDictionary); + ScoreComponent(const ScoreComponent ©); + ~ScoreComponent(); void Reset(); const PhraseDictionary *GetPhraseDictionary() const @@ -54,4 +54,4 @@ public: } }; -std::ostream& operator<<(std::ostream &out, const TransScoreComponent &transScoreComponent); +std::ostream& operator<<(std::ostream &out, const ScoreComponent &transScoreComponent); diff --git a/moses/src/TransScoreComponentCollection.h b/moses/src/ScoreComponentCollection.h similarity index 58% rename from moses/src/TransScoreComponentCollection.h rename to moses/src/ScoreComponentCollection.h index 66b8d62f6..622b925f7 100644 --- a/moses/src/TransScoreComponentCollection.h +++ b/moses/src/ScoreComponentCollection.h @@ -24,22 +24,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include -#include "TransScoreComponent.h" +#include "ScoreComponent.h" #include "PhraseDictionary.h" -class TransScoreComponentCollection : public std::map +class ScoreComponentCollection : public std::map { public: - TransScoreComponent &GetTransScoreComponent(const PhraseDictionary *phraseDictionary) + ScoreComponent &GetScoreComponent(const PhraseDictionary *phraseDictionary) { - TransScoreComponentCollection::iterator iter = find(phraseDictionary); + ScoreComponentCollection::iterator iter = find(phraseDictionary); assert(iter != end()); return *iter->second; } - ~TransScoreComponentCollection() + ~ScoreComponentCollection() { // ??? memory leak but double free -/* TransScoreComponentCollection::iterator iter; +/* ScoreComponentCollection::iterator iter; for (iter = begin() ; iter != end() ; ++iter) { delete iter->second; @@ -47,39 +47,39 @@ public: */ } - const TransScoreComponent &GetTransScoreComponent(const PhraseDictionary *phraseDictionary) const + const ScoreComponent &GetScoreComponent(const PhraseDictionary *phraseDictionary) const { - return const_cast(this)->GetTransScoreComponent(phraseDictionary); + return const_cast(this)->GetScoreComponent(phraseDictionary); } - TransScoreComponent &Add(const TransScoreComponent &transScoreComponent) + ScoreComponent &Add(const ScoreComponent &transScoreComponent) { const PhraseDictionary *phraseDictionary = transScoreComponent.GetPhraseDictionary(); - TransScoreComponentCollection::iterator iter = find(phraseDictionary); + ScoreComponentCollection::iterator iter = find(phraseDictionary); if (iter != end()) { // already have scores for this phrase table. delete it 1st delete iter->second; erase(iter); } // add new into same place - TransScoreComponent *newTransScoreComponent = new TransScoreComponent(transScoreComponent); - operator[](phraseDictionary) = newTransScoreComponent; + ScoreComponent *newScoreComponent = new ScoreComponent(transScoreComponent); + operator[](phraseDictionary) = newScoreComponent; - return *newTransScoreComponent; + return *newScoreComponent; } - TransScoreComponent &Add(const PhraseDictionary *phraseDictionary) + ScoreComponent &Add(const PhraseDictionary *phraseDictionary) { - return Add(TransScoreComponent(phraseDictionary)); + return Add(ScoreComponent(phraseDictionary)); } }; -inline std::ostream& operator<<(std::ostream &out, const TransScoreComponentCollection &transScoreComponentColl) +inline std::ostream& operator<<(std::ostream &out, const ScoreComponentCollection &transScoreComponentColl) { - TransScoreComponentCollection::const_iterator iter; + ScoreComponentCollection::const_iterator iter; for (iter = transScoreComponentColl.begin() ; iter != transScoreComponentColl.end() ; ++iter) { const PhraseDictionary *phraseDictionary = iter->first; - const TransScoreComponent &transScoreComponent = *iter->second; + const ScoreComponent &transScoreComponent = *iter->second; out << "[" << phraseDictionary->GetId() << "=" << transScoreComponent << "] "; } return out; diff --git a/moses/src/TargetPhrase.h b/moses/src/TargetPhrase.h index 734508ae4..696cf1a9c 100644 --- a/moses/src/TargetPhrase.h +++ b/moses/src/TargetPhrase.h @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include #include "Phrase.h" -#include "TransScoreComponent.h" +#include "ScoreComponent.h" class PhraseDictionary; @@ -32,7 +32,7 @@ class TargetPhrase: public Phrase protected: float m_score; #ifdef N_BEST - TransScoreComponent m_scoreComponent; + ScoreComponent m_scoreComponent; #endif public: @@ -52,7 +52,7 @@ public: void SetWeight(const std::vector &weightT); #ifdef N_BEST - inline const TransScoreComponent &GetScoreComponents() const + inline const ScoreComponent &GetScoreComponents() const { return m_scoreComponent; } diff --git a/moses/src/TransScoreComponent.cpp b/moses/src/TransScoreComponent.cpp index 50898a08e..0dc6eb6f0 100644 --- a/moses/src/TransScoreComponent.cpp +++ b/moses/src/TransScoreComponent.cpp @@ -21,16 +21,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "TypeDef.h" #include "Util.h" -#include "TransScoreComponent.h" +#include "ScoreComponent.h" #include "PhraseDictionary.h" -TransScoreComponent::TransScoreComponent(const PhraseDictionary *phraseDictionary) +ScoreComponent::ScoreComponent(const PhraseDictionary *phraseDictionary) : m_phraseDictionary(phraseDictionary) { m_scoreComponent = (float*) malloc(sizeof(float) * phraseDictionary->GetNoScoreComponent()); } -TransScoreComponent::TransScoreComponent(const TransScoreComponent ©) +ScoreComponent::ScoreComponent(const ScoreComponent ©) :m_phraseDictionary(copy.m_phraseDictionary) { const size_t noScoreComponent = m_phraseDictionary->GetNoScoreComponent(); @@ -42,12 +42,12 @@ TransScoreComponent::TransScoreComponent(const TransScoreComponent ©) } } -TransScoreComponent::~TransScoreComponent() +ScoreComponent::~ScoreComponent() { free(m_scoreComponent); } -void TransScoreComponent::Reset() +void ScoreComponent::Reset() { const size_t noScoreComponent = m_phraseDictionary->GetNoScoreComponent(); for (size_t i = 0 ; i < noScoreComponent ; i++) @@ -56,12 +56,12 @@ void TransScoreComponent::Reset() } } -size_t TransScoreComponent::GetNoScoreComponent() const +size_t ScoreComponent::GetNoScoreComponent() const { return m_phraseDictionary->GetNoScoreComponent(); } -std::ostream& operator<<(std::ostream &out, const TransScoreComponent &transScoreComponent) +std::ostream& operator<<(std::ostream &out, const ScoreComponent &transScoreComponent) { const size_t noScoreComponent = transScoreComponent.GetNoScoreComponent(); out << transScoreComponent[0];