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

View File

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

View File

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

View File

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

View File

@ -48,10 +48,10 @@ void SourceGHKMTreeInputMatchFeature::EvaluateWithSourceContext(const InputType
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
if ( (treeInputLabels.find(lhsLabel) != treeInputLabels.end())
if ( (treeInputLabels.find(lhsLabel) != treeInputLabels.end())
&& (lhsLabel != m_output_default_nonterminal) ) {
// match
newScores[0] = 1.0;

View File

@ -68,7 +68,7 @@ Read(std::istream &in)
assert(topVertices.size() >= 1);
}
const std::vector<FactorType>& factorOrder = m_options->input.factor_order;
// Add <s> vertex.
@ -175,7 +175,7 @@ void ForestInput::FindTopVertices(Forest &forest,
std::back_inserter(topVertices));
}
void
void
ForestInput::
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)
size_t toleratedSize = 2*m_maxHypoStackSize-1;
// add in room for stack diversity
if (m_minHypoStackDiversity)
{
// so what happens if maxdistortion is negative?
toleratedSize += m_minHypoStackDiversity
<< m_manager.options()->reordering.max_distortion;
}
if (m_minHypoStackDiversity) {
// so what happens if maxdistortion is negative?
toleratedSize += m_minHypoStackDiversity
<< m_manager.options()->reordering.max_distortion;
}
if (m_hypos.size() > toleratedSize) {
PruneToSize(m_maxHypoStackSize);
} else {

View File

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

View File

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

View File

@ -64,8 +64,8 @@ MockHypothesisGuard
m_targetPhrases.back().CreateFromString(Input, factors, *ti, NULL);
m_toptions.push_back(new TranslationOption
(range,m_targetPhrases.back()));
m_hypothesis = new Hypothesis(*prevHypo, *m_toptions.back(), newBitmap,
m_manager->GetNextHypoId());
m_hypothesis = new Hypothesis(*prevHypo, *m_toptions.back(), newBitmap,
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
using namespace std;
if (m_options->input.xml_policy != XmlPassThrough) {
bool OK = ProcessAndStripXMLTags(*m_options, line,
m_xmlOptions,
bool OK = ProcessAndStripXMLTags(*m_options, line,
m_xmlOptions,
m_reorderingConstraint,
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)
aux_init_partial_translation(line);
line = Trim(line);
aux_interpret_sgml_markup(line); // for "<seg id=..." markup
aux_interpret_dlt(line); // some poorly documented cache-based stuff
@ -365,7 +365,7 @@ CreateFromString(vector<FactorType> const& FOrder, string const& phraseString)
}
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)
{
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&
GetDltMeta() const {

View File

@ -9,7 +9,7 @@
namespace Moses
{
class AllOptions;
class AllOptions;
namespace Syntax
{
namespace F2S
@ -20,8 +20,8 @@ class GlueRuleSynthesizer : public HyperTreeCreator
Word m_input_default_nonterminal;
Word m_output_default_nonterminal;
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
// hyperedge and add it to the rule trie.
void SynthesizeRule(const Forest::Hyperedge &);

View File

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

View File

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

View File

@ -77,7 +77,7 @@ TranslationTask
boost::shared_ptr<IOWrapper> const& ioWrapper)
: m_source(source) , m_ioWrapper(ioWrapper)
{
m_options = source->options();
m_options = source->options();
}
TranslationTask::~TranslationTask()
@ -104,7 +104,7 @@ TranslationTask
else if (algo == SyntaxS2T) {
// 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) {
typedef Syntax::S2T::EagerParserCallback Callback;
typedef Syntax::S2T::RecursiveCYKPlusParser<Callback> Parser;

View File

@ -245,7 +245,7 @@ Read(std::istream& in)
string line;
if (getline(in, line, '\n').eof())
return 0;
m_labelledSpans.clear();
ProcessAndStripXMLTags(*m_options, line, m_labelledSpans, m_xmlOptions);
@ -253,7 +253,7 @@ Read(std::istream& in)
stringstream strme;
strme << line << endl;
Sentence::Read(strme);
Sentence::Read(strme);
// size input chart
size_t sourceSize = GetSize();
@ -265,7 +265,7 @@ Read(std::istream& in)
// do source labels
vector<XMLParseOutput>::const_iterator iterLabel;
for (iterLabel = m_labelledSpans.begin();
for (iterLabel = m_labelledSpans.begin();
iterLabel != m_labelledSpans.end(); ++iterLabel) {
const XMLParseOutput &labelItem = *iterLabel;
const Range &range = labelItem.m_range;
@ -279,7 +279,7 @@ Read(std::istream& in)
for (size_t endPos = startPos; endPos < sourceSize; ++endPos) {
NonTerminalSet &list = GetLabelSet(startPos, endPos);
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;
}
void
void
TreeInput::
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::
AddChartLabel(size_t startPos, size_t endPos, const string &label)
{
const std::vector<FactorType>& fOrder = m_options->input.factor_order;
Word word(true);
const Factor *factor
= FactorCollection::Instance().AddFactor(Input, fOrder[0], label, true);
const Factor *factor
= FactorCollection::Instance().AddFactor(Input, fOrder[0], label, true);
// TODO - no factors
word.SetFactor(0, factor);
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 ">"
*/
bool
ProcessAndStripXMLTags(AllOptions const& opts, string &line,
ProcessAndStripXMLTags(AllOptions const& opts, string &line,
vector<XmlOption const*> &res,
ReorderingConstraint &reorderingConstraint,
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,
std::string &line, std::vector<XmlOption const*> &res,
ReorderingConstraint &reorderingConstraint,
std::vector< size_t > &walls,
ReorderingConstraint &reorderingConstraint,
std::vector< size_t > &walls,
std::vector< std::pair<size_t, std::string> > &placeholders);

View File

@ -70,7 +70,7 @@ public:
, startS(sS)
, endS(eS)
, count(0)
, pcfgScore(0.0)
, pcfgScore(0.0)
, l2rOrientation(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;
outFile.open(fileName.c_str());
typedef map<string,int>::const_iterator I;
@ -1234,7 +1235,7 @@ void writeUnknownWordLabel(const string & fileName) {
outFile.close();
}
void writePhraseOrientationPriors(const string &fileName)
void writePhraseOrientationPriors(const string &fileName)
{
ofstream outFile;
outFile.open(fileName.c_str());