mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
beautify
This commit is contained in:
parent
3eba5782c2
commit
310b26f989
@ -65,7 +65,7 @@ int main(int argc, char **argv)
|
|||||||
sourcePhrase.CreateFromString(Input, input, line, "||dummy_string||", NULL);
|
sourcePhrase.CreateFromString(Input, input, line, "||dummy_string||", NULL);
|
||||||
|
|
||||||
TargetPhraseVectorPtr decodedPhraseColl
|
TargetPhraseVectorPtr decodedPhraseColl
|
||||||
= pdc.GetTargetPhraseCollectionRaw(sourcePhrase);
|
= pdc.GetTargetPhraseCollectionRaw(sourcePhrase);
|
||||||
|
|
||||||
if(decodedPhraseColl != NULL) {
|
if(decodedPhraseColl != NULL) {
|
||||||
if(reportCounts)
|
if(reportCounts)
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
}
|
}
|
||||||
LabelId add(const Key& k) {
|
LabelId add(const Key& k) {
|
||||||
std::pair<typename M::iterator,bool> p
|
std::pair<typename M::iterator,bool> p
|
||||||
=m.insert(std::make_pair(k,data.size()));
|
=m.insert(std::make_pair(k,data.size()));
|
||||||
if(p.second) data.push_back(k);
|
if(p.second) data.push_back(k);
|
||||||
CHECK(static_cast<size_t>(p.first->second)<data.size());
|
CHECK(static_cast<size_t>(p.first->second)<data.size());
|
||||||
return p.first->second;
|
return p.first->second;
|
||||||
|
@ -948,7 +948,7 @@ const TranslationOptionList* StaticData::FindTransOptListInCache(const DecodeGra
|
|||||||
boost::mutex::scoped_lock lock(m_transOptCacheMutex);
|
boost::mutex::scoped_lock lock(m_transOptCacheMutex);
|
||||||
#endif
|
#endif
|
||||||
std::map<std::pair<std::pair<size_t, std::string>, Phrase>, std::pair<TranslationOptionList*,clock_t> >::iterator iter
|
std::map<std::pair<std::pair<size_t, std::string>, Phrase>, std::pair<TranslationOptionList*,clock_t> >::iterator iter
|
||||||
= m_transOptCache.find(key);
|
= m_transOptCache.find(key);
|
||||||
if (iter == m_transOptCache.end())
|
if (iter == m_transOptCache.end())
|
||||||
return NULL;
|
return NULL;
|
||||||
iter->second.second = clock(); // update last used time
|
iter->second.second = clock(); // update last used time
|
||||||
|
@ -673,7 +673,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::map< std::string, std::set< std::string > >::const_iterator lookupIgnoreFF
|
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()) {
|
if (lookupIgnoreFF == m_weightSettingIgnoreFF.end()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -691,7 +691,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::map< std::string, std::set< size_t > >::const_iterator lookupIgnoreDP
|
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()) {
|
if (lookupIgnoreDP == m_weightSettingIgnoreDP.end()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -234,12 +234,12 @@ void ChartRuleLookupManagerOnDisk::GetChartRuleCollection(
|
|||||||
|
|
||||||
std::vector<float> weightT = staticData.GetWeights(&m_dictionary);
|
std::vector<float> weightT = staticData.GetWeights(&m_dictionary);
|
||||||
targetPhraseCollection
|
targetPhraseCollection
|
||||||
= tpcollBerkeleyDb->ConvertToMoses(m_inputFactorsVec
|
= tpcollBerkeleyDb->ConvertToMoses(m_inputFactorsVec
|
||||||
,m_outputFactorsVec
|
,m_outputFactorsVec
|
||||||
,m_dictionary
|
,m_dictionary
|
||||||
,weightT
|
,weightT
|
||||||
,m_filePath
|
,m_filePath
|
||||||
, m_dbWrapper.GetVocab());
|
, m_dbWrapper.GetVocab());
|
||||||
|
|
||||||
delete tpcollBerkeleyDb;
|
delete tpcollBerkeleyDb;
|
||||||
m_cache[tpCollFilePos] = targetPhraseCollection;
|
m_cache[tpCollFilePos] = targetPhraseCollection;
|
||||||
|
@ -428,7 +428,7 @@ void CompressionTaskReordering::operator()()
|
|||||||
while(scoresNum < m_encodedScores.size()) {
|
while(scoresNum < m_encodedScores.size()) {
|
||||||
std::string scores = m_encodedScores[scoresNum];
|
std::string scores = m_encodedScores[scoresNum];
|
||||||
std::string compressedScores
|
std::string compressedScores
|
||||||
= m_creator.CompressEncodedScores(scores);
|
= m_creator.CompressEncodedScores(scores);
|
||||||
|
|
||||||
std::string dummy;
|
std::string dummy;
|
||||||
PackedItem packedItem(scoresNum, dummy, compressedScores, 0);
|
PackedItem packedItem(scoresNum, dummy, compressedScores, 0);
|
||||||
|
@ -61,7 +61,7 @@ PhraseDecoder::~PhraseDecoder()
|
|||||||
inline unsigned PhraseDecoder::GetSourceSymbolId(std::string& symbol)
|
inline unsigned PhraseDecoder::GetSourceSymbolId(std::string& symbol)
|
||||||
{
|
{
|
||||||
boost::unordered_map<std::string, unsigned>::iterator it
|
boost::unordered_map<std::string, unsigned>::iterator it
|
||||||
= m_sourceSymbolsMap.find(symbol);
|
= m_sourceSymbolsMap.find(symbol);
|
||||||
if(it != m_sourceSymbolsMap.end())
|
if(it != m_sourceSymbolsMap.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ TargetPhraseVectorPtr PhraseDecoder::CreateTargetPhraseCollection(const Phrase &
|
|||||||
|
|
||||||
if(m_coding == PREnc) {
|
if(m_coding == PREnc) {
|
||||||
std::pair<TargetPhraseVectorPtr, size_t> cachedPhraseColl
|
std::pair<TargetPhraseVectorPtr, size_t> cachedPhraseColl
|
||||||
= m_decodingCache.Retrieve(sourcePhrase);
|
= m_decodingCache.Retrieve(sourcePhrase);
|
||||||
|
|
||||||
// Has been cached and is complete or does not need to be completed
|
// Has been cached and is complete or does not need to be completed
|
||||||
if(cachedPhraseColl.first != NULL && (!topLevel || cachedPhraseColl.second == 0))
|
if(cachedPhraseColl.first != NULL && (!topLevel || cachedPhraseColl.second == 0))
|
||||||
@ -255,7 +255,7 @@ TargetPhraseVectorPtr PhraseDecoder::DecodeCollection(
|
|||||||
if(m_coding == REnc) {
|
if(m_coding == REnc) {
|
||||||
for(size_t i = 0; i < sourcePhrase.GetSize(); i++) {
|
for(size_t i = 0; i < sourcePhrase.GetSize(); i++) {
|
||||||
std::string sourceWord
|
std::string sourceWord
|
||||||
= sourcePhrase.GetWord(i).GetString(*m_input, false);
|
= sourcePhrase.GetWord(i).GetString(*m_input, false);
|
||||||
unsigned idx = GetSourceSymbolId(sourceWord);
|
unsigned idx = GetSourceSymbolId(sourceWord);
|
||||||
sourceWords.push_back(idx);
|
sourceWords.push_back(idx);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ PhraseDictionaryCompact::GetTargetPhraseCollection(const Phrase &sourcePhrase) c
|
|||||||
|
|
||||||
// Retrieve target phrase collection from phrase table
|
// Retrieve target phrase collection from phrase table
|
||||||
TargetPhraseVectorPtr decodedPhraseColl
|
TargetPhraseVectorPtr decodedPhraseColl
|
||||||
= m_phraseDecoder->CreateTargetPhraseCollection(sourcePhrase, true, true);
|
= m_phraseDecoder->CreateTargetPhraseCollection(sourcePhrase, true, true);
|
||||||
|
|
||||||
if(decodedPhraseColl != NULL && decodedPhraseColl->size()) {
|
if(decodedPhraseColl != NULL && decodedPhraseColl->size()) {
|
||||||
TargetPhraseVectorPtr tpv(new TargetPhraseVector(*decodedPhraseColl));
|
TargetPhraseVectorPtr tpv(new TargetPhraseVector(*decodedPhraseColl));
|
||||||
|
@ -426,7 +426,7 @@ void PhraseTableCreator::AddTargetSymbolId(std::string& symbol)
|
|||||||
unsigned PhraseTableCreator::GetSourceSymbolId(std::string& symbol)
|
unsigned PhraseTableCreator::GetSourceSymbolId(std::string& symbol)
|
||||||
{
|
{
|
||||||
boost::unordered_map<std::string, unsigned>::iterator it
|
boost::unordered_map<std::string, unsigned>::iterator it
|
||||||
= m_sourceSymbolsMap.find(symbol);
|
= m_sourceSymbolsMap.find(symbol);
|
||||||
|
|
||||||
if(it != m_sourceSymbolsMap.end())
|
if(it != m_sourceSymbolsMap.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
@ -437,7 +437,7 @@ unsigned PhraseTableCreator::GetSourceSymbolId(std::string& symbol)
|
|||||||
unsigned PhraseTableCreator::GetTargetSymbolId(std::string& symbol)
|
unsigned PhraseTableCreator::GetTargetSymbolId(std::string& symbol)
|
||||||
{
|
{
|
||||||
boost::unordered_map<std::string, unsigned>::iterator it
|
boost::unordered_map<std::string, unsigned>::iterator it
|
||||||
= m_targetSymbolsMap.find(symbol);
|
= m_targetSymbolsMap.find(symbol);
|
||||||
|
|
||||||
if(it != m_targetSymbolsMap.end())
|
if(it != m_targetSymbolsMap.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
@ -451,7 +451,7 @@ unsigned PhraseTableCreator::GetOrAddTargetSymbolId(std::string& symbol)
|
|||||||
boost::mutex::scoped_lock lock(m_mutex);
|
boost::mutex::scoped_lock lock(m_mutex);
|
||||||
#endif
|
#endif
|
||||||
boost::unordered_map<std::string, unsigned>::iterator it
|
boost::unordered_map<std::string, unsigned>::iterator it
|
||||||
= m_targetSymbolsMap.find(symbol);
|
= m_targetSymbolsMap.find(symbol);
|
||||||
|
|
||||||
if(it != m_targetSymbolsMap.end())
|
if(it != m_targetSymbolsMap.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
@ -1212,7 +1212,7 @@ void CompressionTask::operator()()
|
|||||||
while(collectionNum < m_encodedCollections.size()) {
|
while(collectionNum < m_encodedCollections.size()) {
|
||||||
std::string collection = m_encodedCollections[collectionNum];
|
std::string collection = m_encodedCollections[collectionNum];
|
||||||
std::string compressedCollection
|
std::string compressedCollection
|
||||||
= m_creator.CompressEncodedCollection(collection);
|
= m_creator.CompressEncodedCollection(collection);
|
||||||
|
|
||||||
std::string dummy;
|
std::string dummy;
|
||||||
PackedItem packedItem(collectionNum, dummy, compressedCollection, 0);
|
PackedItem packedItem(collectionNum, dummy, compressedCollection, 0);
|
||||||
|
@ -143,7 +143,7 @@ public:
|
|||||||
return data;
|
return data;
|
||||||
else {
|
else {
|
||||||
typename std::vector<DataType>::iterator it
|
typename std::vector<DataType>::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())
|
if(it != m_bestVec.end())
|
||||||
return *it;
|
return *it;
|
||||||
else
|
else
|
||||||
|
@ -108,28 +108,28 @@ enum DistortionOrientationOptions {
|
|||||||
|
|
||||||
enum PhraseTableImplementation {
|
enum PhraseTableImplementation {
|
||||||
Memory = 0
|
Memory = 0
|
||||||
,Binary = 1
|
,Binary = 1
|
||||||
,OnDisk = 2
|
,OnDisk = 2
|
||||||
//,GlueRule = 3
|
//,GlueRule = 3
|
||||||
//,Joshua = 4
|
//,Joshua = 4
|
||||||
//,MemorySourceLabel = 5
|
//,MemorySourceLabel = 5
|
||||||
,SCFG = 6
|
,SCFG = 6
|
||||||
//,BerkeleyDb = 7
|
//,BerkeleyDb = 7
|
||||||
,SuffixArray = 8
|
,SuffixArray = 8
|
||||||
,Hiero = 9
|
,Hiero = 9
|
||||||
,ALSuffixArray = 10
|
,ALSuffixArray = 10
|
||||||
,FuzzyMatch = 11
|
,FuzzyMatch = 11
|
||||||
,Compact = 12
|
,Compact = 12
|
||||||
,Interpolated = 13
|
,Interpolated = 13
|
||||||
,DSuffixArray = 14
|
,DSuffixArray = 14
|
||||||
};
|
};
|
||||||
|
|
||||||
enum InputTypeEnum {
|
enum InputTypeEnum {
|
||||||
SentenceInput = 0
|
SentenceInput = 0
|
||||||
,ConfusionNetworkInput = 1
|
,ConfusionNetworkInput = 1
|
||||||
,WordLatticeInput = 2
|
,WordLatticeInput = 2
|
||||||
,TreeInputType = 3
|
,TreeInputType = 3
|
||||||
,WordLatticeInput2 = 4
|
,WordLatticeInput2 = 4
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ enum XmlInputType {
|
|||||||
|
|
||||||
enum DictionaryFind {
|
enum DictionaryFind {
|
||||||
Best = 0
|
Best = 0
|
||||||
,All = 1
|
,All = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ParsingAlgorithm {
|
enum ParsingAlgorithm {
|
||||||
@ -152,22 +152,22 @@ enum ParsingAlgorithm {
|
|||||||
|
|
||||||
enum SearchAlgorithm {
|
enum SearchAlgorithm {
|
||||||
Normal = 0
|
Normal = 0
|
||||||
,CubePruning = 1
|
,CubePruning = 1
|
||||||
,CubeGrowing = 2
|
,CubeGrowing = 2
|
||||||
,ChartDecoding= 3
|
,ChartDecoding= 3
|
||||||
,NormalBatch = 4
|
,NormalBatch = 4
|
||||||
,ChartIncremental = 5
|
,ChartIncremental = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SourceLabelOverlap {
|
enum SourceLabelOverlap {
|
||||||
SourceLabelOverlapAdd = 0
|
SourceLabelOverlapAdd = 0
|
||||||
,SourceLabelOverlapReplace = 1
|
,SourceLabelOverlapReplace = 1
|
||||||
,SourceLabelOverlapDiscard = 2
|
,SourceLabelOverlapDiscard = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum WordAlignmentSort {
|
enum WordAlignmentSort {
|
||||||
NoSort = 0
|
NoSort = 0
|
||||||
,TargetOrder = 1
|
,TargetOrder = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FormatType {
|
enum FormatType {
|
||||||
|
@ -137,7 +137,7 @@ void LeftBinarize( SyntaxTree &tree, ParentNodes &parents )
|
|||||||
const SplitPoints &point = *p;
|
const SplitPoints &point = *p;
|
||||||
if (point.size() > 3) {
|
if (point.size() > 3) {
|
||||||
const vector< SyntaxNode* >& topNodes
|
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();
|
string topLabel = topNodes[0]->GetLabel();
|
||||||
|
|
||||||
for(size_t i=2; i<point.size()-1; i++) {
|
for(size_t i=2; i<point.size()-1; i++) {
|
||||||
@ -155,7 +155,7 @@ void RightBinarize( SyntaxTree &tree, ParentNodes &parents )
|
|||||||
if (point.size() > 3) {
|
if (point.size() > 3) {
|
||||||
int endPoint = point[point.size()-1]-1;
|
int endPoint = point[point.size()-1]-1;
|
||||||
const vector< SyntaxNode* >& topNodes
|
const vector< SyntaxNode* >& topNodes
|
||||||
= tree.GetNodes( point[0], endPoint);
|
= tree.GetNodes( point[0], endPoint);
|
||||||
string topLabel = topNodes[0]->GetLabel();
|
string topLabel = topNodes[0]->GetLabel();
|
||||||
|
|
||||||
for(size_t i=1; i<point.size()-2; i++) {
|
for(size_t i=1; i<point.size()-2; i++) {
|
||||||
|
10
symal/cmd.h
10
symal/cmd.h
@ -33,14 +33,14 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__STDC__)
|
#if defined(__STDC__)
|
||||||
int DeclareParams(char *, ...);
|
int DeclareParams(char *, ...);
|
||||||
#else
|
#else
|
||||||
int DeclareParams();
|
int DeclareParams();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int GetParams(int *n, char ***a,char *CmdFileName),
|
int GetParams(int *n, char ***a,char *CmdFileName),
|
||||||
SPrintParams(),
|
SPrintParams(),
|
||||||
PrintParams();
|
PrintParams();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user