mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
use Bitmap& in Hypothesis
This commit is contained in:
parent
b5f0758ee4
commit
3d8e5fa79e
@ -211,7 +211,8 @@ Hypothesis *BackwardsEdge::CreateHypothesis(const Hypothesis &hypothesis, const
|
||||
IFVERBOSE(2) {
|
||||
hypothesis.GetManager().GetSentenceStats().StartTimeBuildHyp();
|
||||
}
|
||||
Hypothesis *newHypo = new Hypothesis(hypothesis, transOpt);
|
||||
const WordsBitmap &bitmap = m_parent.GetWordsBitmap();
|
||||
Hypothesis *newHypo = new Hypothesis(hypothesis, transOpt, bitmap);
|
||||
IFVERBOSE(2) {
|
||||
hypothesis.GetManager().GetSentenceStats().StopTimeBuildHyp();
|
||||
}
|
||||
|
@ -75,9 +75,9 @@ Hypothesis(Manager& manager, InputType const& source, const TranslationOption &i
|
||||
* continue prevHypo by appending the phrases in transOpt
|
||||
*/
|
||||
Hypothesis::
|
||||
Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt)
|
||||
Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt, const WordsBitmap &bitmap)
|
||||
: m_prevHypo(&prevHypo)
|
||||
, m_sourceCompleted(prevHypo.m_sourceCompleted )
|
||||
, m_sourceCompleted(bitmap)
|
||||
, m_sourceInput(prevHypo.m_sourceInput)
|
||||
, m_currSourceWordsRange(transOpt.GetSourceWordsRange())
|
||||
, m_currTargetWordsRange(prevHypo.m_currTargetWordsRange.GetEndPos() + 1,
|
||||
@ -98,8 +98,6 @@ Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt)
|
||||
// that this hypothesis has already translated!
|
||||
assert(!m_sourceCompleted.Overlap(m_currSourceWordsRange));
|
||||
|
||||
//_hash_computed = false;
|
||||
m_sourceCompleted.SetValue(m_currSourceWordsRange.GetStartPos(), m_currSourceWordsRange.GetEndPos(), true);
|
||||
m_wordDeleted = transOpt.IsDeletionOption();
|
||||
m_manager.GetSentenceStats().AddCreated();
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class Hypothesis
|
||||
|
||||
protected:
|
||||
const Hypothesis* m_prevHypo; /*! backpointer to previous hypothesis (from which this one was created) */
|
||||
WordsBitmap m_sourceCompleted; /*! keeps track of which words have been translated so far */
|
||||
const WordsBitmap &m_sourceCompleted; /*! keeps track of which words have been translated so far */
|
||||
InputType const& m_sourceInput;
|
||||
WordsRange m_currSourceWordsRange; /*! source word positions of the last phrase that was used to create this hypothesis */
|
||||
WordsRange m_currTargetWordsRange; /*! target word positions of the last phrase that was used to create this hypothesis */
|
||||
@ -94,7 +94,7 @@ public:
|
||||
/*! used by initial seeding of the translation process */
|
||||
Hypothesis(Manager& manager, InputType const& source, const TranslationOption &initialTransOpt, const WordsBitmap &bitmap);
|
||||
/*! used when creating a new hypothesis using a translation option (phrase translation) */
|
||||
Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt);
|
||||
Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt, const WordsBitmap &bitmap);
|
||||
~Hypothesis();
|
||||
|
||||
void PrintHypothesis() const;
|
||||
|
@ -45,8 +45,9 @@ MockHypothesisGuard
|
||||
m_manager.reset(new Manager(m_ttask));
|
||||
|
||||
//Initial empty hypothesis
|
||||
WordsBitmap bitmap(m_sentence.get()->GetSize());
|
||||
m_manager->ResetSentenceStats(*m_sentence);
|
||||
m_hypothesis = new Hypothesis(*m_manager, *m_sentence, m_initialTransOpt);
|
||||
m_hypothesis = new Hypothesis(*m_manager, *m_sentence, m_initialTransOpt, bitmap);
|
||||
|
||||
//create the chain
|
||||
vector<Alignment>::const_iterator ai = alignments.begin();
|
||||
@ -59,7 +60,7 @@ MockHypothesisGuard
|
||||
m_targetPhrases.back().CreateFromString(Input, factors, *ti, NULL);
|
||||
m_toptions.push_back(new TranslationOption
|
||||
(wordsRange,m_targetPhrases.back()));
|
||||
m_hypothesis = new Hypothesis(*prevHypo, *m_toptions.back());
|
||||
m_hypothesis = new Hypothesis(*prevHypo, *m_toptions.back(), WordsBitmap(44));
|
||||
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ void SearchNormal::ExpandHypothesis(const Hypothesis &hypothesis,
|
||||
IFVERBOSE(2) {
|
||||
stats.StartTimeBuildHyp();
|
||||
}
|
||||
newHypo = new Hypothesis(hypothesis, transOpt);
|
||||
newHypo = new Hypothesis(hypothesis, transOpt, WordsBitmap(44));
|
||||
IFVERBOSE(2) {
|
||||
stats.StopTimeBuildHyp();
|
||||
}
|
||||
@ -329,7 +329,7 @@ void SearchNormal::ExpandHypothesis(const Hypothesis &hypothesis,
|
||||
IFVERBOSE(2) {
|
||||
stats.StartTimeBuildHyp();
|
||||
}
|
||||
newHypo = new Hypothesis(hypothesis, transOpt);
|
||||
newHypo = new Hypothesis(hypothesis, transOpt, WordsBitmap(44));
|
||||
if (newHypo==NULL) return;
|
||||
IFVERBOSE(2) {
|
||||
stats.StopTimeBuildHyp();
|
||||
|
Loading…
Reference in New Issue
Block a user