mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 13:23:25 +03:00
separate class InputLatticeNode into seprate file
This commit is contained in:
parent
65b6429d84
commit
8123772b43
@ -471,6 +471,16 @@
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/moses/InputFileStream.h</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>InputLatticeNode.cpp</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/moses/InputLatticeNode.cpp</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>InputLatticeNode.h</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/moses/InputLatticeNode.h</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>InputType.cpp</name>
|
||||
<type>1</type>
|
||||
|
13
moses/InputLatticeNode.cpp
Normal file
13
moses/InputLatticeNode.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "InputLatticeNode.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
const TargetPhraseCollection *InputLatticeNode::GetTargetPhrases(const PhraseDictionary &phraseDictionary) const
|
||||
{
|
||||
std::map<const PhraseDictionary*, std::pair<const TargetPhraseCollection*, void*> >::const_iterator iter;
|
||||
iter = m_targetPhrases.find(&phraseDictionary);
|
||||
CHECK(iter != m_targetPhrases.end());
|
||||
return iter->second.first;
|
||||
}
|
||||
|
||||
}
|
56
moses/InputLatticeNode.h
Normal file
56
moses/InputLatticeNode.h
Normal file
@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#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 InputLatticeNode that it is a prefix of
|
||||
This is for both sentence input, and confusion network/lattices
|
||||
*/
|
||||
class InputLatticeNode
|
||||
{
|
||||
protected:
|
||||
const InputLatticeNode *m_prevNode;
|
||||
Phrase m_phrase;
|
||||
WordsRange m_range;
|
||||
std::map<const PhraseDictionary*, std::pair<const TargetPhraseCollection*, void*> > m_targetPhrases;
|
||||
|
||||
public:
|
||||
InputLatticeNode()
|
||||
: m_prevNode(NULL)
|
||||
, m_range(NOT_FOUND, NOT_FOUND)
|
||||
{}
|
||||
InputLatticeNode(const Phrase &phrase, const WordsRange &range, const InputLatticeNode *prevNode)
|
||||
:m_prevNode(prevNode)
|
||||
,m_phrase(phrase)
|
||||
,m_range(range) {
|
||||
}
|
||||
|
||||
const Phrase &GetPhrase() const {
|
||||
return m_phrase;
|
||||
}
|
||||
const WordsRange &GetWordsRange() const {
|
||||
return m_range;
|
||||
}
|
||||
|
||||
void SetTargetPhrases(const PhraseDictionary &phraseDictionary
|
||||
, const TargetPhraseCollection *targetPhrases
|
||||
, void *ptNode) {
|
||||
std::pair<const TargetPhraseCollection*, void*> value(targetPhrases, ptNode);
|
||||
m_targetPhrases[&phraseDictionary] = value;
|
||||
}
|
||||
const TargetPhraseCollection *GetTargetPhrases(const PhraseDictionary &phraseDictionary) const;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -34,20 +34,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include "DecodeStepTranslation.h"
|
||||
#include "DecodeGraph.h"
|
||||
#include "moses/FF/UnknownWordPenaltyProducer.h"
|
||||
#include "InputLatticeNode.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
const TargetPhraseCollection *InputLatticeNode::GetTargetPhrases(const PhraseDictionary &phraseDictionary) const
|
||||
{
|
||||
std::map<const PhraseDictionary*, std::pair<const TargetPhraseCollection*, void*> >::const_iterator iter;
|
||||
iter = m_targetPhrases.find(&phraseDictionary);
|
||||
CHECK(iter != m_targetPhrases.end());
|
||||
return iter->second.first;
|
||||
}
|
||||
|
||||
/** helper for pruning */
|
||||
bool CompareTranslationOption(const TranslationOption *a, const TranslationOption *b)
|
||||
{
|
||||
|
@ -43,49 +43,7 @@ class FactorMask;
|
||||
class Word;
|
||||
class DecodeGraph;
|
||||
class PhraseDictionary;
|
||||
|
||||
/** Each node contains
|
||||
1. substring used to searching the phrase table
|
||||
2. the source range it covers
|
||||
3. a list of InputLatticeNode that it is a prefix of
|
||||
This is for both sentence input, and confusion network/lattices
|
||||
*/
|
||||
class InputLatticeNode
|
||||
{
|
||||
protected:
|
||||
const InputLatticeNode *m_prevNode;
|
||||
Phrase m_phrase;
|
||||
WordsRange m_range;
|
||||
std::map<const PhraseDictionary*, std::pair<const TargetPhraseCollection*, void*> > m_targetPhrases;
|
||||
|
||||
public:
|
||||
InputLatticeNode()
|
||||
: m_prevNode(NULL)
|
||||
, m_range(NOT_FOUND, NOT_FOUND)
|
||||
{}
|
||||
InputLatticeNode(const Phrase &phrase, const WordsRange &range, const InputLatticeNode *prevNode)
|
||||
:m_prevNode(prevNode)
|
||||
,m_phrase(phrase)
|
||||
,m_range(range) {
|
||||
}
|
||||
|
||||
const Phrase &GetPhrase() const {
|
||||
return m_phrase;
|
||||
}
|
||||
const WordsRange &GetWordsRange() const {
|
||||
return m_range;
|
||||
}
|
||||
|
||||
void SetTargetPhrases(const PhraseDictionary &phraseDictionary
|
||||
, const TargetPhraseCollection *targetPhrases
|
||||
, void *ptNode) {
|
||||
std::pair<const TargetPhraseCollection*, void*> value(targetPhrases, ptNode);
|
||||
m_targetPhrases[&phraseDictionary] = value;
|
||||
}
|
||||
const TargetPhraseCollection *GetTargetPhrases(const PhraseDictionary &phraseDictionary) const;
|
||||
|
||||
};
|
||||
|
||||
class InputLatticeNode;
|
||||
|
||||
/** Contains all phrase translations applicable to current input type (a sentence or confusion network).
|
||||
* A key insight into efficient decoding is that various input
|
||||
|
@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#define moses_TranslationOptionCollectionText_h
|
||||
|
||||
#include "TranslationOptionCollection.h"
|
||||
#include "InputLatticeNode.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user