2008-06-11 14:52:57 +04:00
|
|
|
// $Id$
|
|
|
|
// vim:tabstop=2
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
Moses - factored phrase-based language decoder
|
|
|
|
Copyright (C) 2006 University of Edinburgh
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
***********************************************************************/
|
|
|
|
|
2009-10-02 20:58:02 +04:00
|
|
|
#include <stdexcept>
|
2013-10-03 14:05:53 +04:00
|
|
|
#include <boost/algorithm/string.hpp>
|
2015-03-02 14:23:00 +03:00
|
|
|
#include <boost/foreach.hpp>
|
2009-10-02 20:58:02 +04:00
|
|
|
|
2008-06-11 14:52:57 +04:00
|
|
|
#include "Sentence.h"
|
|
|
|
#include "TranslationOptionCollectionText.h"
|
|
|
|
#include "StaticData.h"
|
2013-08-18 00:10:15 +04:00
|
|
|
#include "moses/FF/DynamicCacheBasedLanguageModel.h"
|
2014-01-13 18:41:52 +04:00
|
|
|
#include "moses/TranslationModel/PhraseDictionaryDynamicCacheBased.h"
|
2013-07-24 18:55:17 +04:00
|
|
|
#include "ChartTranslationOptions.h"
|
2008-06-11 14:52:57 +04:00
|
|
|
#include "Util.h"
|
2013-09-22 20:24:32 +04:00
|
|
|
#include "XmlOption.h"
|
2013-10-03 14:05:53 +04:00
|
|
|
#include "FactorCollection.h"
|
2015-12-07 19:07:11 +03:00
|
|
|
#include "TranslationTask.h"
|
2008-06-11 14:52:57 +04:00
|
|
|
|
2010-04-08 21:16:10 +04:00
|
|
|
using namespace std;
|
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
2010-01-28 15:12:57 +03:00
|
|
|
|
2015-03-02 14:23:00 +03:00
|
|
|
Sentence::
|
2015-12-10 02:05:00 +03:00
|
|
|
Sentence(AllOptions::ptr const& opts) : Phrase(0) , InputType(opts)
|
2010-04-08 21:16:10 +04:00
|
|
|
{
|
2015-12-10 06:17:36 +03:00
|
|
|
if (is_syntax(opts->search.algo))
|
|
|
|
m_defaultLabelSet.insert(opts->syntax.input_default_non_terminal);
|
2010-04-08 21:16:10 +04:00
|
|
|
}
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2015-03-02 14:23:00 +03:00
|
|
|
Sentence::
|
|
|
|
~Sentence()
|
2013-07-23 19:46:30 +04:00
|
|
|
{
|
2013-07-30 18:04:37 +04:00
|
|
|
RemoveAllInColl(m_xmlOptions);
|
2013-07-23 19:46:30 +04:00
|
|
|
}
|
|
|
|
|
2015-03-02 14:23:00 +03:00
|
|
|
void
|
|
|
|
Sentence::
|
|
|
|
aux_init_partial_translation(string& line)
|
2008-06-11 14:52:57 +04:00
|
|
|
{
|
2015-03-02 14:23:00 +03:00
|
|
|
string sourceCompletedStr;
|
|
|
|
int loc1 = line.find( "|||", 0 );
|
|
|
|
int loc2 = line.find( "|||", loc1 + 3 );
|
2015-05-02 13:45:24 +03:00
|
|
|
if (loc1 > -1 && loc2 > -1) {
|
|
|
|
m_initialTargetPhrase = Trim(line.substr(0, loc1));
|
|
|
|
string scov = Trim(line.substr(loc1 + 3, loc2 - loc1 - 3));
|
|
|
|
line = line.substr(loc2 + 3);
|
|
|
|
|
|
|
|
m_sourceCompleted.resize(scov.size());
|
|
|
|
int contiguous = 1;
|
|
|
|
for (size_t i = 0; i < scov.size(); ++i) {
|
|
|
|
if (sourceCompletedStr.at(i) == '1') {
|
|
|
|
m_sourceCompleted[i] = true;
|
|
|
|
if (contiguous) m_frontSpanCoveredLength++;
|
|
|
|
} else {
|
|
|
|
m_sourceCompleted[i] = false;
|
|
|
|
contiguous = 0;
|
|
|
|
}
|
2011-02-24 16:14:42 +03:00
|
|
|
}
|
2015-05-02 13:45:24 +03:00
|
|
|
}
|
2015-03-02 14:23:00 +03:00
|
|
|
}
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2015-03-02 14:23:00 +03:00
|
|
|
void
|
|
|
|
Sentence::
|
|
|
|
aux_interpret_sgml_markup(string& line)
|
|
|
|
{
|
2011-02-24 16:14:42 +03:00
|
|
|
// if sentences is specified as "<seg id=1> ... </seg>", extract id
|
2015-03-02 14:23:00 +03:00
|
|
|
typedef std::map<std::string, std::string> metamap;
|
|
|
|
metamap meta = ProcessAndStripSGML(line);
|
|
|
|
metamap::const_iterator i;
|
2015-04-30 08:05:11 +03:00
|
|
|
if ((i = meta.find("id")) != meta.end())
|
2015-03-02 14:23:00 +03:00
|
|
|
this->SetTranslationId(atol(i->second.c_str()));
|
2015-05-02 13:45:24 +03:00
|
|
|
if ((i = meta.find("docid")) != meta.end()) {
|
|
|
|
this->SetDocumentId(atol(i->second.c_str()));
|
|
|
|
this->SetUseTopicId(false);
|
|
|
|
this->SetUseTopicIdAndProb(false);
|
|
|
|
}
|
|
|
|
if ((i = meta.find("topic")) != meta.end()) {
|
|
|
|
vector<string> topic_params;
|
|
|
|
boost::split(topic_params, i->second, boost::is_any_of("\t "));
|
|
|
|
if (topic_params.size() == 1) {
|
|
|
|
this->SetTopicId(atol(topic_params[0].c_str()));
|
|
|
|
this->SetUseTopicId(true);
|
2015-03-02 14:23:00 +03:00
|
|
|
this->SetUseTopicIdAndProb(false);
|
2015-05-02 13:45:24 +03:00
|
|
|
} else {
|
|
|
|
this->SetTopicIdAndProb(topic_params);
|
|
|
|
this->SetUseTopicId(false);
|
|
|
|
this->SetUseTopicIdAndProb(true);
|
2012-07-26 20:32:50 +04:00
|
|
|
}
|
2015-05-02 13:45:24 +03:00
|
|
|
}
|
|
|
|
if ((i = meta.find("weight-setting")) != meta.end()) {
|
|
|
|
this->SetWeightSetting(i->second);
|
|
|
|
this->SetSpecifiesWeightSetting(true);
|
|
|
|
StaticData::Instance().SetWeightSetting(i->second);
|
|
|
|
// oh this is so horrible! Why does this have to be propagated globally?
|
|
|
|
// --- UG
|
|
|
|
} else this->SetSpecifiesWeightSetting(false);
|
2015-03-02 14:23:00 +03:00
|
|
|
}
|
2013-07-18 20:00:07 +04:00
|
|
|
|
2015-04-30 08:05:11 +03:00
|
|
|
void
|
2015-03-02 14:23:00 +03:00
|
|
|
Sentence::
|
|
|
|
aux_interpret_dlt(string& line) // whatever DLT means ... --- UG
|
|
|
|
{
|
|
|
|
using namespace std;
|
2015-04-30 08:05:11 +03:00
|
|
|
typedef map<string, string> str2str_map;
|
2015-10-24 03:37:50 +03:00
|
|
|
m_dlt_meta = ProcessAndStripDLT(line);
|
|
|
|
// what's happening below is most likely not thread-safe! UG
|
|
|
|
BOOST_FOREACH(str2str_map const& M, m_dlt_meta) {
|
2015-05-02 13:45:24 +03:00
|
|
|
str2str_map::const_iterator i,j;
|
|
|
|
if ((i = M.find("type")) != M.end()) {
|
|
|
|
j = M.find("id");
|
|
|
|
string id = j == M.end() ? "default" : j->second;
|
|
|
|
if (i->second == "cbtm") {
|
|
|
|
PhraseDictionaryDynamicCacheBased* cbtm;
|
|
|
|
cbtm = PhraseDictionaryDynamicCacheBased::InstanceNonConst(id);
|
|
|
|
if (cbtm) cbtm->ExecuteDlt(M);
|
|
|
|
}
|
|
|
|
if (i->second == "cblm") {
|
|
|
|
DynamicCacheBasedLanguageModel* cblm;
|
|
|
|
cblm = DynamicCacheBasedLanguageModel::InstanceNonConst(id);
|
|
|
|
if (cblm) cblm->ExecuteDlt(M);
|
|
|
|
}
|
2013-07-30 18:04:37 +04:00
|
|
|
}
|
2015-05-02 13:45:24 +03:00
|
|
|
}
|
2015-03-02 14:23:00 +03:00
|
|
|
}
|
2013-07-24 21:06:46 +04:00
|
|
|
|
2015-03-02 14:23:00 +03:00
|
|
|
void
|
|
|
|
Sentence::
|
2015-12-10 06:17:36 +03:00
|
|
|
aux_interpret_xml(std::string& line, std::vector<size_t> & xmlWalls,
|
2015-05-02 13:45:24 +03:00
|
|
|
std::vector<std::pair<size_t, std::string> >& placeholders)
|
|
|
|
{
|
|
|
|
// parse XML markup in translation line
|
2015-03-02 14:23:00 +03:00
|
|
|
using namespace std;
|
2015-12-10 06:17:36 +03:00
|
|
|
if (m_options->input.xml_policy != XmlPassThrough) {
|
2015-12-11 03:00:33 +03:00
|
|
|
bool OK = ProcessAndStripXMLTags(*m_options, line,
|
|
|
|
m_xmlOptions,
|
2015-05-02 13:45:24 +03:00
|
|
|
m_reorderingConstraint,
|
2016-06-07 20:36:30 +03:00
|
|
|
xmlWalls, placeholders,
|
|
|
|
*this);
|
2016-05-28 02:00:33 +03:00
|
|
|
if (!OK) {
|
|
|
|
TRACE_ERR("Unable to parse XML in line: " << line);
|
|
|
|
}
|
2015-05-02 13:45:24 +03:00
|
|
|
}
|
2015-03-02 14:23:00 +03:00
|
|
|
}
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2015-04-30 08:05:11 +03:00
|
|
|
void
|
2015-03-02 14:23:00 +03:00
|
|
|
Sentence::
|
2015-12-10 06:17:36 +03:00
|
|
|
init(string line)
|
2015-03-02 14:23:00 +03:00
|
|
|
{
|
|
|
|
using namespace std;
|
2013-07-18 20:00:07 +04:00
|
|
|
|
2015-03-02 14:23:00 +03:00
|
|
|
m_frontSpanCoveredLength = 0;
|
|
|
|
m_sourceCompleted.resize(0);
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2015-12-10 06:17:36 +03:00
|
|
|
if (m_options->input.continue_partial_translation)
|
2015-03-02 14:23:00 +03:00
|
|
|
aux_init_partial_translation(line);
|
2015-12-11 03:00:33 +03:00
|
|
|
|
2015-03-02 14:23:00 +03:00
|
|
|
line = Trim(line);
|
|
|
|
aux_interpret_sgml_markup(line); // for "<seg id=..." markup
|
|
|
|
aux_interpret_dlt(line); // some poorly documented cache-based stuff
|
2015-04-30 08:05:11 +03:00
|
|
|
|
2015-03-02 14:23:00 +03:00
|
|
|
// if sentences is specified as "<passthrough tag1=""/>"
|
2015-12-10 06:17:36 +03:00
|
|
|
if (m_options->output.PrintPassThrough ||m_options->nbest.include_passthrough) {
|
2015-05-02 13:45:24 +03:00
|
|
|
string pthru = PassthroughSGML(line,"passthrough");
|
|
|
|
this->SetPassthroughInformation(pthru);
|
|
|
|
}
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2015-03-02 14:23:00 +03:00
|
|
|
vector<size_t> xmlWalls;
|
|
|
|
vector<pair<size_t, string> >placeholders;
|
2015-12-10 06:17:36 +03:00
|
|
|
aux_interpret_xml(line, xmlWalls, placeholders);
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2015-12-10 06:17:36 +03:00
|
|
|
Phrase::CreateFromString(Input, m_options->input.factor_order, line, NULL);
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2015-03-02 14:23:00 +03:00
|
|
|
ProcessPlaceholders(placeholders);
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2015-12-10 06:17:36 +03:00
|
|
|
if (is_syntax(m_options->search.algo))
|
|
|
|
InitStartEndWord();
|
2015-04-30 08:05:11 +03:00
|
|
|
|
2015-03-02 14:23:00 +03:00
|
|
|
// now that we have final word positions in phrase (from
|
|
|
|
// CreateFromString), we can make input phrase objects to go with
|
|
|
|
// our XmlOptions and create TranslationOptions
|
|
|
|
|
|
|
|
// only fill the vector if we are parsing XML
|
2015-12-10 06:17:36 +03:00
|
|
|
if (m_options->input.xml_policy != XmlPassThrough) {
|
2015-05-02 13:45:24 +03:00
|
|
|
m_xmlCoverageMap.assign(GetSize(), false);
|
2015-12-04 22:43:37 +03:00
|
|
|
BOOST_FOREACH(XmlOption const* o, m_xmlOptions) {
|
2015-10-25 16:37:59 +03:00
|
|
|
Range const& r = o->range;
|
2015-05-02 13:45:24 +03:00
|
|
|
for(size_t j = r.GetStartPos(); j <= r.GetEndPos(); ++j)
|
|
|
|
m_xmlCoverageMap[j]=true;
|
2015-03-02 14:23:00 +03:00
|
|
|
}
|
2015-05-02 13:45:24 +03:00
|
|
|
}
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2013-05-31 15:28:57 +04:00
|
|
|
// reordering walls and zones
|
2015-03-02 14:23:00 +03:00
|
|
|
m_reorderingConstraint.InitializeWalls(GetSize());
|
2011-02-24 16:14:42 +03:00
|
|
|
|
|
|
|
// set reordering walls, if "-monotone-at-punction" is set
|
2015-12-10 06:17:36 +03:00
|
|
|
if (m_options->reordering.monotone_at_punct && GetSize()) {
|
2015-10-25 16:37:59 +03:00
|
|
|
Range r(0, GetSize()-1);
|
2015-05-02 13:45:24 +03:00
|
|
|
m_reorderingConstraint.SetMonotoneAtPunctuation(GetSubString(r));
|
|
|
|
}
|
2011-02-24 16:14:42 +03:00
|
|
|
|
|
|
|
// set walls obtained from xml
|
|
|
|
for(size_t i=0; i<xmlWalls.size(); i++)
|
2015-03-02 14:23:00 +03:00
|
|
|
if(xmlWalls[i] < GetSize()) // no buggy walls, please
|
|
|
|
m_reorderingConstraint.SetWall(xmlWalls[i], true);
|
2011-02-24 16:14:42 +03:00
|
|
|
m_reorderingConstraint.FinalizeWalls();
|
2015-04-30 08:05:11 +03:00
|
|
|
|
2015-03-02 14:23:00 +03:00
|
|
|
}
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2015-04-30 08:05:11 +03:00
|
|
|
int
|
2015-03-02 14:23:00 +03:00
|
|
|
Sentence::
|
2015-12-10 06:17:36 +03:00
|
|
|
Read(std::istream& in)
|
2015-03-02 14:23:00 +03:00
|
|
|
{
|
|
|
|
std::string line;
|
|
|
|
if (getline(in, line, '\n').eof())
|
|
|
|
return 0;
|
2015-12-10 06:17:36 +03:00
|
|
|
init(line);
|
2011-02-24 16:14:42 +03:00
|
|
|
return 1;
|
2008-06-11 14:52:57 +04:00
|
|
|
}
|
|
|
|
|
2015-04-30 08:05:11 +03:00
|
|
|
void
|
2015-03-02 14:23:00 +03:00
|
|
|
Sentence::
|
|
|
|
ProcessPlaceholders(const std::vector< std::pair<size_t, std::string> > &placeholders)
|
2013-07-18 20:00:07 +04:00
|
|
|
{
|
2015-12-10 06:17:36 +03:00
|
|
|
FactorType placeholderFactor = m_options->input.placeholder_factor;
|
2013-07-19 21:23:38 +04:00
|
|
|
if (placeholderFactor == NOT_FOUND) {
|
2013-07-18 20:00:44 +04:00
|
|
|
return;
|
2013-07-18 20:00:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < placeholders.size(); ++i) {
|
2013-07-18 20:00:44 +04:00
|
|
|
size_t pos = placeholders[i].first;
|
|
|
|
const string &str = placeholders[i].second;
|
|
|
|
const Factor *factor = FactorCollection::Instance().AddFactor(str);
|
|
|
|
Word &word = Phrase::GetWord(pos);
|
2013-07-19 21:23:38 +04:00
|
|
|
word[placeholderFactor] = factor;
|
2013-07-18 20:00:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
TranslationOptionCollection*
|
2015-03-15 23:38:31 +03:00
|
|
|
Sentence::
|
2015-03-30 03:20:17 +03:00
|
|
|
CreateTranslationOptionCollection(ttasksptr const& ttask) const
|
2008-06-11 14:52:57 +04:00
|
|
|
{
|
2015-04-30 08:05:11 +03:00
|
|
|
TranslationOptionCollection *rv
|
2015-12-12 21:04:13 +03:00
|
|
|
= new TranslationOptionCollectionText(ttask, *this);
|
2013-11-19 21:23:19 +04:00
|
|
|
assert(rv);
|
2011-02-24 16:14:42 +03:00
|
|
|
return rv;
|
2008-06-11 14:52:57 +04:00
|
|
|
}
|
|
|
|
void Sentence::Print(std::ostream& out) const
|
|
|
|
{
|
2012-07-03 19:25:04 +04:00
|
|
|
out<<*static_cast<Phrase const*>(this);
|
2008-06-11 14:52:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
bool Sentence::XmlOverlap(size_t startPos, size_t endPos) const
|
|
|
|
{
|
|
|
|
for (size_t pos = startPos; pos <= endPos ; pos++) {
|
|
|
|
if (pos < m_xmlCoverageMap.size() && m_xmlCoverageMap[pos]) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2008-06-11 14:52:57 +04:00
|
|
|
}
|
|
|
|
|
2013-08-16 00:14:04 +04:00
|
|
|
void Sentence::GetXmlTranslationOptions(std::vector <TranslationOption*> &list) const
|
2013-08-15 16:36:56 +04:00
|
|
|
{
|
2015-12-04 22:43:37 +03:00
|
|
|
for (std::vector<XmlOption const*>::const_iterator iterXMLOpts = m_xmlOptions.begin();
|
2013-08-15 16:36:56 +04:00
|
|
|
iterXMLOpts != m_xmlOptions.end(); ++iterXMLOpts) {
|
|
|
|
const XmlOption &xmlOption = **iterXMLOpts;
|
2015-10-25 16:37:59 +03:00
|
|
|
const Range &range = xmlOption.range;
|
2013-08-15 16:36:56 +04:00
|
|
|
const TargetPhrase &targetPhrase = xmlOption.targetPhrase;
|
|
|
|
TranslationOption *transOpt = new TranslationOption(range, targetPhrase);
|
|
|
|
list.push_back(transOpt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-24 16:14:42 +03:00
|
|
|
void Sentence::GetXmlTranslationOptions(std::vector <TranslationOption*> &list, size_t startPos, size_t endPos) const
|
|
|
|
{
|
|
|
|
//iterate over XmlOptions list, find exact source/target matches
|
|
|
|
|
2015-12-04 22:43:37 +03:00
|
|
|
for (std::vector<XmlOption const*>::const_iterator iterXMLOpts = m_xmlOptions.begin();
|
2013-07-23 19:46:30 +04:00
|
|
|
iterXMLOpts != m_xmlOptions.end(); ++iterXMLOpts) {
|
2013-07-30 18:04:37 +04:00
|
|
|
const XmlOption &xmlOption = **iterXMLOpts;
|
2015-10-25 16:37:59 +03:00
|
|
|
const Range &range = xmlOption.range;
|
2013-07-23 19:46:30 +04:00
|
|
|
|
|
|
|
if (startPos == range.GetStartPos()
|
2013-07-30 18:04:37 +04:00
|
|
|
&& endPos == range.GetEndPos()) {
|
2013-07-23 19:46:30 +04:00
|
|
|
const TargetPhrase &targetPhrase = xmlOption.targetPhrase;
|
|
|
|
|
|
|
|
TranslationOption *transOpt = new TranslationOption(range, targetPhrase);
|
|
|
|
list.push_back(transOpt);
|
2011-02-24 16:14:42 +03:00
|
|
|
}
|
|
|
|
}
|
2008-06-11 14:52:57 +04:00
|
|
|
}
|
|
|
|
|
2015-11-12 03:00:40 +03:00
|
|
|
std::vector <ChartTranslationOptions*>
|
2015-11-03 22:36:43 +03:00
|
|
|
Sentence::
|
2015-12-10 06:17:36 +03:00
|
|
|
GetXmlChartTranslationOptions() const
|
2013-07-24 18:55:17 +04:00
|
|
|
{
|
|
|
|
std::vector <ChartTranslationOptions*> ret;
|
|
|
|
|
|
|
|
// XML Options
|
|
|
|
// this code is a copy of the 1 in Sentence.
|
|
|
|
|
|
|
|
//only fill the vector if we are parsing XML
|
2015-12-10 06:17:36 +03:00
|
|
|
if (m_options->input.xml_policy != XmlPassThrough ) {
|
2013-07-30 18:04:37 +04:00
|
|
|
//TODO: needed to handle exclusive
|
|
|
|
//for (size_t i=0; i<GetSize(); i++) {
|
|
|
|
// m_xmlCoverageMap.push_back(false);
|
|
|
|
//}
|
2013-07-24 18:55:17 +04:00
|
|
|
|
2013-07-30 18:04:37 +04:00
|
|
|
//iterXMLOpts will be empty for XmlIgnore
|
|
|
|
//look at each column
|
2015-12-04 22:43:37 +03:00
|
|
|
for(std::vector<XmlOption const*>::const_iterator iterXmlOpts = m_xmlOptions.begin();
|
2013-07-30 18:04:37 +04:00
|
|
|
iterXmlOpts != m_xmlOptions.end(); iterXmlOpts++) {
|
2013-07-24 18:55:17 +04:00
|
|
|
|
2013-07-30 18:04:37 +04:00
|
|
|
const XmlOption &xmlOption = **iterXmlOpts;
|
|
|
|
TargetPhrase *targetPhrase = new TargetPhrase(xmlOption.targetPhrase);
|
2013-07-24 18:55:17 +04:00
|
|
|
|
2015-10-25 16:37:59 +03:00
|
|
|
Range *range = new Range(xmlOption.range);
|
2014-05-09 00:44:06 +04:00
|
|
|
StackVec emptyStackVec; // hmmm... maybe dangerous, but it is never consulted
|
2013-07-24 18:55:17 +04:00
|
|
|
|
2013-07-30 18:04:37 +04:00
|
|
|
TargetPhraseCollection *tpc = new TargetPhraseCollection;
|
|
|
|
tpc->Add(targetPhrase);
|
2013-07-24 18:55:17 +04:00
|
|
|
|
2013-07-30 18:04:37 +04:00
|
|
|
ChartTranslationOptions *transOpt = new ChartTranslationOptions(*tpc, emptyStackVec, *range, 0.0f);
|
|
|
|
ret.push_back(transOpt);
|
2013-07-24 18:55:17 +04:00
|
|
|
|
2013-07-30 18:04:37 +04:00
|
|
|
//TODO: needed to handle exclusive
|
|
|
|
//for(size_t j=transOpt->GetSourceWordsRange().GetStartPos(); j<=transOpt->GetSourceWordsRange().GetEndPos(); j++) {
|
|
|
|
// m_xmlCoverageMap[j]=true;
|
|
|
|
//}
|
|
|
|
}
|
2013-07-24 18:55:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-06-08 11:44:59 +04:00
|
|
|
void
|
2014-05-31 17:33:31 +04:00
|
|
|
Sentence::
|
2015-03-02 14:23:00 +03:00
|
|
|
CreateFromString(vector<FactorType> const& FOrder, string const& phraseString)
|
2009-06-01 00:32:18 +04:00
|
|
|
{
|
2015-03-02 14:23:00 +03:00
|
|
|
Phrase::CreateFromString(Input, FOrder, phraseString, NULL);
|
2009-06-01 00:32:18 +04:00
|
|
|
}
|
|
|
|
|
2015-03-02 14:23:00 +03:00
|
|
|
Sentence::
|
2015-12-11 03:00:33 +03:00
|
|
|
Sentence(AllOptions::ptr const& opts, size_t const transId, string stext)
|
2015-12-10 02:05:00 +03:00
|
|
|
: InputType(opts, transId)
|
2015-03-02 14:23:00 +03:00
|
|
|
{
|
2015-12-10 06:17:36 +03:00
|
|
|
init(stext);
|
2015-03-02 14:23:00 +03:00
|
|
|
}
|
2011-02-24 16:14:42 +03:00
|
|
|
|
2008-10-09 03:51:26 +04:00
|
|
|
}
|
|
|
|
|