From f38976aba07e0dbca74f9b824b28add486889b2a Mon Sep 17 00:00:00 2001 From: MosesAdmin Date: Mon, 2 Nov 2015 00:00:37 +0000 Subject: [PATCH] daily automatic beautifier --- moses-cmd/LatticeMBRGrid.cpp | 4 +- moses/AlignmentInfo.cpp | 20 ++-- moses/AlignmentInfo.h | 2 +- moses/ChartCell.cpp | 11 +- moses/ChartHypothesisCollection.h | 2 +- moses/ChartParser.cpp | 12 +-- moses/ConfusionNet.h | 2 +- moses/DecodeStepTranslation.cpp | 34 +++--- moses/DecodeStepTranslation.h | 10 +- moses/ForestInput.h | 4 +- moses/Hypothesis.cpp | 16 +-- moses/Hypothesis.h | 18 ++-- moses/IOWrapper.cpp | 2 +- moses/Incremental.cpp | 20 ++-- moses/InputType.h | 4 +- moses/LM/IRST.h | 8 +- moses/Manager.cpp | 102 +++++++++--------- moses/Manager.h | 2 +- moses/MockHypothesis.cpp | 12 +-- moses/Parameter.cpp | 2 +- moses/Parameter.h | 11 +- moses/ScoreComponentCollection.cpp | 16 +-- moses/ScoreComponentCollection.h | 4 +- moses/Sentence.cpp | 10 +- moses/Sentence.h | 6 +- moses/StaticData.cpp | 44 ++++---- moses/StaticData.h | 18 ++-- moses/TabbedSentence.cpp | 4 +- moses/TabbedSentence.h | 2 +- ...ranslationOptionCollectionConfusionNet.cpp | 8 +- moses/TranslationTask.cpp | 4 +- moses/TreeInput.cpp | 4 +- moses/TreeInput.h | 4 +- moses/WordLattice.cpp | 4 +- moses/WordLattice.h | 8 +- 35 files changed, 216 insertions(+), 218 deletions(-) diff --git a/moses-cmd/LatticeMBRGrid.cpp b/moses-cmd/LatticeMBRGrid.cpp index 356f90525..a8ecf5f00 100644 --- a/moses-cmd/LatticeMBRGrid.cpp +++ b/moses-cmd/LatticeMBRGrid.cpp @@ -202,8 +202,8 @@ int main(int argc, char* argv[]) << " ||| "; vector mbrBestHypo = doLatticeMBR(manager,nBestList); manager.OutputBestHypo(mbrBestHypo, lineCount, - manager.options().output.ReportSegmentation, - manager.options().output.ReportAllFactors, + manager.options().output.ReportSegmentation, + manager.options().output.ReportAllFactors, cout); } } diff --git a/moses/AlignmentInfo.cpp b/moses/AlignmentInfo.cpp index 15e8b6d52..fb86be207 100644 --- a/moses/AlignmentInfo.cpp +++ b/moses/AlignmentInfo.cpp @@ -106,9 +106,9 @@ std::set AlignmentInfo::GetAlignmentsForTarget(size_t targetPos) const } -bool -compare_target(std::pair const* a, - std::pair const* b) +bool +compare_target(std::pair const* a, + std::pair const* b) { if(a->second < b->second) return true; if(a->second == b->second) return (a->first < b->first); @@ -116,29 +116,29 @@ compare_target(std::pair const* a, } -std::vector< const std::pair* > +std::vector< const std::pair* > AlignmentInfo:: GetSortedAlignments(WordAlignmentSort SortOrder) const { std::vector< const std::pair* > ret; - + CollType::const_iterator iter; for (iter = m_collection.begin(); iter != m_collection.end(); ++iter) { const std::pair &alignPair = *iter; ret.push_back(&alignPair); } - + switch (SortOrder) { case NoSort: break; - + case TargetOrder: std::sort(ret.begin(), ret.end(), compare_target); break; - + default: - UTIL_THROW(util::Exception, "Unknown word alignment sort option: " - << SortOrder); + UTIL_THROW(util::Exception, "Unknown word alignment sort option: " + << SortOrder); } return ret; diff --git a/moses/AlignmentInfo.h b/moses/AlignmentInfo.h index 50a4bf550..c2c98388f 100644 --- a/moses/AlignmentInfo.h +++ b/moses/AlignmentInfo.h @@ -83,7 +83,7 @@ public: return m_collection.size(); } - std::vector< const std::pair* > + std::vector< const std::pair* > GetSortedAlignments(WordAlignmentSort SortOrder) const; std::vector GetSourceIndex2PosMap() const; diff --git a/moses/ChartCell.cpp b/moses/ChartCell.cpp index 89108ebf9..2de890740 100644 --- a/moses/ChartCell.cpp +++ b/moses/ChartCell.cpp @@ -65,12 +65,11 @@ bool ChartCell::AddHypothesis(ChartHypothesis *hypo) { const Word &targetLHS = hypo->GetTargetLHS(); MapType::iterator m = m_hypoColl.find(targetLHS); - if (m == m_hypoColl.end()) - { - std::pair - e(targetLHS, ChartHypothesisCollection(m_manager.options())); - m = m_hypoColl.insert(e).first; - } + if (m == m_hypoColl.end()) { + std::pair + e(targetLHS, ChartHypothesisCollection(m_manager.options())); + m = m_hypoColl.insert(e).first; + } return m->second.AddHypothesis(hypo, m_manager); } diff --git a/moses/ChartHypothesisCollection.h b/moses/ChartHypothesisCollection.h index 9d682d76d..b0980abe3 100644 --- a/moses/ChartHypothesisCollection.h +++ b/moses/ChartHypothesisCollection.h @@ -29,7 +29,7 @@ namespace Moses { class ChartSearchGraphWriter; - class AllOptions; +class AllOptions; //! functor to compare (chart) hypotheses by (descending) score class ChartHypothesisScoreOrderer diff --git a/moses/ChartParser.cpp b/moses/ChartParser.cpp index 19aeb8515..9b75a92c3 100644 --- a/moses/ChartParser.cpp +++ b/moses/ChartParser.cpp @@ -108,12 +108,12 @@ void ChartParserUnknown::Process(const Word &sourceWord, const Range &range, Cha targetPhrase->EvaluateInIsolation(*unksrc); AllOptions const& opts = staticData.options(); - if (!opts.output.detailed_tree_transrep_filepath.empty() || - opts.nbest.print_trees || staticData.GetTreeStructure() != NULL) { - std::string prop = "[ "; - prop += (*targetLHS)[0]->GetString().as_string() + " "; - prop += sourceWord[0]->GetString().as_string() + " ]"; - targetPhrase->SetProperty("Tree", prop); + if (!opts.output.detailed_tree_transrep_filepath.empty() || + opts.nbest.print_trees || staticData.GetTreeStructure() != NULL) { + std::string prop = "[ "; + prop += (*targetLHS)[0]->GetString().as_string() + " "; + prop += sourceWord[0]->GetString().as_string() + " ]"; + targetPhrase->SetProperty("Tree", prop); } // chart rule diff --git a/moses/ConfusionNet.h b/moses/ConfusionNet.h index 834148864..ef3e0294b 100644 --- a/moses/ConfusionNet.h +++ b/moses/ConfusionNet.h @@ -68,7 +68,7 @@ public: virtual void Print(std::ostream&) const; int Read(std::istream& in,const std::vector& factorOrder, - AllOptions const& opts); + AllOptions const& opts); Phrase GetSubString(const Range&) const; //TODO not defined std::string GetStringRep(const std::vector factorsToPrint) const; //TODO not defined diff --git a/moses/DecodeStepTranslation.cpp b/moses/DecodeStepTranslation.cpp index 25d160626..c4a4fd0c4 100644 --- a/moses/DecodeStepTranslation.cpp +++ b/moses/DecodeStepTranslation.cpp @@ -100,14 +100,14 @@ void DecodeStepTranslation::Process(const TranslationOption &inputPartialTranslO } } -void +void DecodeStepTranslation:: ProcessInitialTranslation(InputType const& source, - PartialTranslOptColl &outputPartialTranslOptColl, - size_t startPos, size_t endPos, - bool adhereTableLimit, - InputPath const& inputPath, - TargetPhraseCollection::shared_ptr phraseColl) const + PartialTranslOptColl &outputPartialTranslOptColl, + size_t startPos, size_t endPos, + bool adhereTableLimit, + InputPath const& inputPath, + TargetPhraseCollection::shared_ptr phraseColl) const { const PhraseDictionary* phraseDictionary = GetPhraseDictionaryFeature(); const size_t tableLimit = phraseDictionary->GetTableLimit(); @@ -117,12 +117,12 @@ ProcessInitialTranslation(InputType const& source, if (phraseColl != NULL) { IFVERBOSE(3) { if(source.GetType() == SentenceInput) - TRACE_ERR("[" << source.GetSubString(range) << "; " - << startPos << "-" << endPos << "]\n"); + TRACE_ERR("[" << source.GetSubString(range) << "; " + << startPos << "-" << endPos << "]\n"); else TRACE_ERR("[" << startPos << "-" << endPos << "]" << std::endl); } - + TargetPhraseCollection::const_iterator iterTargetPhrase, iterEnd; iterEnd = (!adhereTableLimit || tableLimit == 0 || phraseColl->GetSize() < tableLimit) ? phraseColl->end() : phraseColl->begin() + tableLimit; @@ -140,13 +140,13 @@ ProcessInitialTranslation(InputType const& source, } } -void +void DecodeStepTranslation:: ProcessInitialTransLEGACY(InputType const& source, - PartialTranslOptColl &outputPartialTranslOptColl, - size_t startPos, size_t endPos, - bool adhereTableLimit, - InputPathList const& inputPathList) const + PartialTranslOptColl &outputPartialTranslOptColl, + size_t startPos, size_t endPos, + bool adhereTableLimit, + InputPathList const& inputPathList) const { const PhraseDictionary* phraseDictionary = GetPhraseDictionaryFeature(); const size_t tableLimit = phraseDictionary->GetTableLimit(); @@ -158,12 +158,12 @@ ProcessInitialTransLEGACY(InputType const& source, if (phraseColl != NULL) { IFVERBOSE(3) { if(source.GetType() == SentenceInput) - TRACE_ERR("[" << source.GetSubString(range) << "; " - << startPos << "-" << endPos << "]\n"); + TRACE_ERR("[" << source.GetSubString(range) << "; " + << startPos << "-" << endPos << "]\n"); else TRACE_ERR("[" << startPos << "-" << endPos << "]" << std::endl); } - + const std::vector &sourcePhrases = phraseColl->GetSourcePhrases(); TargetPhraseCollection::const_iterator iterTargetPhrase, iterEnd; diff --git a/moses/DecodeStepTranslation.h b/moses/DecodeStepTranslation.h index 25af693eb..d9c293b86 100644 --- a/moses/DecodeStepTranslation.h +++ b/moses/DecodeStepTranslation.h @@ -61,12 +61,12 @@ public: , TargetPhraseCollection::shared_ptr phraseColl) const; // legacy - void + void ProcessInitialTransLEGACY(InputType const& source, - PartialTranslOptColl &outputPartialTranslOptColl, - size_t startPos, size_t endPos, - bool adhereTableLimit, - InputPathList const& inputPathList) const; + PartialTranslOptColl &outputPartialTranslOptColl, + size_t startPos, size_t endPos, + bool adhereTableLimit, + InputPathList const& inputPathList) const; void ProcessLEGACY(const TranslationOption &inputPartialTranslOpt , const DecodeStep &decodeStep diff --git a/moses/ForestInput.h b/moses/ForestInput.h index 61cb08d83..5080b3f5f 100644 --- a/moses/ForestInput.h +++ b/moses/ForestInput.h @@ -28,9 +28,9 @@ public: } //! populate this InputType with data from in stream - virtual int + virtual int Read(std::istream& in, - std::vector const& factorOrder, + std::vector const& factorOrder, AllOptions const& opts); //! Output debugging info to stream out diff --git a/moses/Hypothesis.cpp b/moses/Hypothesis.cpp index 151d05583..c43aed01e 100644 --- a/moses/Hypothesis.cpp +++ b/moses/Hypothesis.cpp @@ -380,16 +380,16 @@ OutputAlignment(std::ostream &out) const edges.push_back(currentHypo); currentHypo = currentHypo->GetPrevHypo(); } - + OutputAlignment(out, edges, m_manager.options().output.WA_SortOrder); } void Hypothesis:: -OutputAlignment(ostream &out, - vector const& edges, - WordAlignmentSort waso) +OutputAlignment(ostream &out, + vector const& edges, + WordAlignmentSort waso) { size_t targetOffset = 0; @@ -409,7 +409,7 @@ void Hypothesis:: OutputAlignment(ostream &out, const AlignmentInfo &ai, size_t sourceOffset, size_t targetOffset, - WordAlignmentSort waso) + WordAlignmentSort waso) { typedef std::vector< const std::pair* > AlignVec; AlignVec alignments = ai.GetSortedAlignments(waso); @@ -417,8 +417,8 @@ OutputAlignment(ostream &out, const AlignmentInfo &ai, AlignVec::const_iterator it; for (it = alignments.begin(); it != alignments.end(); ++it) { const std::pair &alignment = **it; - out << alignment.first + sourceOffset << "-" - << alignment.second + targetOffset << " "; + out << alignment.first + sourceOffset << "-" + << alignment.second + targetOffset << " "; } } @@ -608,7 +608,7 @@ OutputLocalWordAlignment(vector& dest) const using namespace std; Range const& src = this->GetCurrSourceWordsRange(); Range const& trg = this->GetCurrTargetWordsRange(); - + WordAlignmentSort waso = m_manager.options().output.WA_SortOrder; vector const* > a = this->GetCurrTargetPhrase().GetAlignTerm().GetSortedAlignments(waso); diff --git a/moses/Hypothesis.h b/moses/Hypothesis.h index c1d6c4598..59d03d4bd 100644 --- a/moses/Hypothesis.h +++ b/moses/Hypothesis.h @@ -251,18 +251,18 @@ public: return m_transOpt; } - void + void OutputAlignment(std::ostream &out) const; - static void - OutputAlignment(std::ostream &out, - const std::vector &edges, - WordAlignmentSort waso); + static void + OutputAlignment(std::ostream &out, + const std::vector &edges, + WordAlignmentSort waso); - static void - OutputAlignment(std::ostream &out, const Moses::AlignmentInfo &ai, - size_t sourceOffset, size_t targetOffset, - WordAlignmentSort waso); + static void + OutputAlignment(std::ostream &out, const Moses::AlignmentInfo &ai, + size_t sourceOffset, size_t targetOffset, + WordAlignmentSort waso); void OutputInput(std::ostream& os) const; static void OutputInput(std::vector& map, const Hypothesis* hypo); diff --git a/moses/IOWrapper.cpp b/moses/IOWrapper.cpp index 8a83547e7..2e91e7382 100644 --- a/moses/IOWrapper.cpp +++ b/moses/IOWrapper.cpp @@ -95,7 +95,7 @@ IOWrapper::IOWrapper() m_look_back = staticData.options().context.look_back; m_inputType = staticData.options().input.input_type; - + UTIL_THROW_IF2((m_look_ahead || m_look_back) && m_inputType != SentenceInput, "Context-sensitive decoding currently works only with sentence input."); diff --git a/moses/Incremental.cpp b/moses/Incremental.cpp index c004cda5d..15ef1ad71 100644 --- a/moses/Incremental.cpp +++ b/moses/Incremental.cpp @@ -320,15 +320,15 @@ void Manager::OutputNBest(OutputCollector *collector) const OutputNBestList(collector, *completed_nbest_, m_source.GetTranslationId()); } -void +void Manager:: -OutputNBestList(OutputCollector *collector, - std::vector const& nbest, - long translationId) const +OutputNBestList(OutputCollector *collector, + std::vector const& nbest, + long translationId) const { const StaticData &staticData = StaticData::Instance(); - const std::vector &outputFactorOrder - = staticData.GetOutputFactorOrder(); + const std::vector &outputFactorOrder + = staticData.GetOutputFactorOrder(); std::ostringstream out; // wtf? copied from the original OutputNBestList @@ -337,13 +337,13 @@ OutputNBestList(OutputCollector *collector, } Phrase outputPhrase; ScoreComponentCollection features; - for (std::vector::const_iterator i = nbest.begin(); + for (std::vector::const_iterator i = nbest.begin(); i != nbest.end(); ++i) { Incremental::PhraseAndFeatures(*i, outputPhrase, features); // and UTIL_THROW_IF2(outputPhrase.GetSize() < 2, "Output phrase should have contained at least 2 words " - << "(beginning and end-of-sentence)"); + << "(beginning and end-of-sentence)"); outputPhrase.RemoveWord(0); outputPhrase.RemoveWord(outputPhrase.GetSize() - 1); @@ -359,7 +359,7 @@ OutputNBestList(OutputCollector *collector, collector->Write(translationId, out.str()); } -void +void Manager:: OutputDetailedTranslationReport(OutputCollector *collector) const { @@ -525,7 +525,7 @@ void Manager::OutputBestHypo(OutputCollector *collector, search::Applied applied VERBOSE(1,"BEST TRANSLATION: " << outPhrase << "[total=" << applied.GetScore() << "]" << std::endl); } -void +void Manager:: OutputBestNone(OutputCollector *collector, long translationId) const { diff --git a/moses/InputType.h b/moses/InputType.h index 9f3777530..9501f8c8a 100644 --- a/moses/InputType.h +++ b/moses/InputType.h @@ -184,8 +184,8 @@ public: } //! populate this InputType with data from in stream - virtual int - Read(std::istream& in, + virtual int + Read(std::istream& in, std::vector const& factorOrder, AllOptions const& opts) =0; diff --git a/moses/LM/IRST.h b/moses/LM/IRST.h index c84df493c..820031faf 100644 --- a/moses/LM/IRST.h +++ b/moses/LM/IRST.h @@ -97,11 +97,11 @@ public: virtual void CalcScore(const Phrase &phrase, float &fullScore, float &ngramScore, size_t &oovCount) const; virtual FFState *EvaluateWhenApplied(const Hypothesis &hypo, const FFState *ps, ScoreComponentCollection *out) const; -/* - virtual FFState *EvaluateWhenApplied(const ChartHypothesis& cur_hypo, int featureID, ScoreComponentCollection *accumulator) const; + /* + virtual FFState *EvaluateWhenApplied(const ChartHypothesis& cur_hypo, int featureID, ScoreComponentCollection *accumulator) const; - virtual FFState *EvaluateWhenApplied(const Syntax::SHyperedge& hyperedge, int featureID, ScoreComponentCollection *accumulator) const; -*/ + virtual FFState *EvaluateWhenApplied(const Syntax::SHyperedge& hyperedge, int featureID, ScoreComponentCollection *accumulator) const; + */ void InitializeForInput(ttasksptr const& ttask); void CleanUpAfterSentenceProcessing(const InputType& source); diff --git a/moses/Manager.cpp b/moses/Manager.cpp index 7e34302ba..5f349ea72 100644 --- a/moses/Manager.cpp +++ b/moses/Manager.cpp @@ -100,8 +100,8 @@ Manager::GetSource() const void Manager::Decode() { - std::cerr << options().nbest.nbest_size << " " - << options().nbest.enabled << " " << std::endl; + std::cerr << options().nbest.nbest_size << " " + << options().nbest.enabled << " " << std::endl; // initialize statistics ResetSentenceStats(m_source); @@ -128,8 +128,8 @@ void Manager::Decode() // some reporting on how long this took IFVERBOSE(1) { GetSentenceStats().StopTimeCollectOpts(); - TRACE_ERR("Line "<< m_source.GetTranslationId() - << ": Collecting options took " + TRACE_ERR("Line "<< m_source.GetTranslationId() + << ": Collecting options took " << GetSentenceStats().GetTimeCollectOpts() << " seconds at " << __FILE__ << ":" << __LINE__ << endl); } @@ -1118,10 +1118,10 @@ void Manager::OutputSearchGraphAsSLF(long translationId, std::ostream &outputSea } -void -OutputSearchNode(AllOptions const& opts, long translationId, - std::ostream &outputSearchGraphStream, - SearchGraphNode const& searchNode) +void +OutputSearchNode(AllOptions const& opts, long translationId, + std::ostream &outputSearchGraphStream, + SearchGraphNode const& searchNode) { const vector &outputFactorOrder = StaticData::Instance().GetOutputFactorOrder(); bool extendedFormat = opts.output.SearchGraphExtended.size(); @@ -1377,7 +1377,7 @@ void Manager::SerializeSearchGraphPB( } #endif -void +void Manager:: OutputSearchGraph(long translationId, std::ostream &out) const { @@ -1388,12 +1388,12 @@ OutputSearchGraph(long translationId, std::ostream &out) const } } -void +void Manager:: GetForwardBackwardSearchGraph ( std::map< int, bool >* pConnected, - std::vector* pConnectedList, - std::map >* pOutgoingHyps, + std::vector* pConnectedList, + std::map >* pOutgoingHyps, vector< float>* pFwdBwdScores) const { std::map < int, bool > &connected = *pConnected; @@ -1401,8 +1401,8 @@ GetForwardBackwardSearchGraph std::map < int, int > forward; std::map < int, double > forwardScore; - std::map < const Hypothesis*, set > & outgoingHyps - = *pOutgoingHyps; + std::map < const Hypothesis*, set > & outgoingHyps + = *pOutgoingHyps; vector< float> & estimatedScores = *pFwdBwdScores; // *** find connected hypotheses *** @@ -1411,8 +1411,8 @@ GetForwardBackwardSearchGraph // ** compute best forward path for each hypothesis *** // // forward cost of hypotheses on final stack is 0 - const std::vector < HypothesisStack* > &hypoStackColl - = m_search->GetHypothesisStacks(); + const std::vector < HypothesisStack* > &hypoStackColl + = m_search->GetHypothesisStacks(); const HypothesisStack &finalStack = *hypoStackColl.back(); HypothesisStack::const_iterator iterHypo; for (iterHypo = finalStack.begin() ; iterHypo != finalStack.end() ; ++iterHypo) { @@ -1531,12 +1531,12 @@ void Manager::OutputBest(OutputCollector *collector) const // const PARAM_VEC *params = staticData.GetParameter().GetParam("print-id"); if (options().output.PrintID) { - out << translationId << " "; - } - - // VN : I put back the code for OutputPassthroughInformation - if (options().output.PrintPassThrough) { - OutputPassthroughInformation(out, bestHypo); + out << translationId << " "; + } + + // VN : I put back the code for OutputPassthroughInformation + if (options().output.PrintPassThrough) { + OutputPassthroughInformation(out, bestHypo); } // end of add back @@ -1589,8 +1589,8 @@ void Manager::OutputBest(OutputCollector *collector) const } else { //Lattice MBR decoding vector mbrBestHypo = doLatticeMBR(*this,nBestList); - OutputBestHypo(mbrBestHypo, translationId, - options().output.ReportSegmentation, + OutputBestHypo(mbrBestHypo, translationId, + options().output.ReportSegmentation, options().output.ReportAllFactors, out); IFVERBOSE(2) { PrintUserTime("finished Lattice MBR decoding"); @@ -1614,7 +1614,7 @@ void Manager::OutputBest(OutputCollector *collector) const else { const TrellisPath &mbrBestHypo = doMBR(nBestList); OutputBestHypo(mbrBestHypo, translationId, - options().output.ReportSegmentation, + options().output.ReportSegmentation, options().output.ReportAllFactors, out); OutputAlignment(m_alignmentOut, mbrBestHypo); IFVERBOSE(2) { @@ -1650,8 +1650,8 @@ void Manager::OutputNBest(OutputCollector *collector) const ostringstream out; CalcNBest(options().nbest.nbest_size, nBestList, options().nbest.only_distinct); - OutputNBest(out, nBestList, - staticData.GetOutputFactorOrder(), + OutputNBest(out, nBestList, + staticData.GetOutputFactorOrder(), m_source.GetTranslationId(), options().output.ReportSegmentation); collector->Write(m_source.GetTranslationId(), out.str()); @@ -1659,12 +1659,12 @@ void Manager::OutputNBest(OutputCollector *collector) const } -void +void Manager:: OutputNBest(std::ostream& out, - const Moses::TrellisPathList &nBestList, - const std::vector& outputFactorOrder, - long translationId, char reportSegmentation) const + const Moses::TrellisPathList &nBestList, + const std::vector& outputFactorOrder, + long translationId, char reportSegmentation) const { const StaticData &staticData = StaticData::Instance(); NBestOptions const& nbo = options().nbest; @@ -1681,8 +1681,8 @@ OutputNBest(std::ostream& out, out << translationId << " ||| "; for (int currEdge = (int)edges.size() - 1 ; currEdge >= 0 ; currEdge--) { const Hypothesis &edge = *edges[currEdge]; - OutputSurface(out, edge, outputFactorOrder, reportSegmentation, - reportAllFactors); + OutputSurface(out, edge, outputFactorOrder, reportSegmentation, + reportAllFactors); } out << " |||"; @@ -1741,11 +1741,11 @@ OutputNBest(std::ostream& out, /*** * print surface factor only for the given phrase */ -void +void Manager:: -OutputSurface(std::ostream &out, const Hypothesis &edge, - const std::vector &outputFactorOrder, - char reportSegmentation, bool reportAllFactors) const +OutputSurface(std::ostream &out, const Hypothesis &edge, + const std::vector &outputFactorOrder, + char reportSegmentation, bool reportAllFactors) const { UTIL_THROW_IF2(outputFactorOrder.size() == 0, "Must specific at least 1 output factor"); @@ -1820,10 +1820,10 @@ OutputSurface(std::ostream &out, const Hypothesis &edge, } } -void +void Manager:: -OutputAlignment(ostream &out, const AlignmentInfo &ai, - size_t sourceOffset, size_t targetOffset) const +OutputAlignment(ostream &out, const AlignmentInfo &ai, + size_t sourceOffset, size_t targetOffset) const { typedef std::vector< const std::pair* > AlignVec; AlignVec alignments = ai.GetSortedAlignments(options().output.WA_SortOrder); @@ -1831,13 +1831,13 @@ OutputAlignment(ostream &out, const AlignmentInfo &ai, AlignVec::const_iterator it; for (it = alignments.begin(); it != alignments.end(); ++it) { const std::pair &alignment = **it; - out << alignment.first + sourceOffset << "-" - << alignment.second + targetOffset << " "; + out << alignment.first + sourceOffset << "-" + << alignment.second + targetOffset << " "; } - + } -void +void Manager:: OutputInput(std::ostream& os, const Hypothesis* hypo) const { @@ -1883,9 +1883,9 @@ void Manager::OutputLatticeSamples(OutputCollector *collector) const TrellisPathList latticeSamples; ostringstream out; CalcLatticeSamples(staticData.GetLatticeSamplesSize(), latticeSamples); - OutputNBest(out,latticeSamples, - staticData.GetOutputFactorOrder(), - m_source.GetTranslationId(), + OutputNBest(out,latticeSamples, + staticData.GetOutputFactorOrder(), + m_source.GetTranslationId(), options().output.ReportSegmentation); collector->Write(m_source.GetTranslationId(), out.str()); } @@ -2075,11 +2075,11 @@ void Manager::OutputBestHypo(const std::vector& mbrBestHypo, long /*trans out << endl; } -void +void Manager:: -OutputBestHypo(const Moses::TrellisPath &path, long /*translationId*/, - char reportSegmentation, bool reportAllFactors, - std::ostream &out) const +OutputBestHypo(const Moses::TrellisPath &path, long /*translationId*/, + char reportSegmentation, bool reportAllFactors, + std::ostream &out) const { const std::vector &edges = path.GetEdges(); diff --git a/moses/Manager.h b/moses/Manager.h index 720dee38b..59c070c83 100644 --- a/moses/Manager.h +++ b/moses/Manager.h @@ -131,7 +131,7 @@ protected: // nbest mutable std::ostringstream m_latticeNBestOut; mutable std::ostringstream m_alignmentOut; - public: +public: void OutputNBest(std::ostream& out , const Moses::TrellisPathList &nBestList , const std::vector& outputFactorOrder diff --git a/moses/MockHypothesis.cpp b/moses/MockHypothesis.cpp index 12527aee9..53a97764a 100644 --- a/moses/MockHypothesis.cpp +++ b/moses/MockHypothesis.cpp @@ -45,13 +45,13 @@ MockHypothesisGuard m_manager.reset(new Manager(m_ttask)); //Initial empty hypothesis - Bitmaps bitmaps(m_sentence.get()->GetSize(), - m_sentence.get()->m_sourceCompleted); + Bitmaps bitmaps(m_sentence.get()->GetSize(), + m_sentence.get()->m_sourceCompleted); m_manager->ResetSentenceStats(*m_sentence); const Bitmap &initBitmap = bitmaps.GetInitialBitmap(); - m_hypothesis = new Hypothesis(*m_manager, *m_sentence, m_initialTransOpt, - initBitmap); + m_hypothesis = new Hypothesis(*m_manager, *m_sentence, m_initialTransOpt, + initBitmap); //create the chain vector::const_iterator ai = alignments.begin(); @@ -59,8 +59,8 @@ MockHypothesisGuard for (; ti != targetSegments.end() && ai != alignments.end(); ++ti,++ai) { Hypothesis* prevHypo = m_hypothesis; Range range(ai->first,ai->second); - const Bitmap &newBitmap = bitmaps.GetBitmap(prevHypo->GetWordsBitmap(), - range); + const Bitmap &newBitmap = bitmaps.GetBitmap(prevHypo->GetWordsBitmap(), + range); m_targetPhrases.push_back(TargetPhrase(NULL)); // m_targetPhrases.back().CreateFromString(Input, factors, *ti, "|", NULL); diff --git a/moses/Parameter.cpp b/moses/Parameter.cpp index 206f15e50..f379b6904 100644 --- a/moses/Parameter.cpp +++ b/moses/Parameter.cpp @@ -1620,7 +1620,7 @@ SetParameter(bool ¶meter, std::string const& parameterName, } } -void +void Parameter:: SetParameter(bool& var, std::string const& name) { diff --git a/moses/Parameter.h b/moses/Parameter.h index 5dbe5fd30..bc3415245 100644 --- a/moses/Parameter.h +++ b/moses/Parameter.h @@ -155,14 +155,13 @@ public: // issues a warning if format is wrong const PARAM_VEC *params = GetParam(name); val = (params && params->size()); - if (val && params->size() != 1) - { - TRACE_ERR("ERROR: wrong format for switch -" << name); - return false; - } + if (val && params->size() != 1) { + TRACE_ERR("ERROR: wrong format for switch -" << name); + return false; + } return true; } - + }; template<> diff --git a/moses/ScoreComponentCollection.cpp b/moses/ScoreComponentCollection.cpp index e7a2acf9d..7ce03c608 100644 --- a/moses/ScoreComponentCollection.cpp +++ b/moses/ScoreComponentCollection.cpp @@ -280,7 +280,7 @@ void ScoreComponentCollection::ZeroDenseFeatures(const FeatureFunction* sp) } //! get subset of scores that belong to a certain sparse ScoreProducer -FVector +FVector ScoreComponentCollection:: GetVectorForProducer(const FeatureFunction* sp) const { @@ -307,21 +307,21 @@ void ScoreComponentCollection::PlusEquals(const FeatureFunction* sp, const Score } } -void +void ScoreComponentCollection:: OutputAllFeatureScores(std::ostream &out, bool with_labels) const { std::string lastName = ""; - const vector& sff - = StatefulFeatureFunction::GetStatefulFeatureFunctions(); + const vector& sff + = StatefulFeatureFunction::GetStatefulFeatureFunctions(); for( size_t i=0; iIsTuneable()) { OutputFeatureScores(out, ff, lastName, with_labels); } } - const vector& slf - = StatelessFeatureFunction::GetStatelessFeatureFunctions(); + const vector& slf + = StatelessFeatureFunction::GetStatelessFeatureFunctions(); for( size_t i=0; iIsTuneable()) { @@ -330,10 +330,10 @@ OutputAllFeatureScores(std::ostream &out, bool with_labels) const } } -void +void ScoreComponentCollection:: OutputFeatureScores(std::ostream& out, FeatureFunction const* ff, - std::string &lastName, bool with_labels) const + std::string &lastName, bool with_labels) const { // const StaticData &staticData = StaticData::Instance(); // bool labeledOutput = staticData.options().nbest.include_feature_labels; diff --git a/moses/ScoreComponentCollection.h b/moses/ScoreComponentCollection.h index cd48e2705..1305e9c16 100644 --- a/moses/ScoreComponentCollection.h +++ b/moses/ScoreComponentCollection.h @@ -88,7 +88,7 @@ class ScoreComponentCollection { friend std::ostream& operator<<(std::ostream& os, const ScoreComponentCollection& rhs); friend void swap(ScoreComponentCollection &first, ScoreComponentCollection &second); - + private: FVector m_scores; @@ -433,7 +433,7 @@ public: void OutputAllFeatureScores(std::ostream &out, bool with_labels) const; void OutputFeatureScores(std::ostream& out, Moses::FeatureFunction const* ff, - std::string &lastName, bool with_labels) const; + std::string &lastName, bool with_labels) const; #ifdef MPI_ENABLE public: diff --git a/moses/Sentence.cpp b/moses/Sentence.cpp index 4aaf3d069..842feed2b 100644 --- a/moses/Sentence.cpp +++ b/moses/Sentence.cpp @@ -183,7 +183,7 @@ init(string line, std::vector const& factorOrder, aux_interpret_dlt(line); // some poorly documented cache-based stuff // if sentences is specified as "" - if (SD.options().output.PrintPassThrough || + if (SD.options().output.PrintPassThrough || SD.options().nbest.include_passthrough) { string pthru = PassthroughSGML(line,"passthrough"); this->SetPassthroughInformation(pthru); @@ -232,7 +232,7 @@ init(string line, std::vector const& factorOrder, int Sentence:: -Read(std::istream& in, +Read(std::istream& in, const std::vector& factorOrder, AllOptions const& opts) { @@ -370,9 +370,9 @@ CreateFromString(vector const& FOrder, string const& phraseString) } Sentence:: -Sentence(size_t const transId, - string const& stext, - AllOptions const& opts, +Sentence(size_t const transId, + string const& stext, + AllOptions const& opts, vector const* IFO) : InputType(transId) { diff --git a/moses/Sentence.h b/moses/Sentence.h index 575ae26c1..91393b355 100644 --- a/moses/Sentence.h +++ b/moses/Sentence.h @@ -65,8 +65,8 @@ protected: public: Sentence(); Sentence(size_t const transId, std::string const& stext, - AllOptions const& opts, - std::vector const* IFO = NULL); + AllOptions const& opts, + std::vector const* IFO = NULL); // Sentence(size_t const transId, std::string const& stext); ~Sentence(); @@ -97,7 +97,7 @@ public: void GetXmlTranslationOptions(std::vector &list, size_t startPos, size_t endPos) const; std::vector GetXmlChartTranslationOptions() const; - virtual int + virtual int Read(std::istream& in, const std::vector& factorOrder, AllOptions const& opts); diff --git a/moses/StaticData.cpp b/moses/StaticData.cpp index cc4b1ad35..3d5ffe9d7 100644 --- a/moses/StaticData.cpp +++ b/moses/StaticData.cpp @@ -63,7 +63,7 @@ StaticData StaticData::s_instance; StaticData::StaticData() : m_sourceStartPosMattersForRecombination(false) , m_requireSortingAfterSourceContext(false) - // , m_inputType(SentenceInput) + // , m_inputType(SentenceInput) , m_lmEnableOOVFeature(false) , m_isAlwaysCreateDirectTranslationOption(false) , m_currentWeightSetting("default") @@ -169,21 +169,21 @@ StaticData m_parameter->SetParameter(m_verboseLevel, "verbose", (size_t) 1); - m_parameter->SetParameter(m_includeLHSInSearchGraph, + m_parameter->SetParameter(m_includeLHSInSearchGraph, "include-lhs-in-search-graph", false ); - m_parameter->SetParameter(m_outputUnknownsFile, + m_parameter->SetParameter(m_outputUnknownsFile, "output-unknowns", ""); //Print Translation Options - m_parameter->SetParameter(m_printTranslationOptions, + m_parameter->SetParameter(m_printTranslationOptions, "print-translation-option", false ); - + //Print All Derivations - m_parameter->SetParameter(m_printAllDerivations , + m_parameter->SetParameter(m_printAllDerivations , "print-all-derivations", false ); - - m_parameter->SetParameter(m_startTranslationId, + + m_parameter->SetParameter(m_startTranslationId, "start-translation-id", 0); //lattice samples @@ -340,9 +340,9 @@ bool StaticData::LoadData(Parameter *parameter) ini_zombie_options(); // probably dead, or maybe not - m_parameter->SetParameter(m_placeHolderFactor, "placeholder-factor", + m_parameter->SetParameter(m_placeHolderFactor, "placeholder-factor", NOT_FOUND); - + // FEATURE FUNCTION INITIALIZATION HAPPENS HERE =============================== initialize_features(); @@ -393,7 +393,7 @@ void StaticData::SetWeight(const FeatureFunction* sp, float weight) m_allWeights.Assign(sp,weight); } -void StaticData::SetWeights(const FeatureFunction* sp, +void StaticData::SetWeights(const FeatureFunction* sp, const std::vector& weights) { m_allWeights.Resize(); @@ -444,9 +444,9 @@ void StaticData::LoadChartDecodingParameters() LoadNonTerminals(); // source label overlap - m_parameter->SetParameter(m_sourceLabelOverlap, "source-label-overlap", + m_parameter->SetParameter(m_sourceLabelOverlap, "source-label-overlap", SourceLabelOverlapAdd); - m_parameter->SetParameter(m_ruleLimit, "rule-limit", + m_parameter->SetParameter(m_ruleLimit, "rule-limit", DEFAULT_MAX_TRANS_OPT_SIZE); } @@ -485,16 +485,16 @@ void StaticData::LoadDecodeGraphs() } } -void +void StaticData:: -LoadDecodeGraphsOld(const vector &mappingVector, +LoadDecodeGraphsOld(const vector &mappingVector, const vector &maxChartSpans) { const vector& pts = PhraseDictionary::GetColl(); const vector& gens = GenerationDictionary::GetColl(); - const std::vector *featuresRemaining - = &FeatureFunction::GetFeatureFunctions(); + const std::vector *featuresRemaining + = &FeatureFunction::GetFeatureFunctions(); DecodeStep *prev = 0; size_t prevDecodeGraphInd = 0; @@ -513,7 +513,7 @@ LoadDecodeGraphsOld(const vector &mappingVector, // For specifying multiple translation model decodeGraphInd = Scan(token[0]); //the vectorList index can only increment by one - UTIL_THROW_IF2(decodeGraphInd != prevDecodeGraphInd + UTIL_THROW_IF2(decodeGraphInd != prevDecodeGraphInd && decodeGraphInd != prevDecodeGraphInd + 1, "Malformed mapping"); if (decodeGraphInd > prevDecodeGraphInd) { @@ -601,7 +601,7 @@ void StaticData::LoadDecodeGraphsNew(const std::vector &mappingVect decodeGraphInd = Scan(token[0]); //the vectorList index can only increment by one - UTIL_THROW_IF2(decodeGraphInd != prevDecodeGraphInd + UTIL_THROW_IF2(decodeGraphInd != prevDecodeGraphInd && decodeGraphInd != prevDecodeGraphInd + 1, "Malformed mapping"); if (decodeGraphInd > prevDecodeGraphInd) { @@ -702,14 +702,14 @@ StaticData:: InitializeForInput(ttasksptr const& ttask) const { const std::vector &producers - = FeatureFunction::GetFeatureFunctions(); + = FeatureFunction::GetFeatureFunctions(); for(size_t i=0; i } //! populate this InputType with data from in stream -int +int TreeInput:: Read(std::istream& in, const std::vector& factorOrder, AllOptions const& opts) @@ -258,7 +258,7 @@ Read(std::istream& in, const std::vector& factorOrder, strme << line << endl; Sentence::Read(strme, factorOrder, opts); - + // size input chart size_t sourceSize = GetSize(); m_sourceChart.resize(sourceSize); diff --git a/moses/TreeInput.h b/moses/TreeInput.h index 2116334c1..a8c53493e 100644 --- a/moses/TreeInput.h +++ b/moses/TreeInput.h @@ -53,8 +53,8 @@ public: } //! populate this InputType with data from in stream - virtual int - Read(std::istream& in, + virtual int + Read(std::istream& in, const std::vector& factorOrder, AllOptions const& opts); diff --git a/moses/WordLattice.cpp b/moses/WordLattice.cpp index e597affc5..09866f812 100644 --- a/moses/WordLattice.cpp +++ b/moses/WordLattice.cpp @@ -147,9 +147,9 @@ InitializeFromPCNDataType return !cn.empty(); } -int +int WordLattice:: -Read(std::istream& in, +Read(std::istream& in, std::vector const& factorOrder, AllOptions const& opts) { diff --git a/moses/WordLattice.h b/moses/WordLattice.h index 992fb9498..1b3ff889b 100644 --- a/moses/WordLattice.h +++ b/moses/WordLattice.h @@ -43,10 +43,10 @@ public: int InitializeFromPCNDataType(const PCN::CN& cn, const std::vector& factorOrder, const std::string& debug_line = ""); /** Read from PLF format (1 lattice per line) */ - int Read(std::istream& in, - std::vector const& factorOrder, - AllOptions const& opts); - + int Read(std::istream& in, + std::vector const& factorOrder, + AllOptions const& opts); + /** Convert internal representation into an edge matrix * @note edges[1][2] means there is an edge from 1 to 2 */