diff --git a/moses-cmd/configure b/moses-cmd/configure index d97725ad5..f0f5fbfe9 100755 --- a/moses-cmd/configure +++ b/moses-cmd/configure @@ -847,6 +847,7 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors + --enable-profiling moses will dump profiling info --enable-mysql (optional) build in MySQL support] Optional Packages: @@ -2603,6 +2604,13 @@ else fi; +# Check whether --enable-profiling or --disable-profiling was given. +if test "${enable_profiling+set}" = set; then + enableval="$enable_profiling" + CPPFLAGS="$CPPFLAGS -pg"; LDFLAGS="$LDFLAGS -pg" + +fi; + # Check whether --enable-mysql or --disable-mysql was given. if test "${enable_mysql+set}" = set; then enableval="$enable_mysql" @@ -2612,7 +2620,7 @@ else fi; if test "x$with_boost" != 'xno' then - CPPFLAGS="$CPPFLAGS -I${with_boost}" + CPPFLAGS="$CPPFLAGS -I${with_boost} -I${with_boost}/include" LDFLAGS="$LDFLAGS -L${with_boost}/lib -L${with_boost}/stage/lib" fi diff --git a/moses-cmd/src/Main.cpp b/moses-cmd/src/Main.cpp index 7b19a139b..eaf61136a 100644 --- a/moses-cmd/src/Main.cpp +++ b/moses-cmd/src/Main.cpp @@ -73,6 +73,10 @@ int main(int argc, char* argv[]) { timer.start("Starting..."); +#ifdef N_BEST + cerr << "N_BEST flag on\n"; +#endif + StaticData staticData; if (!staticData.LoadParameters(argc, argv)) return EXIT_FAILURE; @@ -152,14 +156,18 @@ InputOutput *GetInputOutput(StaticData &staticData) list< Phrase > inputPhraseList; string filePath = staticData.GetParam("input-file")[0]; + TRACE_ERR("About to create ioFile" << endl); IOFile *ioFile = new IOFile(factorOrder, inputFactorUsed , staticData.GetFactorCollection() , staticData.GetNBestSize() , staticData.GetNBestFilePath() , filePath); + TRACE_ERR("About to GetInputPhrase" << endl); ioFile->GetInputPhrase(inputPhraseList); + TRACE_ERR("After GetInputPhrase" << endl); inputOutput = ioFile; inputFileHash = GetMD5Hash(filePath); + TRACE_ERR("About to LoadPhraseTables" << endl); staticData.LoadPhraseTables(true, inputFileHash, inputPhraseList); } else diff --git a/moses/src/HypothesisCollection.cpp b/moses/src/HypothesisCollection.cpp index 3cdc00aaf..b81ea4f6a 100755 --- a/moses/src/HypothesisCollection.cpp +++ b/moses/src/HypothesisCollection.cpp @@ -44,6 +44,8 @@ void HypothesisCollection::Add(Hypothesis *hypo) if (hypo->GetScore(ScoreType::Total) > m_bestScore) { m_bestScore = hypo->GetScore(ScoreType::Total); + if ( m_bestScore + m_beamThreshold > m_worstScore ) + m_worstScore = m_bestScore + m_beamThreshold; } if (size() > m_maxHypoStackSize) @@ -59,9 +61,9 @@ float HypothesisCollection::getBestScore(){ -bool HypothesisCollection::Add(Hypothesis *hypo, float beamThreshold) +bool HypothesisCollection::AddPrune(Hypothesis *hypo) { - if (hypo->GetScore(ScoreType::Total) < m_bestScore + beamThreshold) + if (hypo->GetScore(ScoreType::Total) < m_worstScore) return false; // over threshold @@ -138,6 +140,7 @@ void HypothesisCollection::PruneToSize(size_t newSize) ++iter; } } + m_worstScore = scoreThreshold; } } diff --git a/moses/src/HypothesisCollection.h b/moses/src/HypothesisCollection.h index 749ac3154..375507fcc 100755 --- a/moses/src/HypothesisCollection.h +++ b/moses/src/HypothesisCollection.h @@ -64,7 +64,9 @@ class HypothesisCollection : public std::set< Hypothesis*, CompareHypothesisColl friend std::ostream& operator<<(std::ostream&, const HypothesisCollection&); protected: - float m_bestScore, m_beamThreshold; + float m_bestScore; + float m_worstScore; + float m_beamThreshold; size_t m_maxHypoStackSize; // std::list m_arc; @@ -80,6 +82,7 @@ public: inline HypothesisCollection() { m_bestScore = -std::numeric_limits::infinity(); + m_worstScore = -std::numeric_limits::infinity(); } inline void AddNoPrune(Hypothesis *hypothesis) @@ -87,7 +90,8 @@ public: //push_back(hypothesis); insert(hypothesis); } - bool Add(Hypothesis *hypothesis, float beamThreshold); + bool AddPrune(Hypothesis *hypothesis); + // AddPrune adds the hypo, but only if within thresholds (beamThr+stackSize) inline void Detach(const HypothesisCollection::iterator &iter) { erase(iter); diff --git a/moses/src/Makefile.in b/moses/src/Makefile.in index 06a83d3fd..ba7edf78f 100644 --- a/moses/src/Makefile.in +++ b/moses/src/Makefile.in @@ -105,8 +105,6 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ -BUILD_MYSQL_SUPPORT_FALSE = @BUILD_MYSQL_SUPPORT_FALSE@ -BUILD_MYSQL_SUPPORT_TRUE = @BUILD_MYSQL_SUPPORT_TRUE@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ @@ -131,9 +129,6 @@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ -MYSQLCLIENT_CPPFLAGS = @MYSQLCLIENT_CPPFLAGS@ -MYSQLCLIENT_LDFLAGS = @MYSQLCLIENT_LDFLAGS@ -MYSQLCLIENT_LIBS = @MYSQLCLIENT_LIBS@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -203,9 +198,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/Makefile + $(AUTOMAKE) --foreign src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ diff --git a/moses/src/Manager.cpp b/moses/src/Manager.cpp index d73088d98..75bce4c2b 100755 --- a/moses/src/Manager.cpp +++ b/moses/src/Manager.cpp @@ -75,7 +75,7 @@ void Manager::ProcessSentence() LMList allLM = m_staticData.GetAllLM(); hypo->ResizeComponentScore(allLM, decodeStepList); #endif - m_hypoStack[0].Add(hypo, m_staticData.GetBeamThreshold()); + m_hypoStack[0].AddPrune(hypo); } // go thru each stack @@ -181,7 +181,7 @@ void Manager::ProcessOneHypothesis(const list < DecodeStep > &decodeStepList } size_t wordsTranslated = hypo->GetWordsBitmap().GetWordsCount(); - if (m_hypoStack[wordsTranslated].Add(hypo, m_staticData.GetBeamThreshold())) + if (m_hypoStack[wordsTranslated].AddPrune(hypo)) { HypothesisCollectionIntermediate::iterator iterCurr = iterHypo++; lastHypoColl.Detach(iterCurr); diff --git a/moses/src/TypeDef.h b/moses/src/TypeDef.h index b1115a042..f880ea159 100755 --- a/moses/src/TypeDef.h +++ b/moses/src/TypeDef.h @@ -43,7 +43,7 @@ const size_t DEFAULT_VERBOSE_LEVEL = 1; #include "config.h" #define TRACE_ENABLE 1 // REMOVE after we figure this out -// #define N_BEST 1 // REMOVE +#define N_BEST 1 // REMOVE # ifdef HAVE_SRILM # define LM_SRI 1