mosesdecoder/moses/InputPath.h
2013-07-07 02:14:51 +01:00

65 lines
1.6 KiB
C++

#pragma once
#include <map>
#include <iostream>
#include "Phrase.h"
#include "WordsRange.h"
namespace Moses
{
class PhraseDictionary;
class TargetPhraseCollection;
/** Each node contains
1. substring used to searching the phrase table
2. the source range it covers
3. a list of InputPath that it is a prefix of
This is for both sentence input, and confusion network/lattices
*/
class InputPath
{
friend std::ostream& operator<<(std::ostream& out, const InputPath &obj);
protected:
const InputPath *m_prevNode;
Phrase m_phrase;
WordsRange m_range;
std::map<const PhraseDictionary*, std::pair<const TargetPhraseCollection*, const void*> > m_targetPhrases;
public:
explicit InputPath()
: m_prevNode(NULL)
, m_range(NOT_FOUND, NOT_FOUND) {
}
InputPath(const Phrase &phrase, const WordsRange &range, const InputPath *prevNode)
:m_prevNode(prevNode)
,m_phrase(phrase)
,m_range(range) {
}
const Phrase &GetPhrase() const {
return m_phrase;
}
const WordsRange &GetWordsRange() const {
return m_range;
}
const InputPath *GetPrevNode() const {
return m_prevNode;
}
void SetTargetPhrases(const PhraseDictionary &phraseDictionary
, const TargetPhraseCollection *targetPhrases
, const void *ptNode) {
std::pair<const TargetPhraseCollection*, const void*> value(targetPhrases, ptNode);
m_targetPhrases[&phraseDictionary] = value;
}
const TargetPhraseCollection *GetTargetPhrases(const PhraseDictionary &phraseDictionary) const;
const void *GetPtNode(const PhraseDictionary &phraseDictionary) const;
};
};