mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-27 05:55:02 +03:00
create target phrases, not Translation Options, for XML. Can be used in both pb and scfg
This commit is contained in:
parent
d5d4051d8b
commit
8ffd53e321
@ -137,7 +137,6 @@ void ChartManager::AddXmlChartOptions()
|
||||
ChartTranslationOptions* opt = *i;
|
||||
|
||||
TargetPhrase &targetPhrase = *opt->GetTargetPhraseCollection().GetCollection()[0];
|
||||
targetPhrase.GetScoreBreakdown().Assign(staticData.GetWordPenaltyProducer(), -1);
|
||||
const WordsRange &range = opt->GetSourceWordsRange();
|
||||
|
||||
RuleCubeItem* item = new RuleCubeItem( *opt, m_hypoStackColl );
|
||||
|
@ -129,8 +129,15 @@ int Sentence::Read(std::istream& in,const std::vector<FactorType>& factorOrder)
|
||||
std::vector< std::pair<size_t, std::string> > placeholders;
|
||||
|
||||
if (staticData.GetXmlInputType() != XmlPassThrough) {
|
||||
int offset = 0;
|
||||
if (staticData.IsChart()) {
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
if (!ProcessAndStripXMLTags(line, m_xmlOptions, m_reorderingConstraint, xmlWalls, placeholders,
|
||||
staticData.GetXmlBrackets().first, staticData.GetXmlBrackets().second)) {
|
||||
offset,
|
||||
staticData.GetXmlBrackets().first,
|
||||
staticData.GetXmlBrackets().second)) {
|
||||
const string msg("Unable to parse XML in line: " + line);
|
||||
TRACE_ERR(msg << endl);
|
||||
throw runtime_error(msg);
|
||||
|
@ -151,6 +151,7 @@ vector<string> TokenizeXml(const string& str, const std::string& lbrackStr, cons
|
||||
*/
|
||||
bool ProcessAndStripXMLTags(string &line, vector<XmlOption*> &res, ReorderingConstraint &reorderingConstraint, vector< size_t > &walls,
|
||||
std::vector< std::pair<size_t, std::string> > &placeholders,
|
||||
int offset,
|
||||
const std::string& lbrackStr, const std::string& rbrackStr)
|
||||
{
|
||||
//parse XML markup in translation line
|
||||
@ -353,7 +354,7 @@ bool ProcessAndStripXMLTags(string &line, vector<XmlOption*> &res, ReorderingCon
|
||||
// convert from prob to log-prob
|
||||
float scoreValue = FloorScore(TransformScore(probValue));
|
||||
|
||||
WordsRange range(startPos,endPos-1); // span covered by phrase
|
||||
WordsRange range(startPos + offset,endPos-1 + offset); // span covered by phrase
|
||||
TargetPhrase targetPhrase;
|
||||
targetPhrase.CreateFromString(Output, outputFactorOrder,altTexts[i],factorDelimiter, NULL);
|
||||
|
||||
|
@ -32,6 +32,7 @@ std::vector<std::string> TokenizeXml(const std::string& str, const std::string&
|
||||
|
||||
bool ProcessAndStripXMLTags(std::string &line, std::vector<XmlOption*> &res, ReorderingConstraint &reorderingConstraint, std::vector< size_t > &walls,
|
||||
std::vector< std::pair<size_t, std::string> > &placeholders,
|
||||
int offset,
|
||||
const std::string& lbrackStr="<", const std::string& rbrackStr=">");
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user