mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
minor cleanup
This commit is contained in:
parent
ae2e2c6d83
commit
d395737639
@ -183,11 +183,11 @@ void ChartParser::Create(const WordsRange &wordsRange, ChartParserCallback &to)
|
||||
void ChartParser::CreateInputPaths(const InputType &input)
|
||||
{
|
||||
size_t size = input.GetSize();
|
||||
m_targetPhrasesfromPt.resize(size);
|
||||
m_inputPathMatrix.resize(size);
|
||||
for (size_t phaseSize = 1; phaseSize <= size; ++phaseSize) {
|
||||
for (size_t startPos = 0; startPos < size - phaseSize + 1; ++startPos) {
|
||||
size_t endPos = startPos + phaseSize -1;
|
||||
vector<InputPath*> &vec = m_targetPhrasesfromPt[startPos];
|
||||
vector<InputPath*> &vec = m_inputPathMatrix[startPos];
|
||||
|
||||
WordsRange range(startPos, endPos);
|
||||
Phrase subphrase(input.GetSubString(WordsRange(startPos, endPos)));
|
||||
@ -203,7 +203,7 @@ void ChartParser::CreateInputPaths(const InputType &input)
|
||||
vec.push_back(node);
|
||||
}
|
||||
|
||||
m_phraseDictionaryQueue.push_back(node);
|
||||
//m_phraseDictionaryQueue.push_back(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -211,15 +211,15 @@ void ChartParser::CreateInputPaths(const InputType &input)
|
||||
const InputPath &ChartParser::GetInputPath(size_t startPos, size_t endPos) const
|
||||
{
|
||||
size_t offset = endPos - startPos;
|
||||
CHECK(offset < m_targetPhrasesfromPt[startPos].size());
|
||||
return *m_targetPhrasesfromPt[startPos][offset];
|
||||
CHECK(offset < m_inputPathMatrix[startPos].size());
|
||||
return *m_inputPathMatrix[startPos][offset];
|
||||
}
|
||||
|
||||
InputPath &ChartParser::GetInputPath(size_t startPos, size_t endPos)
|
||||
{
|
||||
size_t offset = endPos - startPos;
|
||||
CHECK(offset < m_targetPhrasesfromPt[startPos].size());
|
||||
return *m_targetPhrasesfromPt[startPos][offset];
|
||||
CHECK(offset < m_inputPathMatrix[startPos].size());
|
||||
return *m_inputPathMatrix[startPos][offset];
|
||||
}
|
||||
/*
|
||||
const Sentence &ChartParser::GetSentence() const {
|
||||
|
@ -73,10 +73,8 @@ private:
|
||||
std::vector<ChartRuleLookupManager*> m_ruleLookupManagers;
|
||||
InputType const& m_source; /**< source sentence to be translated */
|
||||
|
||||
InputPathList m_phraseDictionaryQueue;
|
||||
|
||||
typedef std::vector< std::vector<InputPath*> > TargetPhraseMatrix;
|
||||
TargetPhraseMatrix m_targetPhrasesfromPt; /*< contains translation options */
|
||||
typedef std::vector< std::vector<InputPath*> > InputPathMatrix;
|
||||
InputPathMatrix m_inputPathMatrix;
|
||||
|
||||
void CreateInputPaths(const InputType &input);
|
||||
InputPath &GetInputPath(size_t startPos, size_t endPos);
|
||||
|
@ -24,11 +24,11 @@ TranslationOptionCollectionConfusionNet::TranslationOptionCollectionConfusionNet
|
||||
CHECK(inputFeature);
|
||||
|
||||
size_t size = input.GetSize();
|
||||
m_targetPhrasesfromPt.resize(size);
|
||||
m_inputPathMatrix.resize(size);
|
||||
|
||||
// 1-word phrases
|
||||
for (size_t startPos = 0; startPos < size; ++startPos) {
|
||||
vector<InputPathList> &vec = m_targetPhrasesfromPt[startPos];
|
||||
vector<InputPathList> &vec = m_inputPathMatrix[startPos];
|
||||
vec.push_back(InputPathList());
|
||||
InputPathList &list = vec.back();
|
||||
|
||||
@ -60,7 +60,7 @@ TranslationOptionCollectionConfusionNet::TranslationOptionCollectionConfusionNet
|
||||
WordsRange range(startPos, endPos);
|
||||
const NonTerminalSet &labels = input.GetLabelSet(startPos, endPos);
|
||||
|
||||
vector<InputPathList> &vec = m_targetPhrasesfromPt[startPos];
|
||||
vector<InputPathList> &vec = m_inputPathMatrix[startPos];
|
||||
vec.push_back(InputPathList());
|
||||
InputPathList &list = vec.back();
|
||||
|
||||
@ -109,8 +109,8 @@ TranslationOptionCollectionConfusionNet::TranslationOptionCollectionConfusionNet
|
||||
InputPathList &TranslationOptionCollectionConfusionNet::GetInputPathList(size_t startPos, size_t endPos)
|
||||
{
|
||||
size_t offset = endPos - startPos;
|
||||
CHECK(offset < m_targetPhrasesfromPt[startPos].size());
|
||||
return m_targetPhrasesfromPt[startPos][offset];
|
||||
CHECK(offset < m_inputPathMatrix[startPos].size());
|
||||
return m_inputPathMatrix[startPos][offset];
|
||||
}
|
||||
|
||||
/* forcibly create translation option for a particular source word.
|
||||
|
@ -16,12 +16,12 @@ class ConfusionNet;
|
||||
class TranslationOptionCollectionConfusionNet : public TranslationOptionCollection
|
||||
{
|
||||
public:
|
||||
typedef std::vector< std::vector<InputPathList> > TargetPhraseMatrix;
|
||||
typedef std::vector< std::vector<InputPathList> > InputPathMatrix;
|
||||
|
||||
protected:
|
||||
bool m_useLegacy;
|
||||
|
||||
TargetPhraseMatrix m_targetPhrasesfromPt; /*< contains translation options */
|
||||
InputPathMatrix m_inputPathMatrix; /*< contains translation options */
|
||||
|
||||
InputPathList &GetInputPathList(size_t startPos, size_t endPos);
|
||||
void CheckLegacy();
|
||||
|
@ -36,11 +36,11 @@ TranslationOptionCollectionText::TranslationOptionCollectionText(Sentence const
|
||||
: TranslationOptionCollection(input, maxNoTransOptPerCoverage, translationOptionThreshold)
|
||||
{
|
||||
size_t size = input.GetSize();
|
||||
m_targetPhrasesfromPt.resize(size);
|
||||
m_inputPathMatrix.resize(size);
|
||||
for (size_t phaseSize = 1; phaseSize <= size; ++phaseSize) {
|
||||
for (size_t startPos = 0; startPos < size - phaseSize + 1; ++startPos) {
|
||||
size_t endPos = startPos + phaseSize -1;
|
||||
vector<InputPath*> &vec = m_targetPhrasesfromPt[startPos];
|
||||
vector<InputPath*> &vec = m_inputPathMatrix[startPos];
|
||||
|
||||
WordsRange range(startPos, endPos);
|
||||
Phrase subphrase(input.GetSubString(WordsRange(startPos, endPos)));
|
||||
@ -100,8 +100,8 @@ void TranslationOptionCollectionText::CreateXmlOptionsForRange(size_t startPosit
|
||||
InputPath &TranslationOptionCollectionText::GetInputPath(size_t startPos, size_t endPos)
|
||||
{
|
||||
size_t offset = endPos - startPos;
|
||||
CHECK(offset < m_targetPhrasesfromPt[startPos].size());
|
||||
return *m_targetPhrasesfromPt[startPos][offset];
|
||||
CHECK(offset < m_inputPathMatrix[startPos].size());
|
||||
return *m_inputPathMatrix[startPos][offset];
|
||||
}
|
||||
|
||||
void TranslationOptionCollectionText::CreateTranslationOptions()
|
||||
|
@ -38,10 +38,10 @@ class Sentence;
|
||||
class TranslationOptionCollectionText : public TranslationOptionCollection
|
||||
{
|
||||
public:
|
||||
typedef std::vector< std::vector<InputPath*> > TargetPhraseMatrix;
|
||||
typedef std::vector< std::vector<InputPath*> > InputPathMatrix;
|
||||
|
||||
protected:
|
||||
TargetPhraseMatrix m_targetPhrasesfromPt; /*< contains translation options */
|
||||
InputPathMatrix m_inputPathMatrix; /*< contains translation options */
|
||||
|
||||
InputPath &GetInputPath(size_t startPos, size_t endPos);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user