From 2203bb328470cc6657c8c2dcbbbfaa2730ff2b9d Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Mon, 8 Jul 2013 19:08:31 +0100 Subject: [PATCH 1/2] beautify --- scripts/other/beautify.perl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/other/beautify.perl b/scripts/other/beautify.perl index 41c93850c..e23f7e2a4 100755 --- a/scripts/other/beautify.perl +++ b/scripts/other/beautify.perl @@ -2,10 +2,13 @@ use strict; use File::Basename; +use FindBin qw($RealBin); sub Beautify($); -Beautify("/home/hieu/workspace/github/mosesdecoder"); +print STDERR "RealBin=$RealBin \n\n"; + +Beautify("$RealBin/../.."); sub Beautify($) { From 3eba5782c2df7b03cf2dad99b52e0a97c0ca39e9 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Mon, 8 Jul 2013 20:25:47 +0100 Subject: [PATCH 2/2] beautify --- misc/queryPhraseTableMin.cpp | 2 +- moses/LVoc.h | 2 +- moses/StaticData.cpp | 2 +- moses/StaticData.h | 4 +- .../BilingualDynSuffixArray.h | 8 +-- .../ChartRuleLookupManagerOnDisk.cpp | 12 ++--- .../LexicalReorderingTableCreator.cpp | 2 +- .../CompactPT/PhraseDecoder.cpp | 6 +-- .../CompactPT/PhraseDictionaryCompact.cpp | 2 +- .../CompactPT/PhraseTableCreator.cpp | 18 +++---- .../CompactPT/PhraseTableCreator.h | 2 +- moses/TypeDef.h | 54 +++++++++---------- moses/generic/sorting/VectorIndexSorter.h | 8 +-- phrase-extract/relax-parse-main.cpp | 4 +- symal/cmd.h | 10 ++-- 15 files changed, 68 insertions(+), 68 deletions(-) diff --git a/misc/queryPhraseTableMin.cpp b/misc/queryPhraseTableMin.cpp index 0b4324020..2f0caf910 100644 --- a/misc/queryPhraseTableMin.cpp +++ b/misc/queryPhraseTableMin.cpp @@ -65,7 +65,7 @@ int main(int argc, char **argv) sourcePhrase.CreateFromString(Input, input, line, "||dummy_string||", NULL); TargetPhraseVectorPtr decodedPhraseColl - = pdc.GetTargetPhraseCollectionRaw(sourcePhrase); + = pdc.GetTargetPhraseCollectionRaw(sourcePhrase); if(decodedPhraseColl != NULL) { if(reportCounts) diff --git a/moses/LVoc.h b/moses/LVoc.h index 485e3f481..5f5423832 100644 --- a/moses/LVoc.h +++ b/moses/LVoc.h @@ -38,7 +38,7 @@ public: } LabelId add(const Key& k) { std::pair p - =m.insert(std::make_pair(k,data.size())); + =m.insert(std::make_pair(k,data.size())); if(p.second) data.push_back(k); CHECK(static_cast(p.first->second)second; diff --git a/moses/StaticData.cpp b/moses/StaticData.cpp index af52b5cbf..96108c9e3 100644 --- a/moses/StaticData.cpp +++ b/moses/StaticData.cpp @@ -948,7 +948,7 @@ const TranslationOptionList* StaticData::FindTransOptListInCache(const DecodeGra boost::mutex::scoped_lock lock(m_transOptCacheMutex); #endif std::map, Phrase>, std::pair >::iterator iter - = m_transOptCache.find(key); + = m_transOptCache.find(key); if (iter == m_transOptCache.end()) return NULL; iter->second.second = clock(); // update last used time diff --git a/moses/StaticData.h b/moses/StaticData.h index c64b22940..8eba8c774 100644 --- a/moses/StaticData.h +++ b/moses/StaticData.h @@ -673,7 +673,7 @@ public: return false; } std::map< std::string, std::set< std::string > >::const_iterator lookupIgnoreFF - = m_weightSettingIgnoreFF.find( m_currentWeightSetting ); + = m_weightSettingIgnoreFF.find( m_currentWeightSetting ); if (lookupIgnoreFF == m_weightSettingIgnoreFF.end()) { return false; } @@ -691,7 +691,7 @@ public: return false; } std::map< std::string, std::set< size_t > >::const_iterator lookupIgnoreDP - = m_weightSettingIgnoreDP.find( m_currentWeightSetting ); + = m_weightSettingIgnoreDP.find( m_currentWeightSetting ); if (lookupIgnoreDP == m_weightSettingIgnoreDP.end()) { return false; } diff --git a/moses/TranslationModel/BilingualDynSuffixArray.h b/moses/TranslationModel/BilingualDynSuffixArray.h index 71f032507..0dac64807 100644 --- a/moses/TranslationModel/BilingualDynSuffixArray.h +++ b/moses/TranslationModel/BilingualDynSuffixArray.h @@ -26,8 +26,8 @@ public: vector words; SAPhrase(size_t phraseSize) - :words(phraseSize) - {} + :words(phraseSize) { + } void SetId(size_t pos, wordID_t id) { CHECK(pos < words.size()); @@ -49,8 +49,8 @@ public: , m_endTarget(endTarget) , m_startSource(startSource) , m_endSource(endSource) - , m_sntIndex(sntIndex) - {} + , m_sntIndex(sntIndex) { + } size_t GetTargetSize() const { return m_endTarget - m_startTarget + 1; diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp index 5dde99ade..195f6708e 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp @@ -234,12 +234,12 @@ void ChartRuleLookupManagerOnDisk::GetChartRuleCollection( std::vector weightT = staticData.GetWeights(&m_dictionary); targetPhraseCollection - = tpcollBerkeleyDb->ConvertToMoses(m_inputFactorsVec - ,m_outputFactorsVec - ,m_dictionary - ,weightT - ,m_filePath - , m_dbWrapper.GetVocab()); + = tpcollBerkeleyDb->ConvertToMoses(m_inputFactorsVec + ,m_outputFactorsVec + ,m_dictionary + ,weightT + ,m_filePath + , m_dbWrapper.GetVocab()); delete tpcollBerkeleyDb; m_cache[tpCollFilePos] = targetPhraseCollection; diff --git a/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp b/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp index 655ed01ca..7e60dec7d 100644 --- a/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp +++ b/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp @@ -428,7 +428,7 @@ void CompressionTaskReordering::operator()() while(scoresNum < m_encodedScores.size()) { std::string scores = m_encodedScores[scoresNum]; std::string compressedScores - = m_creator.CompressEncodedScores(scores); + = m_creator.CompressEncodedScores(scores); std::string dummy; PackedItem packedItem(scoresNum, dummy, compressedScores, 0); diff --git a/moses/TranslationModel/CompactPT/PhraseDecoder.cpp b/moses/TranslationModel/CompactPT/PhraseDecoder.cpp index c0767dad9..057e49268 100644 --- a/moses/TranslationModel/CompactPT/PhraseDecoder.cpp +++ b/moses/TranslationModel/CompactPT/PhraseDecoder.cpp @@ -61,7 +61,7 @@ PhraseDecoder::~PhraseDecoder() inline unsigned PhraseDecoder::GetSourceSymbolId(std::string& symbol) { boost::unordered_map::iterator it - = m_sourceSymbolsMap.find(symbol); + = m_sourceSymbolsMap.find(symbol); if(it != m_sourceSymbolsMap.end()) return it->second; @@ -200,7 +200,7 @@ TargetPhraseVectorPtr PhraseDecoder::CreateTargetPhraseCollection(const Phrase & if(m_coding == PREnc) { std::pair cachedPhraseColl - = m_decodingCache.Retrieve(sourcePhrase); + = m_decodingCache.Retrieve(sourcePhrase); // Has been cached and is complete or does not need to be completed if(cachedPhraseColl.first != NULL && (!topLevel || cachedPhraseColl.second == 0)) @@ -255,7 +255,7 @@ TargetPhraseVectorPtr PhraseDecoder::DecodeCollection( if(m_coding == REnc) { for(size_t i = 0; i < sourcePhrase.GetSize(); i++) { std::string sourceWord - = sourcePhrase.GetWord(i).GetString(*m_input, false); + = sourcePhrase.GetWord(i).GetString(*m_input, false); unsigned idx = GetSourceSymbolId(sourceWord); sourceWords.push_back(idx); } diff --git a/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp b/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp index 8d0f9ff2f..60c1876ba 100644 --- a/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp +++ b/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp @@ -117,7 +117,7 @@ PhraseDictionaryCompact::GetTargetPhraseCollection(const Phrase &sourcePhrase) c // Retrieve target phrase collection from phrase table TargetPhraseVectorPtr decodedPhraseColl - = m_phraseDecoder->CreateTargetPhraseCollection(sourcePhrase, true, true); + = m_phraseDecoder->CreateTargetPhraseCollection(sourcePhrase, true, true); if(decodedPhraseColl != NULL && decodedPhraseColl->size()) { TargetPhraseVectorPtr tpv(new TargetPhraseVector(*decodedPhraseColl)); diff --git a/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp b/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp index f2192ee36..25e232eec 100644 --- a/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp +++ b/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp @@ -426,7 +426,7 @@ void PhraseTableCreator::AddTargetSymbolId(std::string& symbol) unsigned PhraseTableCreator::GetSourceSymbolId(std::string& symbol) { boost::unordered_map::iterator it - = m_sourceSymbolsMap.find(symbol); + = m_sourceSymbolsMap.find(symbol); if(it != m_sourceSymbolsMap.end()) return it->second; @@ -437,7 +437,7 @@ unsigned PhraseTableCreator::GetSourceSymbolId(std::string& symbol) unsigned PhraseTableCreator::GetTargetSymbolId(std::string& symbol) { boost::unordered_map::iterator it - = m_targetSymbolsMap.find(symbol); + = m_targetSymbolsMap.find(symbol); if(it != m_targetSymbolsMap.end()) return it->second; @@ -451,7 +451,7 @@ unsigned PhraseTableCreator::GetOrAddTargetSymbolId(std::string& symbol) boost::mutex::scoped_lock lock(m_mutex); #endif boost::unordered_map::iterator it - = m_targetSymbolsMap.find(symbol); + = m_targetSymbolsMap.find(symbol); if(it != m_targetSymbolsMap.end()) return it->second; @@ -1034,16 +1034,16 @@ void RankingTask::operator()() for(size_t i = 0; i < lines.size(); i++) { std::vector tokens; Moses::TokenizeMultiCharSeparator(tokens, lines[i], m_creator.m_separator); - + for(std::vector::iterator it = tokens.begin(); it != tokens.end(); it++) *it = Moses::Trim(*it); - + if(tokens.size() < 4) { std::cerr << "Error: It seems the following line has a wrong format:" << std::endl; std::cerr << "Line " << i << ": " << lines[i] << std::endl; abort(); } - + if(tokens[3].size() <= 1 && m_creator.m_coding != PhraseTableCreator::None) { std::cerr << "Error: It seems the following line contains no alignment information, " << std::endl; std::cerr << "but you are using "; @@ -1134,13 +1134,13 @@ void EncodingTask::operator()() for(std::vector::iterator it = tokens.begin(); it != tokens.end(); it++) *it = Moses::Trim(*it); - + if(tokens.size() < 3) { std::cerr << "Error: It seems the following line has a wrong format:" << std::endl; std::cerr << "Line " << i << ": " << lines[i] << std::endl; abort(); } - + if(tokens[3].size() <= 1 && m_creator.m_coding != PhraseTableCreator::None) { std::cerr << "Error: It seems the following line contains no alignment information, " << std::endl; std::cerr << "but you are using "; @@ -1212,7 +1212,7 @@ void CompressionTask::operator()() while(collectionNum < m_encodedCollections.size()) { std::string collection = m_encodedCollections[collectionNum]; std::string compressedCollection - = m_creator.CompressEncodedCollection(collection); + = m_creator.CompressEncodedCollection(collection); std::string dummy; PackedItem packedItem(collectionNum, dummy, compressedCollection, 0); diff --git a/moses/TranslationModel/CompactPT/PhraseTableCreator.h b/moses/TranslationModel/CompactPT/PhraseTableCreator.h index fd5fc1581..b92df1697 100644 --- a/moses/TranslationModel/CompactPT/PhraseTableCreator.h +++ b/moses/TranslationModel/CompactPT/PhraseTableCreator.h @@ -143,7 +143,7 @@ public: return data; else { typename std::vector::iterator it - = std::lower_bound(m_bestVec.begin(), m_bestVec.end(), data); + = std::lower_bound(m_bestVec.begin(), m_bestVec.end(), data); if(it != m_bestVec.end()) return *it; else diff --git a/moses/TypeDef.h b/moses/TypeDef.h index af3a47b23..a49a3feb9 100644 --- a/moses/TypeDef.h +++ b/moses/TypeDef.h @@ -108,28 +108,28 @@ enum DistortionOrientationOptions { enum PhraseTableImplementation { Memory = 0 - ,Binary = 1 - ,OnDisk = 2 - //,GlueRule = 3 - //,Joshua = 4 - //,MemorySourceLabel = 5 - ,SCFG = 6 - //,BerkeleyDb = 7 - ,SuffixArray = 8 - ,Hiero = 9 - ,ALSuffixArray = 10 - ,FuzzyMatch = 11 - ,Compact = 12 - ,Interpolated = 13 - ,DSuffixArray = 14 + ,Binary = 1 + ,OnDisk = 2 + //,GlueRule = 3 + //,Joshua = 4 + //,MemorySourceLabel = 5 + ,SCFG = 6 + //,BerkeleyDb = 7 + ,SuffixArray = 8 + ,Hiero = 9 + ,ALSuffixArray = 10 + ,FuzzyMatch = 11 + ,Compact = 12 + ,Interpolated = 13 + ,DSuffixArray = 14 }; enum InputTypeEnum { SentenceInput = 0 - ,ConfusionNetworkInput = 1 - ,WordLatticeInput = 2 - ,TreeInputType = 3 - ,WordLatticeInput2 = 4 + ,ConfusionNetworkInput = 1 + ,WordLatticeInput = 2 + ,TreeInputType = 3 + ,WordLatticeInput2 = 4 }; @@ -142,7 +142,7 @@ enum XmlInputType { enum DictionaryFind { Best = 0 - ,All = 1 + ,All = 1 }; enum ParsingAlgorithm { @@ -152,22 +152,22 @@ enum ParsingAlgorithm { enum SearchAlgorithm { Normal = 0 - ,CubePruning = 1 - ,CubeGrowing = 2 - ,ChartDecoding= 3 - ,NormalBatch = 4 - ,ChartIncremental = 5 + ,CubePruning = 1 + ,CubeGrowing = 2 + ,ChartDecoding= 3 + ,NormalBatch = 4 + ,ChartIncremental = 5 }; enum SourceLabelOverlap { SourceLabelOverlapAdd = 0 - ,SourceLabelOverlapReplace = 1 - ,SourceLabelOverlapDiscard = 2 + ,SourceLabelOverlapReplace = 1 + ,SourceLabelOverlapDiscard = 2 }; enum WordAlignmentSort { NoSort = 0 - ,TargetOrder = 1 + ,TargetOrder = 1 }; enum FormatType { diff --git a/moses/generic/sorting/VectorIndexSorter.h b/moses/generic/sorting/VectorIndexSorter.h index a689c417b..996a67877 100644 --- a/moses/generic/sorting/VectorIndexSorter.h +++ b/moses/generic/sorting/VectorIndexSorter.h @@ -24,12 +24,12 @@ public: COMP const& Compare; VectorIndexSorter(vector const& v, COMP const& comp) - : m_vecref(v), Compare(comp) - { } + : m_vecref(v), Compare(comp) { + } VectorIndexSorter(vector const& v) - : m_vecref(v), m_comp(new COMP()), Compare(*m_comp) - { } + : m_vecref(v), m_comp(new COMP()), Compare(*m_comp) { + } bool operator()(IDX_T const & a, IDX_T const & b) const { bool fwd = Compare(m_vecref.at(a) ,m_vecref.at(b)); diff --git a/phrase-extract/relax-parse-main.cpp b/phrase-extract/relax-parse-main.cpp index a58d4d97f..d3cb4c527 100644 --- a/phrase-extract/relax-parse-main.cpp +++ b/phrase-extract/relax-parse-main.cpp @@ -137,7 +137,7 @@ void LeftBinarize( SyntaxTree &tree, ParentNodes &parents ) const SplitPoints &point = *p; if (point.size() > 3) { const vector< SyntaxNode* >& topNodes - = tree.GetNodes( point[0], point[point.size()-1]-1); + = tree.GetNodes( point[0], point[point.size()-1]-1); string topLabel = topNodes[0]->GetLabel(); for(size_t i=2; i 3) { int endPoint = point[point.size()-1]-1; const vector< SyntaxNode* >& topNodes - = tree.GetNodes( point[0], endPoint); + = tree.GetNodes( point[0], endPoint); string topLabel = topNodes[0]->GetLabel(); for(size_t i=1; i