daily automatic beautifier

This commit is contained in:
MosesAdmin 2015-12-11 00:00:33 +00:00
parent a950605795
commit 739165c2b0
21 changed files with 69 additions and 69 deletions

View File

@ -47,21 +47,21 @@ ChartParserUnknown::~ChartParserUnknown()
// RemoveAllInColl(m_cacheTargetPhraseCollection); // RemoveAllInColl(m_cacheTargetPhraseCollection);
} }
AllOptions::ptr const& AllOptions::ptr const&
ChartParserUnknown:: ChartParserUnknown::
options() const options() const
{ {
return m_ttask.lock()->options(); return m_ttask.lock()->options();
} }
void void
ChartParserUnknown:: ChartParserUnknown::
Process(const Word &sourceWord, const Range &range, ChartParserCallback &to) Process(const Word &sourceWord, const Range &range, ChartParserCallback &to)
{ {
// unknown word, add as trans opt // unknown word, add as trans opt
const StaticData &staticData = StaticData::Instance(); const StaticData &staticData = StaticData::Instance();
const UnknownWordPenaltyProducer &unknownWordPenaltyProducer const UnknownWordPenaltyProducer &unknownWordPenaltyProducer
= UnknownWordPenaltyProducer::Instance(); = UnknownWordPenaltyProducer::Instance();
size_t isDigit = 0; size_t isDigit = 0;
if (options()->unk.drop) { if (options()->unk.drop) {
@ -101,8 +101,8 @@ Process(const Word &sourceWord, const Range &range, ChartParserCallback &to)
//const Word &sourceLHS = staticData.GetInputDefaultNonTerminal(); //const Word &sourceLHS = staticData.GetInputDefaultNonTerminal();
Word *targetLHS = new Word(true); Word *targetLHS = new Word(true);
targetLHS->CreateFromString(Output, options()->output.factor_order, targetLHS->CreateFromString(Output, options()->output.factor_order,
targetLHSStr, true); targetLHSStr, true);
UTIL_THROW_IF2(targetLHS->GetFactor(0) == NULL, "Null factor for target LHS"); UTIL_THROW_IF2(targetLHS->GetFactor(0) == NULL, "Null factor for target LHS");
// add to dictionary // add to dictionary
@ -142,8 +142,8 @@ Process(const Word &sourceWord, const Range &range, ChartParserCallback &to)
//float prob = iterLHS->second; //float prob = iterLHS->second;
Word *targetLHS = new Word(true); Word *targetLHS = new Word(true);
targetLHS->CreateFromString(Output, staticData.options().output.factor_order, targetLHS->CreateFromString(Output, staticData.options().output.factor_order,
targetLHSStr, true); targetLHSStr, true);
UTIL_THROW_IF2(targetLHS->GetFactor(0) == NULL, "Null factor for target LHS"); UTIL_THROW_IF2(targetLHS->GetFactor(0) == NULL, "Null factor for target LHS");
targetPhrase->GetScoreBreakdown().Assign(&unknownWordPenaltyProducer, unknownScore); targetPhrase->GetScoreBreakdown().Assign(&unknownWordPenaltyProducer, unknownScore);
@ -300,12 +300,12 @@ long ChartParser::GetTranslationId() const
} }
AllOptions::ptr const& AllOptions::ptr const&
ChartParser:: ChartParser::
options() const options() const
{ {
return m_ttask.lock()->options(); return m_ttask.lock()->options();
} }
} // namespace Moses } // namespace Moses

View File

@ -57,7 +57,7 @@ public:
private: private:
std::vector<Phrase*> m_unksrcs; std::vector<Phrase*> m_unksrcs;
std::list<TargetPhraseCollection::shared_ptr> m_cacheTargetPhraseCollection; std::list<TargetPhraseCollection::shared_ptr> m_cacheTargetPhraseCollection;
AllOptions::ptr const& options() const; AllOptions::ptr const& options() const;
}; };
class ChartParser class ChartParser
@ -79,7 +79,7 @@ public:
return m_unknown.GetUnknownSources(); return m_unknown.GetUnknownSources();
} }
AllOptions::ptr const& options() const; AllOptions::ptr const& options() const;
private: private:
ChartParserUnknown m_unknown; ChartParserUnknown m_unknown;

View File

@ -46,8 +46,8 @@ public:
const Column& GetColumn(size_t i) const { const Column& GetColumn(size_t i) const {
UTIL_THROW_IF2(i >= data.size(), UTIL_THROW_IF2(i >= data.size(),
"Out of bounds. Trying to access " << i "Out of bounds. Trying to access " << i
<< " when vector only contains " << data.size()); << " when vector only contains " << data.size());
return data[i]; return data[i];
} }
const Column& operator[](size_t i) const { const Column& operator[](size_t i) const {

View File

@ -569,8 +569,8 @@ void SoftSourceSyntacticConstraintsFeature::EvaluateWithSourceContext(const Inpu
} }
if ( treeInputLabelsLHS.size() == 0 ) { if ( treeInputLabelsLHS.size() == 0 ) {
scoreBreakdown.PlusEquals(this, scoreBreakdown.PlusEquals(this,
"LHSPAIR_" + targetLHS->GetString().as_string() + "_" "LHSPAIR_" + targetLHS->GetString().as_string() + "_"
+ m_output_default_nonterminal[0]->GetString().as_string(), + m_output_default_nonterminal[0]->GetString().as_string(),
1); 1);
if (!m_targetSourceLHSJointCountFile.empty()) { if (!m_targetSourceLHSJointCountFile.empty()) {
t2sLabelsScore = TransformScore(m_floor); t2sLabelsScore = TransformScore(m_floor);

View File

@ -48,10 +48,10 @@ void SourceGHKMTreeInputMatchFeature::EvaluateWithSourceContext(const InputType
const StaticData& staticData = StaticData::Instance(); const StaticData& staticData = StaticData::Instance();
std::vector<float> newScores(m_numScoreComponents,0.0); std::vector<float> newScores(m_numScoreComponents,0.0);
// m_numScoreComponents == 2 // first fires for matches, second for mismatches // m_numScoreComponents == 2 // first fires for matches, second for mismatches
if ( (treeInputLabels.find(lhsLabel) != treeInputLabels.end()) if ( (treeInputLabels.find(lhsLabel) != treeInputLabels.end())
&& (lhsLabel != m_output_default_nonterminal) ) { && (lhsLabel != m_output_default_nonterminal) ) {
// match // match
newScores[0] = 1.0; newScores[0] = 1.0;

View File

@ -68,7 +68,7 @@ Read(std::istream &in)
assert(topVertices.size() >= 1); assert(topVertices.size() >= 1);
} }
const std::vector<FactorType>& factorOrder = m_options->input.factor_order; const std::vector<FactorType>& factorOrder = m_options->input.factor_order;
// Add <s> vertex. // Add <s> vertex.
@ -175,7 +175,7 @@ void ForestInput::FindTopVertices(Forest &forest,
std::back_inserter(topVertices)); std::back_inserter(topVertices));
} }
void void
ForestInput:: ForestInput::
ParseHyperedgeLine(const std::string &line) ParseHyperedgeLine(const std::string &line)
{ {

View File

@ -74,13 +74,12 @@ pair<HypothesisStackNormal::iterator, bool> HypothesisStackNormal::Add(Hypothesi
// prune only if stack is twice as big as needed (lazy pruning) // prune only if stack is twice as big as needed (lazy pruning)
size_t toleratedSize = 2*m_maxHypoStackSize-1; size_t toleratedSize = 2*m_maxHypoStackSize-1;
// add in room for stack diversity // add in room for stack diversity
if (m_minHypoStackDiversity) if (m_minHypoStackDiversity) {
{ // so what happens if maxdistortion is negative?
// so what happens if maxdistortion is negative? toleratedSize += m_minHypoStackDiversity
toleratedSize += m_minHypoStackDiversity << m_manager.options()->reordering.max_distortion;
<< m_manager.options()->reordering.max_distortion; }
}
if (m_hypos.size() > toleratedSize) { if (m_hypos.size() > toleratedSize) {
PruneToSize(m_maxHypoStackSize); PruneToSize(m_maxHypoStackSize);
} else { } else {

View File

@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
namespace Moses namespace Moses
{ {
InputType::InputType(AllOptions::ptr const& opts, long translationId) InputType::InputType(AllOptions::ptr const& opts, long translationId)
: m_options(opts) : m_options(opts)
, m_translationId(translationId) , m_translationId(translationId)
{ {

View File

@ -190,10 +190,10 @@ public:
//! populate this InputType with data from in stream //! populate this InputType with data from in stream
virtual int virtual int
Read(std::istream& in) = 0; Read(std::istream& in) = 0;
// , // ,
// std::vector<FactorType> const& factorOrder, // std::vector<FactorType> const& factorOrder,
// AllOptions const& opts) =0; // AllOptions const& opts) =0;
//! Output debugging info to stream out //! Output debugging info to stream out
virtual void Print(std::ostream&) const =0; virtual void Print(std::ostream&) const =0;

View File

@ -64,8 +64,8 @@ MockHypothesisGuard
m_targetPhrases.back().CreateFromString(Input, factors, *ti, NULL); m_targetPhrases.back().CreateFromString(Input, factors, *ti, NULL);
m_toptions.push_back(new TranslationOption m_toptions.push_back(new TranslationOption
(range,m_targetPhrases.back())); (range,m_targetPhrases.back()));
m_hypothesis = new Hypothesis(*prevHypo, *m_toptions.back(), newBitmap, m_hypothesis = new Hypothesis(*prevHypo, *m_toptions.back(), newBitmap,
m_manager->GetNextHypoId()); m_manager->GetNextHypoId());
} }

View File

@ -151,11 +151,11 @@ aux_interpret_xml(std::string& line, std::vector<size_t> & xmlWalls,
// parse XML markup in translation line // parse XML markup in translation line
using namespace std; using namespace std;
if (m_options->input.xml_policy != XmlPassThrough) { if (m_options->input.xml_policy != XmlPassThrough) {
bool OK = ProcessAndStripXMLTags(*m_options, line, bool OK = ProcessAndStripXMLTags(*m_options, line,
m_xmlOptions, m_xmlOptions,
m_reorderingConstraint, m_reorderingConstraint,
xmlWalls, placeholders); xmlWalls, placeholders);
UTIL_THROW_IF2(!OK, "Unable to parse XML in line: " << line); UTIL_THROW_IF2(!OK, "Unable to parse XML in line: " << line);
} }
} }
@ -170,7 +170,7 @@ init(string line)
if (m_options->input.continue_partial_translation) if (m_options->input.continue_partial_translation)
aux_init_partial_translation(line); aux_init_partial_translation(line);
line = Trim(line); line = Trim(line);
aux_interpret_sgml_markup(line); // for "<seg id=..." markup aux_interpret_sgml_markup(line); // for "<seg id=..." markup
aux_interpret_dlt(line); // some poorly documented cache-based stuff aux_interpret_dlt(line); // some poorly documented cache-based stuff
@ -365,7 +365,7 @@ CreateFromString(vector<FactorType> const& FOrder, string const& phraseString)
} }
Sentence:: Sentence::
Sentence(AllOptions::ptr const& opts, size_t const transId, string stext) Sentence(AllOptions::ptr const& opts, size_t const transId, string stext)
: InputType(opts, transId) : InputType(opts, transId)
{ {
init(stext); init(stext);

View File

@ -115,7 +115,7 @@ public:
} }
void init(std::string line); void init(std::string line);
std::vector<std::map<std::string,std::string> > const& std::vector<std::map<std::string,std::string> > const&
GetDltMeta() const { GetDltMeta() const {

View File

@ -9,7 +9,7 @@
namespace Moses namespace Moses
{ {
class AllOptions; class AllOptions;
namespace Syntax namespace Syntax
{ {
namespace F2S namespace F2S
@ -20,8 +20,8 @@ class GlueRuleSynthesizer : public HyperTreeCreator
Word m_input_default_nonterminal; Word m_input_default_nonterminal;
Word m_output_default_nonterminal; Word m_output_default_nonterminal;
public: public:
GlueRuleSynthesizer(Moses::AllOptions const& opts, HyperTree &); GlueRuleSynthesizer(Moses::AllOptions const& opts, HyperTree &);
// Synthesize the minimal, monotone rule that can be applied to the given // Synthesize the minimal, monotone rule that can be applied to the given
// hyperedge and add it to the rule trie. // hyperedge and add it to the rule trie.
void SynthesizeRule(const Forest::Hyperedge &); void SynthesizeRule(const Forest::Hyperedge &);

View File

@ -12,7 +12,7 @@ namespace Syntax
namespace T2S namespace T2S
{ {
void void
GlueRuleSynthesizer:: GlueRuleSynthesizer::
SynthesizeRule(const InputTree::Node &node) SynthesizeRule(const InputTree::Node &node)
{ {

View File

@ -18,11 +18,11 @@ class GlueRuleSynthesizer : public RuleTrieCreator
{ {
Word m_output_default_nonterminal; Word m_output_default_nonterminal;
public: public:
GlueRuleSynthesizer(RuleTrie &trie, Word dflt_nonterm) GlueRuleSynthesizer(RuleTrie &trie, Word dflt_nonterm)
: m_ruleTrie(trie) : m_ruleTrie(trie)
, m_output_default_nonterminal(dflt_nonterm) , m_output_default_nonterminal(dflt_nonterm)
{} {}
// Synthesize the minimal, montone rule that can be applied to the given node // Synthesize the minimal, montone rule that can be applied to the given node
// and add it to the rule trie. // and add it to the rule trie.
void SynthesizeRule(const InputTree::Node &); void SynthesizeRule(const InputTree::Node &);

View File

@ -77,7 +77,7 @@ TranslationTask
boost::shared_ptr<IOWrapper> const& ioWrapper) boost::shared_ptr<IOWrapper> const& ioWrapper)
: m_source(source) , m_ioWrapper(ioWrapper) : m_source(source) , m_ioWrapper(ioWrapper)
{ {
m_options = source->options(); m_options = source->options();
} }
TranslationTask::~TranslationTask() TranslationTask::~TranslationTask()
@ -104,7 +104,7 @@ TranslationTask
else if (algo == SyntaxS2T) { else if (algo == SyntaxS2T) {
// new-style string-to-tree decoding (ask Phil Williams) // new-style string-to-tree decoding (ask Phil Williams)
S2TParsingAlgorithm algorithm = m_options->syntax.s2t_parsing_algo; S2TParsingAlgorithm algorithm = m_options->syntax.s2t_parsing_algo;
if (algorithm == RecursiveCYKPlus) { if (algorithm == RecursiveCYKPlus) {
typedef Syntax::S2T::EagerParserCallback Callback; typedef Syntax::S2T::EagerParserCallback Callback;
typedef Syntax::S2T::RecursiveCYKPlusParser<Callback> Parser; typedef Syntax::S2T::RecursiveCYKPlusParser<Callback> Parser;

View File

@ -245,7 +245,7 @@ Read(std::istream& in)
string line; string line;
if (getline(in, line, '\n').eof()) if (getline(in, line, '\n').eof())
return 0; return 0;
m_labelledSpans.clear(); m_labelledSpans.clear();
ProcessAndStripXMLTags(*m_options, line, m_labelledSpans, m_xmlOptions); ProcessAndStripXMLTags(*m_options, line, m_labelledSpans, m_xmlOptions);
@ -253,7 +253,7 @@ Read(std::istream& in)
stringstream strme; stringstream strme;
strme << line << endl; strme << line << endl;
Sentence::Read(strme); Sentence::Read(strme);
// size input chart // size input chart
size_t sourceSize = GetSize(); size_t sourceSize = GetSize();
@ -265,7 +265,7 @@ Read(std::istream& in)
// do source labels // do source labels
vector<XMLParseOutput>::const_iterator iterLabel; vector<XMLParseOutput>::const_iterator iterLabel;
for (iterLabel = m_labelledSpans.begin(); for (iterLabel = m_labelledSpans.begin();
iterLabel != m_labelledSpans.end(); ++iterLabel) { iterLabel != m_labelledSpans.end(); ++iterLabel) {
const XMLParseOutput &labelItem = *iterLabel; const XMLParseOutput &labelItem = *iterLabel;
const Range &range = labelItem.m_range; const Range &range = labelItem.m_range;
@ -279,7 +279,7 @@ Read(std::istream& in)
for (size_t endPos = startPos; endPos < sourceSize; ++endPos) { for (size_t endPos = startPos; endPos < sourceSize; ++endPos) {
NonTerminalSet &list = GetLabelSet(startPos, endPos); NonTerminalSet &list = GetLabelSet(startPos, endPos);
if (list.size() == 0 || ! only4empty ) { if (list.size() == 0 || ! only4empty ) {
AddChartLabel(startPos, endPos, m_options->syntax.input_default_non_terminal); AddChartLabel(startPos, endPos, m_options->syntax.input_default_non_terminal);
} }
} }
} }
@ -300,7 +300,7 @@ TranslationOptionCollection* TreeInput::CreateTranslationOptionCollection() cons
return NULL; return NULL;
} }
void void
TreeInput:: TreeInput::
AddChartLabel(size_t startPos, size_t endPos, const Word &label) AddChartLabel(size_t startPos, size_t endPos, const Word &label)
{ {
@ -324,14 +324,14 @@ AddChartLabel(size_t startPos, size_t endPos, const Word &label)
} }
} }
void void
TreeInput:: TreeInput::
AddChartLabel(size_t startPos, size_t endPos, const string &label) AddChartLabel(size_t startPos, size_t endPos, const string &label)
{ {
const std::vector<FactorType>& fOrder = m_options->input.factor_order; const std::vector<FactorType>& fOrder = m_options->input.factor_order;
Word word(true); Word word(true);
const Factor *factor const Factor *factor
= FactorCollection::Instance().AddFactor(Input, fOrder[0], label, true); = FactorCollection::Instance().AddFactor(Input, fOrder[0], label, true);
// TODO - no factors // TODO - no factors
word.SetFactor(0, factor); word.SetFactor(0, factor);
AddChartLabel(startPos, endPos, word); AddChartLabel(startPos, endPos, word);

View File

@ -159,7 +159,7 @@ vector<string> TokenizeXml(const string& str, const std::string& lbrackStr, cons
* \param rbrackStr xml tag's right bracket string, typically ">" * \param rbrackStr xml tag's right bracket string, typically ">"
*/ */
bool bool
ProcessAndStripXMLTags(AllOptions const& opts, string &line, ProcessAndStripXMLTags(AllOptions const& opts, string &line,
vector<XmlOption const*> &res, vector<XmlOption const*> &res,
ReorderingConstraint &reorderingConstraint, ReorderingConstraint &reorderingConstraint,
vector< size_t > &walls, vector< size_t > &walls,

View File

@ -32,8 +32,8 @@ std::vector<std::string> TokenizeXml(const std::string& str, const std::string&
bool ProcessAndStripXMLTags(AllOptions const& opts, bool ProcessAndStripXMLTags(AllOptions const& opts,
std::string &line, std::vector<XmlOption const*> &res, std::string &line, std::vector<XmlOption const*> &res,
ReorderingConstraint &reorderingConstraint, ReorderingConstraint &reorderingConstraint,
std::vector< size_t > &walls, std::vector< size_t > &walls,
std::vector< std::pair<size_t, std::string> > &placeholders); std::vector< std::pair<size_t, std::string> > &placeholders);

View File

@ -70,7 +70,7 @@ public:
, startS(sS) , startS(sS)
, endS(eS) , endS(eS)
, count(0) , count(0)
, pcfgScore(0.0) , pcfgScore(0.0)
, l2rOrientation(PhraseOrientation::REO_CLASS_UNKNOWN) , l2rOrientation(PhraseOrientation::REO_CLASS_UNKNOWN)
, r2lOrientation(PhraseOrientation::REO_CLASS_UNKNOWN) , r2lOrientation(PhraseOrientation::REO_CLASS_UNKNOWN)
{ } { }

View File

@ -1210,7 +1210,8 @@ void collectWordLabelCounts( SentenceAlignmentWithSyntax &sentence )
} }
} }
void writeUnknownWordLabel(const string & fileName) { void writeUnknownWordLabel(const string & fileName)
{
ofstream outFile; ofstream outFile;
outFile.open(fileName.c_str()); outFile.open(fileName.c_str());
typedef map<string,int>::const_iterator I; typedef map<string,int>::const_iterator I;
@ -1234,7 +1235,7 @@ void writeUnknownWordLabel(const string & fileName) {
outFile.close(); outFile.close();
} }
void writePhraseOrientationPriors(const string &fileName) void writePhraseOrientationPriors(const string &fileName)
{ {
ofstream outFile; ofstream outFile;
outFile.open(fileName.c_str()); outFile.open(fileName.c_str());