rename vector<InputPath> to InputPathList. Pass regression tests

This commit is contained in:
Hieu Hoang 2013-07-09 14:19:35 +01:00
parent 9a22019aab
commit 5f9d0a85f5
11 changed files with 32 additions and 17 deletions

View File

@ -11,6 +11,9 @@ InputPath::InputPath(const Phrase &phrase, const WordsRange &range, const InputP
if (inputScore) {
m_inputScore = new ScoreComponentCollection(*inputScore);
}
else {
m_inputScore = NULL;
}
}
InputPath::~InputPath()

View File

@ -2,6 +2,7 @@
#include <map>
#include <iostream>
#include <list>
#include "Phrase.h"
#include "WordsRange.h"
@ -12,6 +13,9 @@ class PhraseDictionary;
class TargetPhraseCollection;
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

View File

@ -69,11 +69,11 @@ void PhraseDictionary::SetFeaturesToApply()
}
}
void PhraseDictionary::SetTargetPhraseFromPtMatrix(const std::vector<InputPath*> &phraseDictionaryQueue) const
void PhraseDictionary::SetTargetPhraseFromPtMatrix(const InputPathList &phraseDictionaryQueue) const
{
// UTIL_THROW(util::Exception, "SetTargetPhraseFromPtMatrix() not implemented");
for (size_t i = 0; i < phraseDictionaryQueue.size(); ++i) {
InputPath &node = *phraseDictionaryQueue[i];
InputPathList::const_iterator iter;
for (iter = phraseDictionaryQueue.begin(); iter != phraseDictionaryQueue.end(); ++iter) {
InputPath &node = **iter;
const Phrase &phrase = node.GetPhrase();
const TargetPhraseCollection *targetPhrases = this->GetTargetPhraseCollection(phrase);

View File

@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "moses/TargetPhrase.h"
#include "moses/TargetPhraseCollection.h"
#include "moses/DecodeFeature.h"
#include "moses/InputPath.h"
namespace Moses
{
@ -47,7 +48,6 @@ class InputType;
class WordsRange;
class ChartCellCollectionBase;
class ChartRuleLookupManager;
class InputPath;
/**
* Abstract base class for phrase dictionaries (tables).
@ -94,7 +94,7 @@ public:
void SetParameter(const std::string& key, const std::string& value);
virtual void SetTargetPhraseFromPtMatrix(const std::vector<InputPath*> &phraseDictionaryQueue) const;
virtual void SetTargetPhraseFromPtMatrix(const InputPathList &phraseDictionaryQueue) const;
protected:
size_t m_tableLimit;

View File

@ -134,11 +134,11 @@ void PhraseDictionaryMemory::SortAndPrune()
}
}
void PhraseDictionaryMemory::SetTargetPhraseFromPtMatrix(const std::vector<InputPath*> &phraseDictionaryQueue) const
void PhraseDictionaryMemory::SetTargetPhraseFromPtMatrix(const InputPathList &phraseDictionaryQueue) const
{
// UTIL_THROW(util::Exception, "SetTargetPhraseFromPtMatrix() not implemented");
for (size_t i = 0; i < phraseDictionaryQueue.size(); ++i) {
InputPath &node = *phraseDictionaryQueue[i];
InputPathList::const_iterator iter;
for (iter = phraseDictionaryQueue.begin(); iter != phraseDictionaryQueue.end(); ++iter) {
InputPath &node = **iter;
const Phrase &phrase = node.GetPhrase();
const InputPath *prevNode = node.GetPrevNode();

View File

@ -53,7 +53,7 @@ public:
const InputType &,
const ChartCellCollectionBase &);
void SetTargetPhraseFromPtMatrix(const std::vector<InputPath*> &phraseDictionaryQueue) const;
void SetTargetPhraseFromPtMatrix(const InputPathList &phraseDictionaryQueue) const;
TO_STRING();

View File

@ -98,12 +98,13 @@ void PhraseDictionaryOnDisk::InitializeForInput(InputType const& source)
m_implementation.reset(obj);
}
void PhraseDictionaryOnDisk::SetTargetPhraseFromPtMatrix(const std::vector<InputPath*> &phraseDictionaryQueue) const
void PhraseDictionaryOnDisk::SetTargetPhraseFromPtMatrix(const InputPathList &phraseDictionaryQueue) const
{
OnDiskPt::OnDiskWrapper &wrapper = const_cast<OnDiskPt::OnDiskWrapper&>(GetImplementation());
for (size_t i = 0; i < phraseDictionaryQueue.size(); ++i) {
InputPath &node = *phraseDictionaryQueue[i];
InputPathList::const_iterator iter;
for (iter = phraseDictionaryQueue.begin(); iter != phraseDictionaryQueue.end(); ++iter) {
InputPath &node = **iter;
const Phrase &phrase = node.GetPhrase();
const InputPath *prevNode = node.GetPrevNode();

View File

@ -77,7 +77,7 @@ public:
const ChartCellCollectionBase &);
virtual void InitializeForInput(InputType const& source);
void SetTargetPhraseFromPtMatrix(const std::vector<InputPath*> &phraseDictionaryQueue) const;
void SetTargetPhraseFromPtMatrix(const InputPathList &phraseDictionaryQueue) const;
};

View File

@ -69,7 +69,7 @@ protected:
const size_t m_maxNoTransOptPerCoverage; /*< maximum number of translation options per input span */
const float m_translationOptionThreshold; /*< threshold for translation options with regard to best option for input span */
std::vector<Phrase*> m_unksrcs;
std::vector<InputPath*> m_phraseDictionaryQueue;
InputPathList m_phraseDictionaryQueue;
TranslationOptionCollection(InputType const& src, size_t maxNoTransOptPerCoverage,
float translationOptionThreshold);

View File

@ -3,6 +3,7 @@
#define moses_TranslationOptionCollectionConfusionNet_h
#include "TranslationOptionCollection.h"
#include "InputPath.h"
namespace Moses
{
@ -14,6 +15,9 @@ class ConfusionNet;
*/
class TranslationOptionCollectionConfusionNet : public TranslationOptionCollection
{
protected:
typedef std::vector< std::vector<InputPathList> > TargetPhraseMatrix;
public:
TranslationOptionCollectionConfusionNet(const ConfusionNet &source, size_t maxNoTransOptPerCoverage, float translationOptionThreshold);
@ -23,6 +27,9 @@ public:
, size_t endPosition
, bool adhereTableLimit
, size_t graphInd);
protected:
};
}

View File

@ -40,7 +40,7 @@ TranslationOptionCollectionText::TranslationOptionCollectionText(Sentence const
for (size_t phaseSize = 1; phaseSize <= size; ++phaseSize) {
for (size_t startPos = 0; startPos < size - phaseSize + 1; ++startPos) {
size_t endPos = startPos + phaseSize -1;
std::vector<InputPath*> &vec = m_targetPhrasesfromPt[startPos];
vector<InputPath*> &vec = m_targetPhrasesfromPt[startPos];
Phrase subphrase(input.GetSubString(WordsRange(startPos, endPos)));
WordsRange range(startPos, endPos);