mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-10-26 19:37:58 +03:00
create ChartTranslationOption class that store pointer to target phrase. Don't store target phrase itself. QUicker, but still not as quick as storing pointer to target phrase in hypo
This commit is contained in:
parent
8756ad8ffd
commit
46fce4029c
@ -49,7 +49,7 @@ protected:
|
||||
static ObjectPool<ChartHypothesis> s_objectPool;
|
||||
#endif
|
||||
|
||||
boost::shared_ptr<TargetPhrase> m_targetPhrase;
|
||||
boost::shared_ptr<ChartTranslationOption> m_targetPhrase;
|
||||
|
||||
WordsRange m_currSourceWordsRange;
|
||||
std::vector<const FFState*> m_ffStates; /*! stateful feature function states */
|
||||
@ -102,7 +102,7 @@ public:
|
||||
|
||||
//! Get the rule that created this hypothesis
|
||||
const TargetPhrase &GetCurrTargetPhrase()const {
|
||||
return *m_targetPhrase;
|
||||
return m_targetPhrase->GetPhrase();
|
||||
}
|
||||
|
||||
//! the source range that this hypothesis spans
|
||||
|
@ -136,7 +136,7 @@ void ChartManager::AddXmlChartOptions()
|
||||
i != xmlChartOptionsList.end(); ++i) {
|
||||
ChartTranslationOptions* opt = *i;
|
||||
|
||||
const TargetPhrase &targetPhrase = *opt->GetTargetPhrases()[0];
|
||||
const TargetPhrase &targetPhrase = opt->GetTargetPhrases()[0]->GetPhrase();
|
||||
const WordsRange &range = opt->GetSourceWordsRange();
|
||||
|
||||
RuleCubeItem* item = new RuleCubeItem( *opt, m_hypoStackColl );
|
||||
|
@ -25,6 +25,10 @@
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
ChartTranslationOption::ChartTranslationOption(const TargetPhrase &targetPhrase)
|
||||
:m_targetPhrase(targetPhrase)
|
||||
{
|
||||
}
|
||||
|
||||
ChartTranslationOptions::ChartTranslationOptions(const TargetPhraseCollection &targetPhraseColl,
|
||||
const StackVec &stackVec,
|
||||
@ -38,7 +42,7 @@ ChartTranslationOptions::ChartTranslationOptions(const TargetPhraseCollection &t
|
||||
for (iter = targetPhraseColl.begin(); iter != targetPhraseColl.end(); ++iter) {
|
||||
const TargetPhrase *origTP = *iter;
|
||||
|
||||
boost::shared_ptr<TargetPhrase> ptr(new TargetPhrase(*origTP));
|
||||
boost::shared_ptr<ChartTranslationOption> ptr(new ChartTranslationOption(*origTP));
|
||||
m_targetPhraseCollection.push_back(ptr);
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,29 @@
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
class ChartTranslationOption
|
||||
{
|
||||
protected:
|
||||
const TargetPhrase &m_targetPhrase;
|
||||
|
||||
public:
|
||||
ChartTranslationOption(const TargetPhrase &targetPhrase);
|
||||
|
||||
const TargetPhrase &GetPhrase() const
|
||||
{ return m_targetPhrase; }
|
||||
|
||||
const ScoreComponentCollection &GetScores() const
|
||||
{ return m_targetPhrase.GetScoreBreakdown(); }
|
||||
|
||||
};
|
||||
|
||||
/** Similar to a DottedRule, but contains a direct reference to a list
|
||||
* of translations and provdes an estimate of the best score. For a specific range in the input sentence
|
||||
*/
|
||||
class ChartTranslationOptions
|
||||
{
|
||||
public:
|
||||
typedef std::vector<boost::shared_ptr<TargetPhrase> > CollType;
|
||||
typedef std::vector<boost::shared_ptr<ChartTranslationOption> > CollType;
|
||||
|
||||
/** Constructor
|
||||
\param targetPhraseColl @todo dunno
|
||||
|
@ -65,7 +65,7 @@ RuleCubeItem::~RuleCubeItem()
|
||||
|
||||
void RuleCubeItem::EstimateScore()
|
||||
{
|
||||
m_score = m_translationDimension.GetTargetPhrase()->GetFutureScore();
|
||||
m_score = m_translationDimension.GetTargetPhrase()->GetPhrase().GetFutureScore();
|
||||
std::vector<HypothesisDimension>::const_iterator p;
|
||||
for (p = m_hypothesisDimensions.begin();
|
||||
p != m_hypothesisDimensions.end(); ++p) {
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
return m_pos+1 < m_orderedTargetPhrases.size();
|
||||
}
|
||||
|
||||
const boost::shared_ptr<TargetPhrase> &GetTargetPhrase() const {
|
||||
const boost::shared_ptr<ChartTranslationOption> &GetTargetPhrase() const {
|
||||
return m_orderedTargetPhrases[m_pos];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user