mosesdecoder/moses/InputPath.h

77 lines
2.1 KiB
C
Raw Normal View History

#pragma once
#include <map>
#include <iostream>
#include <list>
#include "Phrase.h"
#include "WordsRange.h"
namespace Moses
{
class PhraseDictionary;
class TargetPhraseCollection;
2013-07-09 01:47:02 +04:00
class ScoreComponentCollection;
class InputPath;
typedef std::list<InputPath*> InputPathList;
/** Each node contains
1. substring used to searching the phrase table
2. the source range it covers
2013-07-07 05:14:51 +04:00
3. a list of InputPath that it is a prefix of
This is for both sentence input, and confusion network/lattices
*/
2013-07-07 05:14:51 +04:00
class InputPath
{
2013-07-07 05:14:51 +04:00
friend std::ostream& operator<<(std::ostream& out, const InputPath &obj);
protected:
2013-07-07 05:14:51 +04:00
const InputPath *m_prevNode;
Phrase m_phrase;
WordsRange m_range;
2013-07-09 01:47:02 +04:00
const ScoreComponentCollection *m_inputScore;
std::map<const PhraseDictionary*, std::pair<const TargetPhraseCollection*, const void*> > m_targetPhrases;
2013-07-18 23:23:44 +04:00
// make a copy of the target phrase collection, rather than using the 1 given by the phrase dictionary
// must clean up yourself.
// used when pruning during placeholder processing
2013-07-18 23:39:15 +04:00
std::vector<TargetPhraseCollection> m_copiedSet;
2013-07-18 23:23:44 +04:00
public:
2013-07-07 05:14:51 +04:00
explicit InputPath()
: m_prevNode(NULL)
2013-07-09 01:47:02 +04:00
, m_range(NOT_FOUND, NOT_FOUND)
, m_inputScore(NULL) {
2013-07-05 02:38:18 +04:00
}
2013-07-09 01:47:02 +04:00
InputPath(const Phrase &phrase, const WordsRange &range, const InputPath *prevNode
,const ScoreComponentCollection *inputScore);
2013-07-09 01:47:02 +04:00
~InputPath();
const Phrase &GetPhrase() const {
return m_phrase;
}
const WordsRange &GetWordsRange() const {
return m_range;
}
2013-07-07 05:14:51 +04:00
const InputPath *GetPrevNode() const {
return m_prevNode;
}
void SetTargetPhrases(const PhraseDictionary &phraseDictionary
2013-07-05 02:38:18 +04:00
, const TargetPhraseCollection *targetPhrases
2013-07-18 23:23:44 +04:00
, const void *ptNode);
const TargetPhraseCollection *GetTargetPhrases(const PhraseDictionary &phraseDictionary) const;
2013-07-18 23:23:44 +04:00
// pointer to internal node in phrase-table. Since this is implementation dependent, this is a void*
const void *GetPtNode(const PhraseDictionary &phraseDictionary) const;
const ScoreComponentCollection *GetInputScore() const {
return m_inputScore;
}
};
};