mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-29 06:52:34 +03:00
fixed a minor bug introduced by previous commit
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@2781 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
parent
c12c8d85dd
commit
9e7c97ddbc
@ -25,7 +25,9 @@ SearchNormal::SearchNormal(Manager& manager, const InputType &source, const Tran
|
||||
// only if constraint decoding (having to match a specified output)
|
||||
long sentenceID = source.GetTranslationId();
|
||||
m_constraint = staticData.GetConstrainingPhrase(sentenceID);
|
||||
VERBOSE(1, "Search constraint to output: " << *m_constraint<<endl);
|
||||
if (m_constraint) {
|
||||
VERBOSE(1, "Search constraint to output: " << *m_constraint<<endl);
|
||||
}
|
||||
|
||||
// initialize the stacks: create data structure and set limits
|
||||
std::vector < HypothesisStackNormal >::iterator iterStack;
|
||||
|
@ -338,35 +338,36 @@ bool StaticData::LoadData(Parameter *parameter)
|
||||
// Read in constraint decoding file, if provided
|
||||
if(m_parameter->GetParam("constraint").size()) {
|
||||
if (m_parameter->GetParam("search-algorithm").size() > 0
|
||||
&& Scan<size_t>(m_parameter->GetParam("search-algorithm")[0]) != 0) {
|
||||
cerr << "Can use -constraint only with stack-based search (-search-algorithm 0)" << endl;
|
||||
exit(1);
|
||||
}
|
||||
&& Scan<size_t>(m_parameter->GetParam("search-algorithm")[0]) != 0) {
|
||||
cerr << "Can use -constraint only with stack-based search (-search-algorithm 0)" << endl;
|
||||
exit(1);
|
||||
}
|
||||
m_constraintFileName = m_parameter->GetParam("constraint")[0];
|
||||
}
|
||||
|
||||
InputFileStream constraintFile(m_constraintFileName);
|
||||
InputFileStream constraintFile(m_constraintFileName);
|
||||
|
||||
|
||||
std::string line;
|
||||
|
||||
long sentenceID = -1;
|
||||
while (getline(constraintFile, line))
|
||||
{
|
||||
vector<string> vecStr = Tokenize(line, "\t");
|
||||
std::string line;
|
||||
|
||||
if (vecStr.size() == 1) {
|
||||
sentenceID++;
|
||||
Phrase phrase(Output);
|
||||
phrase.CreateFromString(GetOutputFactorOrder(), vecStr[0], GetFactorDelimiter());
|
||||
m_constraints.insert(make_pair(sentenceID,phrase));
|
||||
} else if (vecStr.size() == 2) {
|
||||
sentenceID = Scan<long>(vecStr[0]);
|
||||
Phrase phrase(Output);
|
||||
phrase.CreateFromString(GetOutputFactorOrder(), vecStr[1], GetFactorDelimiter());
|
||||
m_constraints.insert(make_pair(sentenceID,phrase));
|
||||
} else {
|
||||
assert(false);
|
||||
long sentenceID = -1;
|
||||
while (getline(constraintFile, line))
|
||||
{
|
||||
vector<string> vecStr = Tokenize(line, "\t");
|
||||
|
||||
if (vecStr.size() == 1) {
|
||||
sentenceID++;
|
||||
Phrase phrase(Output);
|
||||
phrase.CreateFromString(GetOutputFactorOrder(), vecStr[0], GetFactorDelimiter());
|
||||
m_constraints.insert(make_pair(sentenceID,phrase));
|
||||
}
|
||||
else if (vecStr.size() == 2) {
|
||||
sentenceID = Scan<long>(vecStr[0]);
|
||||
Phrase phrase(Output);
|
||||
phrase.CreateFromString(GetOutputFactorOrder(), vecStr[1], GetFactorDelimiter());
|
||||
m_constraints.insert(make_pair(sentenceID,phrase));
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user