mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-29 06:52:34 +03:00
Never add a hypo with score worse than the worst in the (at least once pruned) stack, as it would get pruned anyway.
Renamed Add(hypo, beamthreshold) to AddPrune(hypo) git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@97 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
parent
e798b099e0
commit
02a83cbc28
10
moses-cmd/configure
vendored
10
moses-cmd/configure
vendored
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<Arc> m_arc;
|
||||
@ -80,6 +82,7 @@ public:
|
||||
inline HypothesisCollection()
|
||||
{
|
||||
m_bestScore = -std::numeric_limits<float>::infinity();
|
||||
m_worstScore = -std::numeric_limits<float>::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);
|
||||
|
@ -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 \
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user