mosesdecoder/contrib/other-builds/moses2/InputPaths.cpp

53 lines
1.1 KiB
C++
Raw Normal View History

2015-10-24 01:19:31 +03:00
/*
* InputPaths.cpp
*
* Created on: 23 Oct 2015
* Author: hieu
*/
2015-10-24 04:02:50 +03:00
#include <iostream>
2015-10-24 01:19:31 +03:00
#include "InputPaths.h"
#include "Phrase.h"
2015-10-26 00:20:55 +03:00
#include "System.h"
2015-10-25 18:58:26 +03:00
#include "moses/Range.h"
2015-10-24 01:19:31 +03:00
2015-10-24 04:02:50 +03:00
using namespace std;
InputPaths::~InputPaths() {
// TODO Auto-generated destructor stub
}
2015-11-03 17:20:10 +03:00
void InputPaths::Init(const PhraseImpl &input, const System &system)
2015-10-24 01:19:31 +03:00
{
2015-11-05 14:19:37 +03:00
size_t numPt = system.mappings.size();
2015-10-24 01:19:31 +03:00
size_t size = input.GetSize();
2015-11-06 21:50:25 +03:00
size_t maxLength = min(size, system.maxPhraseLength);
for (size_t phaseSize = 1; phaseSize <= maxLength; ++phaseSize) {
2015-10-24 01:19:31 +03:00
for (size_t startPos = 0; startPos < size - phaseSize + 1; ++startPos) {
size_t endPos = startPos + phaseSize -1;
SubPhrase subPhrase = input.GetSubPhrase(startPos, endPos);
2015-10-25 18:58:26 +03:00
Moses::Range range(startPos, endPos);
2015-10-24 04:02:50 +03:00
2015-10-24 15:31:43 +03:00
InputPath path(subPhrase, range, numPt);
2015-10-24 01:19:31 +03:00
m_inputPaths.push_back(path);
}
}
}
void InputPaths::DeleteUnusedPaths()
{
size_t ind = 0;
while (ind < m_inputPaths.size()) {
const InputPath &path = m_inputPaths[ind];
if (path.IsUsed()) {
m_inputPaths.erase(m_inputPaths.begin() + ind);
}
else {
++ind;
}
}
2015-10-24 01:19:31 +03:00
}