From 871c64cec5b2bbc48e2a5277c5637c9d2e29ee5f Mon Sep 17 00:00:00 2001 From: MosesAdmin Date: Thu, 6 Oct 2016 15:14:56 +0100 Subject: daily automatic beautifier --- misc/CreateProbingPT.cpp | 16 ++++----- moses/ScoreComponentCollection.h | 3 +- moses/TranslationModel/ProbingPT/ProbingPT.cpp | 25 ++++++-------- moses/TranslationModel/ProbingPT/ProbingPT.h | 9 +++-- moses/TranslationModel/ProbingPT/StoreTarget.cpp | 40 ++++++++++------------ moses/TranslationModel/ProbingPT/StoreTarget.h | 2 +- moses/TranslationModel/ProbingPT/StoreVocab.h | 14 +++----- moses/TranslationModel/ProbingPT/hash.cpp | 14 ++++---- moses/TranslationModel/ProbingPT/line_splitter.hh | 6 ++-- .../ProbingPT/probing_hash_utils.hh | 12 +++---- moses/TranslationModel/ProbingPT/querying.cpp | 5 ++- moses/TranslationModel/ProbingPT/querying.hh | 13 +++---- moses/TranslationModel/ProbingPT/storing.cpp | 33 ++++++++---------- moses/TranslationModel/ProbingPT/storing.hh | 23 ++++++------- moses/TranslationModel/ProbingPT/vocabid.cpp | 14 ++++---- moses/TranslationModel/ProbingPT/vocabid.hh | 4 +-- 16 files changed, 104 insertions(+), 129 deletions(-) diff --git a/misc/CreateProbingPT.cpp b/misc/CreateProbingPT.cpp index dff916660..2cf6627ef 100644 --- a/misc/CreateProbingPT.cpp +++ b/misc/CreateProbingPT.cpp @@ -12,12 +12,12 @@ std::string ReformatSCFGFile(const std::string &path); int main(int argc, char* argv[]) { - string inPath, outPath; - int num_scores = 4; - int num_lex_scores = 0; - bool log_prob = false; - bool scfg = false; - int max_cache_size = 50000; + string inPath, outPath; + int num_scores = 4; + int num_lex_scores = 0; + bool log_prob = false; + bool scfg = false; + int max_cache_size = 50000; namespace po = boost::program_options; po::options_description desc("Options"); @@ -31,7 +31,7 @@ int main(int argc, char* argv[]) ("max-cache-size", po::value()->default_value(max_cache_size), "Maximum number of high-count source lines to write to cache file. 0=no cache, negative=no limit") ("scfg", "Rules are SCFG in Moses format (ie. with non-terms and LHS") - ; + ; po::variables_map vm; try { @@ -102,7 +102,7 @@ std::string ReformatSCFGFile(const std::string &path) string sortedPath = path + ".reformat.sorted.gz"; string tmpPath = path + ".tmp "; string cmd = "mkdir " + tmpPath - + " && gzip -dc " + reformattedPath + " | LC_ALL=C sort -T " + tmpPath + " | gzip -c > " + sortedPath; + + " && gzip -dc " + reformattedPath + " | LC_ALL=C sort -T " + tmpPath + " | gzip -c > " + sortedPath; system(cmd.c_str()); cmd = "rm -rf " + tmpPath + " " + reformattedPath; diff --git a/moses/ScoreComponentCollection.h b/moses/ScoreComponentCollection.h index 0ab57a73a..9b7010746 100644 --- a/moses/ScoreComponentCollection.h +++ b/moses/ScoreComponentCollection.h @@ -247,8 +247,7 @@ public: } } - void PlusEquals(const FeatureFunction* sp, float scores[]) - { + void PlusEquals(const FeatureFunction* sp, float scores[]) { size_t numScores = sp->GetNumScoreComponents(); size_t offset = sp->GetIndex(); for (size_t i = 0; i < numScores; ++i) { diff --git a/moses/TranslationModel/ProbingPT/ProbingPT.cpp b/moses/TranslationModel/ProbingPT/ProbingPT.cpp index 8b4505985..1ae0c67c3 100644 --- a/moses/TranslationModel/ProbingPT/ProbingPT.cpp +++ b/moses/TranslationModel/ProbingPT/ProbingPT.cpp @@ -39,10 +39,10 @@ void ProbingPT::Load(AllOptions::ptr const& opts) // source vocab const std::map &sourceVocab = - m_engine->getSourceVocab(); + m_engine->getSourceVocab(); std::map::const_iterator iterSource; for (iterSource = sourceVocab.begin(); iterSource != sourceVocab.end(); - ++iterSource) { + ++iterSource) { string wordStr = iterSource->second; //cerr << "wordStr=" << wordStr << endl; @@ -157,7 +157,7 @@ TargetPhraseCollection::shared_ptr ProbingPT::CreateTargetPhrase(const Phrase &s // query pt TargetPhraseCollection *tps = CreateTargetPhrases(sourcePhrase, - keyStruct.second); + keyStruct.second); return TargetPhraseCollection::shared_ptr(tps); } @@ -174,8 +174,7 @@ std::pair ProbingPT::GetKey(const Phrase &sourcePhrase) const if (!ret.first) { // source phrase contains a word unknown in the pt. // We know immediately there's no translation for it - } - else { + } else { ret.second = m_engine->getKey(probingSource, sourceSize); } @@ -184,7 +183,7 @@ std::pair ProbingPT::GetKey(const Phrase &sourcePhrase) const } void ProbingPT::GetSourceProbingIds(const Phrase &sourcePhrase, - bool &ok, uint64_t probingSource[]) const + bool &ok, uint64_t probingSource[]) const { size_t size = sourcePhrase.GetSize(); @@ -194,8 +193,7 @@ void ProbingPT::GetSourceProbingIds(const Phrase &sourcePhrase, if (probingId == m_unkId) { ok = false; return; - } - else { + } else { probingSource[i] = probingId; } } @@ -213,7 +211,7 @@ uint64_t ProbingPT::GetSourceProbingId(const Word &word) const size_t factorId = factor->GetId(); if (factorId >= m_sourceVocab.size()) { - return m_unkId; + return m_unkId; } ret += m_sourceVocab[factorId]; } @@ -222,7 +220,7 @@ uint64_t ProbingPT::GetSourceProbingId(const Word &word) const } TargetPhraseCollection *ProbingPT::CreateTargetPhrases( - const Phrase &sourcePhrase, uint64_t key) const + const Phrase &sourcePhrase, uint64_t key) const { TargetPhraseCollection *tps = NULL; @@ -256,7 +254,7 @@ TargetPhraseCollection *ProbingPT::CreateTargetPhrases( } TargetPhrase *ProbingPT::CreateTargetPhrase( - const char *&offset) const + const char *&offset) const { TargetPhraseInfo *tpInfo = (TargetPhraseInfo*) offset; size_t numRealWords = tpInfo->numWords / m_output.size(); @@ -280,8 +278,7 @@ TargetPhrase *ProbingPT::CreateTargetPhrase( tp->scoreProperties = scores + m_engine->num_scores; } */ - } - else { + } else { // log score 1st float logScores[totalNumScores]; for (size_t i = 0; i < totalNumScores; ++i) { @@ -304,7 +301,7 @@ TargetPhrase *ProbingPT::CreateTargetPhrase( // words for (size_t targetPos = 0; targetPos < numRealWords; ++targetPos) { - Word &word = tp->AddWord(); + Word &word = tp->AddWord(); for (size_t i = 0; i < m_output.size(); ++i) { FactorType factorType = m_output[i]; diff --git a/moses/TranslationModel/ProbingPT/ProbingPT.h b/moses/TranslationModel/ProbingPT/ProbingPT.h index 21c01df28..953a2dc2f 100644 --- a/moses/TranslationModel/ProbingPT/ProbingPT.h +++ b/moses/TranslationModel/ProbingPT/ProbingPT.h @@ -59,17 +59,16 @@ protected: std::pair GetKey(const Phrase &sourcePhrase) const; void GetSourceProbingIds(const Phrase &sourcePhrase, bool &ok, - uint64_t probingSource[]) const; + uint64_t probingSource[]) const; uint64_t GetSourceProbingId(const Word &word) const; uint64_t GetSourceProbingId(const Factor *factor) const; TargetPhraseCollection *CreateTargetPhrases( - const Phrase &sourcePhrase, uint64_t key) const; + const Phrase &sourcePhrase, uint64_t key) const; TargetPhrase *CreateTargetPhrase( - const char *&offset) const; + const char *&offset) const; - inline const Factor *GetTargetFactor(uint32_t probingId) const - { + inline const Factor *GetTargetFactor(uint32_t probingId) const { if (probingId >= m_targetVocab.size()) { return NULL; } diff --git a/moses/TranslationModel/ProbingPT/StoreTarget.cpp b/moses/TranslationModel/ProbingPT/StoreTarget.cpp index 8072f408b..f586a26b9 100644 --- a/moses/TranslationModel/ProbingPT/StoreTarget.cpp +++ b/moses/TranslationModel/ProbingPT/StoreTarget.cpp @@ -17,12 +17,12 @@ namespace Moses { StoreTarget::StoreTarget(const std::string &basepath) -:m_basePath(basepath) -,m_vocab(basepath + "/TargetVocab.dat") + :m_basePath(basepath) + ,m_vocab(basepath + "/TargetVocab.dat") { std::string path = basepath + "/TargetColl.dat"; m_fileTargetColl.open(path.c_str(), - std::ios::out | std::ios::binary | std::ios::ate | std::ios::trunc); + std::ios::out | std::ios::binary | std::ios::ate | std::ios::trunc); if (!m_fileTargetColl.is_open()) { throw "can't create file "; } @@ -112,10 +112,10 @@ void StoreTarget::Append(const line_text &line, bool log_prob, bool scfg) vector nonTerms; util::TokenIter it; it = util::TokenIter(line.target_phrase, - util::SingleCharacter(' ')); + util::SingleCharacter(' ')); while (it) { - StringPiece word = *it; - //cerr << "word=" << word << endl; + StringPiece word = *it; + //cerr << "word=" << word << endl; bool nonTerm = false; if (scfg) { @@ -129,16 +129,16 @@ void StoreTarget::Append(const line_text &line, bool log_prob, bool scfg) util::TokenIter itFactor; itFactor = util::TokenIter(word, - util::SingleCharacter('|')); + util::SingleCharacter('|')); while (itFactor) { - StringPiece factor = *itFactor; + StringPiece factor = *itFactor; - string factorStr = factor.as_string(); - uint32_t vocabId = m_vocab.GetVocabId(factorStr); + string factorStr = factor.as_string(); + uint32_t vocabId = m_vocab.GetVocabId(factorStr); - rule->target_phrase.push_back(vocabId); + rule->target_phrase.push_back(vocabId); - itFactor++; + itFactor++; } it++; @@ -146,7 +146,7 @@ void StoreTarget::Append(const line_text &line, bool log_prob, bool scfg) // probs it = util::TokenIter(line.prob, - util::SingleCharacter(' ')); + util::SingleCharacter(' ')); while (it) { string tok = it->as_string(); float prob = Scan(tok); @@ -170,7 +170,7 @@ void StoreTarget::Append(const line_text &line, bool log_prob, bool scfg) // alignment it = util::TokenIter(line.word_align, - util::SingleCharacter(' ')); + util::SingleCharacter(' ')); while (it) { string tokPair = Trim(it->as_string()); if (tokPair.empty()) { @@ -193,8 +193,7 @@ void StoreTarget::Append(const line_text &line, bool log_prob, bool scfg) rule->word_align_non_term.push_back(sourcePos); rule->word_align_non_term.push_back(targetPos); //cerr << (int) rule->word_all1.back() << " "; - } - else { + } else { rule->word_align_term.push_back(sourcePos); rule->word_align_term.push_back(targetPos); } @@ -221,19 +220,18 @@ void StoreTarget::Append(const line_text &line, bool log_prob, bool scfg) uint32_t StoreTarget::GetAlignId(const std::vector &align) { boost::unordered_map, uint32_t>::iterator iter = - m_aligns.find(align); + m_aligns.find(align); if (iter == m_aligns.end()) { uint32_t ind = m_aligns.size(); m_aligns[align] = ind; return ind; - } - else { + } else { return iter->second; } } void StoreTarget::AppendLexRO(std::string &prop, std::vector &retvector, - bool log_prob) const + bool log_prob) const { size_t startPos = prop.find("{{LexRO "); @@ -258,7 +256,7 @@ void StoreTarget::AppendLexRO(std::string &prop, std::vector &retvector, // exclude LexRO property from property column prop = prop.substr(0, startPos) - + prop.substr(endPos + 2, prop.size() - endPos - 2); + + prop.substr(endPos + 2, prop.size() - endPos - 2); //cerr << "line.property_to_be_binarized=" << line.property_to_be_binarized << "AAAA" << endl; } } diff --git a/moses/TranslationModel/ProbingPT/StoreTarget.h b/moses/TranslationModel/ProbingPT/StoreTarget.h index 5c7d9e1b7..331c197b3 100644 --- a/moses/TranslationModel/ProbingPT/StoreTarget.h +++ b/moses/TranslationModel/ProbingPT/StoreTarget.h @@ -43,7 +43,7 @@ protected: void Save(const target_text &rule); void AppendLexRO(std::string &prop, std::vector &retvector, - bool log_prob) const; + bool log_prob) const; }; diff --git a/moses/TranslationModel/ProbingPT/StoreVocab.h b/moses/TranslationModel/ProbingPT/StoreVocab.h index 05d279f4c..806dcebf4 100644 --- a/moses/TranslationModel/ProbingPT/StoreVocab.h +++ b/moses/TranslationModel/ProbingPT/StoreVocab.h @@ -24,31 +24,27 @@ protected: public: StoreVocab(const std::string &path) - :m_path(path) + :m_path(path) {} virtual ~StoreVocab() {} - VOCABID GetVocabId(const std::string &word) - { + VOCABID GetVocabId(const std::string &word) { typename Coll::iterator iter = m_vocab.find(word); if (iter == m_vocab.end()) { VOCABID ind = m_vocab.size() + 1; m_vocab[word] = ind; return ind; - } - else { + } else { return iter->second; } } - void Insert(VOCABID id, const std::string &word) - { + void Insert(VOCABID id, const std::string &word) { m_vocab[word] = id; } - void Save() - { + void Save() { OutputFileStream strme(m_path); typename Coll::const_iterator iter; diff --git a/moses/TranslationModel/ProbingPT/hash.cpp b/moses/TranslationModel/ProbingPT/hash.cpp index 27a64b129..47242e25d 100644 --- a/moses/TranslationModel/ProbingPT/hash.cpp +++ b/moses/TranslationModel/ProbingPT/hash.cpp @@ -21,16 +21,16 @@ std::vector getVocabIDs(const StringPiece &textin) util::TokenIter itWord(textin, util::SingleCharacter(' ')); while (itWord) { - StringPiece word = *itWord; - uint64_t id = 0; + StringPiece word = *itWord; + uint64_t id = 0; - util::TokenIter itFactor(word, util::SingleCharacter('|')); + util::TokenIter itFactor(word, util::SingleCharacter('|')); while (itFactor) { - StringPiece factor = *itFactor; - //cerr << "factor=" << factor << endl; + StringPiece factor = *itFactor; + //cerr << "factor=" << factor << endl; - id += getHash(factor); - itFactor++; + id += getHash(factor); + itFactor++; } output.push_back(id); diff --git a/moses/TranslationModel/ProbingPT/line_splitter.hh b/moses/TranslationModel/ProbingPT/line_splitter.hh index cec0a5f45..01b86fc9b 100644 --- a/moses/TranslationModel/ProbingPT/line_splitter.hh +++ b/moses/TranslationModel/ProbingPT/line_splitter.hh @@ -13,8 +13,7 @@ namespace Moses { //Struct for holding processed line -struct line_text -{ +struct line_text { StringPiece source_phrase; StringPiece target_phrase; StringPiece prob; @@ -26,8 +25,7 @@ struct line_text }; //Struct for holding processed line -struct target_text -{ +struct target_text { std::vector target_phrase; std::vector prob; std::vector word_align_term; diff --git a/moses/TranslationModel/ProbingPT/probing_hash_utils.hh b/moses/TranslationModel/ProbingPT/probing_hash_utils.hh index dcf0dbe25..998686b2e 100644 --- a/moses/TranslationModel/ProbingPT/probing_hash_utils.hh +++ b/moses/TranslationModel/ProbingPT/probing_hash_utils.hh @@ -13,18 +13,15 @@ namespace Moses #define API_VERSION 15 //Hash table entry -struct Entry -{ +struct Entry { typedef uint64_t Key; Key key; - Key GetKey() const - { + Key GetKey() const { return key; } - void SetKey(Key to) - { + void SetKey(Key to) { key = to; } @@ -42,8 +39,7 @@ char * readTable(const char * filename, size_t size); uint64_t getKey(const uint64_t source_phrase[], size_t size); -struct TargetPhraseInfo -{ +struct TargetPhraseInfo { uint32_t alignTerm; uint32_t alignNonTerm; uint16_t numWords; diff --git a/moses/TranslationModel/ProbingPT/querying.cpp b/moses/TranslationModel/ProbingPT/querying.cpp index 52cd7f516..45e6ffdab 100644 --- a/moses/TranslationModel/ProbingPT/querying.cpp +++ b/moses/TranslationModel/ProbingPT/querying.cpp @@ -43,10 +43,9 @@ QueryEngine::QueryEngine(const char * filepath) found = Get(keyValue, "API_VERSION", version); if (!found) { std::cerr << "Old or corrupted version of ProbingPT. Please rebinarize your phrase tables." << std::endl; - } - else if (version != API_VERSION) { + } else if (version != API_VERSION) { std::cerr << "The ProbingPT API has changed. " << version << "!=" - << API_VERSION << " Please rebinarize your phrase tables." << std::endl; + << API_VERSION << " Please rebinarize your phrase tables." << std::endl; exit(EXIT_FAILURE); } diff --git a/moses/TranslationModel/ProbingPT/querying.hh b/moses/TranslationModel/ProbingPT/querying.hh index c43c7f3b9..915bc4806 100644 --- a/moses/TranslationModel/ProbingPT/querying.hh +++ b/moses/TranslationModel/ProbingPT/querying.hh @@ -38,17 +38,18 @@ public: std::pair query(uint64_t key); - const std::map &getSourceVocab() const - { return source_vocabids; } + const std::map &getSourceVocab() const { + return source_vocabids; + } - const std::vector &getAlignments() const - { return alignColl; } + const std::vector &getAlignments() const { + return alignColl; + } uint64_t getKey(uint64_t source_phrase[], size_t size) const; template - inline bool Get(const boost::unordered_map &keyValue, const std::string &sought, T &found) const - { + inline bool Get(const boost::unordered_map &keyValue, const std::string &sought, T &found) const { boost::unordered_map::const_iterator iter = keyValue.find(sought); if (iter == keyValue.end()) { return false; diff --git a/moses/TranslationModel/ProbingPT/storing.cpp b/moses/TranslationModel/ProbingPT/storing.cpp index 98dcfd5dc..baf6ae91e 100644 --- a/moses/TranslationModel/ProbingPT/storing.cpp +++ b/moses/TranslationModel/ProbingPT/storing.cpp @@ -32,14 +32,12 @@ void Node::Add(Table &table, const SourcePhrase &sourcePhrase, size_t pos) child = &m_children[vocabId]; assert(!child->done); child->key = key + (vocabId << pos); - } - else { + } else { child = &iter->second; } child->Add(table, sourcePhrase, pos + 1); - } - else { + } else { // this node was written previously 'cos it has rules done = true; } @@ -66,8 +64,8 @@ void Node::Write(Table &table) /////////////////////////////////////////////////////////////////////// void createProbingPT(const std::string &phrasetable_path, - const std::string &basepath, int num_scores, int num_lex_scores, - bool log_prob, int max_cache_size, bool scfg) + const std::string &basepath, int num_scores, int num_lex_scores, + bool log_prob, int max_cache_size, bool scfg) { std::cerr << "Starting..." << std::endl; @@ -123,12 +121,10 @@ void createProbingPT(const std::string &phrasetable_path, // 1st line prevSource = line.source_phrase.as_string(); storeTarget.Append(line, log_prob, scfg); - } - else if (prevSource == line.source_phrase) { + } else if (prevSource == line.source_phrase) { //If we still have the same line, just append to it: storeTarget.Append(line, log_prob, scfg); - } - else { + } else { assert(prevSource != line.source_phrase); //Create a new entry even @@ -147,7 +143,7 @@ void createProbingPT(const std::string &phrasetable_path, std::vector vocabid_source = getVocabIDs(prevSource); if (scfg) { // storing prefixes? - sourcePhrases.Add(sourceEntries, vocabid_source); + sourcePhrases.Add(sourceEntries, vocabid_source); } sourceEntry.key = getKey(vocabid_source); @@ -155,7 +151,7 @@ void createProbingPT(const std::string &phrasetable_path, cerr << "prevSource=" << prevSource << flush << " vocabids=" << Debug(vocabid_source) << flush << " key=" << sourceEntry.key << endl; - */ + */ //Put into table sourceEntries.Insert(sourceEntry); @@ -175,9 +171,9 @@ void createProbingPT(const std::string &phrasetable_path, uint64_t currKey = getKey(currVocabidSource); CacheItem *item = new CacheItem( - Trim(line.source_phrase.as_string()), - currKey, - toks[1]); + Trim(line.source_phrase.as_string()), + currKey, + toks[1]); cache.push(item); if (max_cache_size > 0 && cache.size() > max_cache_size) { @@ -191,8 +187,7 @@ void createProbingPT(const std::string &phrasetable_path, prevSource = line.source_phrase.as_string(); } - } - catch (util::EndOfFileException e) { + } catch (util::EndOfFileException e) { std::cerr << "Reading phrase table finished, writing remaining files to disk." << std::endl; @@ -258,8 +253,8 @@ size_t countUniqueSource(const std::string &path) } void serialize_cache( - std::priority_queue, CacheItemOrderer> &cache, - const std::string &path, float totalSourceCount) + std::priority_queue, CacheItemOrderer> &cache, + const std::string &path, float totalSourceCount) { std::vector vec(cache.size()); diff --git a/moses/TranslationModel/ProbingPT/storing.hh b/moses/TranslationModel/ProbingPT/storing.hh index 957c73491..994067515 100644 --- a/moses/TranslationModel/ProbingPT/storing.hh +++ b/moses/TranslationModel/ProbingPT/storing.hh @@ -32,7 +32,7 @@ public: bool done; Node() - :done(false) + :done(false) {} void Add(Table &table, const SourcePhrase &sourcePhrase, size_t pos = 0); @@ -41,8 +41,8 @@ public: void createProbingPT(const std::string &phrasetable_path, - const std::string &basepath, int num_scores, int num_lex_scores, - bool log_prob, int max_cache_size, bool scfg); + const std::string &basepath, int num_scores, int num_lex_scores, + bool log_prob, int max_cache_size, bool scfg); uint64_t getKey(const std::vector &source_phrase); std::vector CreatePrefix(const std::vector &vocabid_source, size_t endPos); @@ -66,14 +66,12 @@ public: uint64_t sourceKey; float count; CacheItem(const std::string &vSource, uint64_t vSourceKey, float vCount) - :source(vSource) - ,sourceKey(vSourceKey) - ,count(vCount) - { + :source(vSource) + ,sourceKey(vSourceKey) + ,count(vCount) { } - bool operator<(const CacheItem &other) const - { + bool operator<(const CacheItem &other) const { return count > other.count; } }; @@ -81,15 +79,14 @@ public: class CacheItemOrderer { public: - bool operator()(const CacheItem* a, const CacheItem* b) const - { + bool operator()(const CacheItem* a, const CacheItem* b) const { return (*a) < (*b); } }; void serialize_cache( - std::priority_queue, CacheItemOrderer> &cache, - const std::string &path, float totalSourceCount); + std::priority_queue, CacheItemOrderer> &cache, + const std::string &path, float totalSourceCount); } diff --git a/moses/TranslationModel/ProbingPT/vocabid.cpp b/moses/TranslationModel/ProbingPT/vocabid.cpp index 3d6efe841..d6f442323 100644 --- a/moses/TranslationModel/ProbingPT/vocabid.cpp +++ b/moses/TranslationModel/ProbingPT/vocabid.cpp @@ -7,27 +7,27 @@ namespace Moses { void add_to_map(StoreVocab &sourceVocab, - const StringPiece &textin) + const StringPiece &textin) { //Tokenize util::TokenIter itWord(textin, util::SingleCharacter(' ')); while (itWord) { - StringPiece word = *itWord; + StringPiece word = *itWord; - util::TokenIter itFactor(word, util::SingleCharacter('|')); + util::TokenIter itFactor(word, util::SingleCharacter('|')); while (itFactor) { - StringPiece factor = *itFactor; + StringPiece factor = *itFactor; - sourceVocab.Insert(getHash(factor), factor.as_string()); - itFactor++; + sourceVocab.Insert(getHash(factor), factor.as_string()); + itFactor++; } itWord++; } } void serialize_map(const std::map &karta, - const std::string &filename) + const std::string &filename) { std::ofstream os(filename.c_str()); diff --git a/moses/TranslationModel/ProbingPT/vocabid.hh b/moses/TranslationModel/ProbingPT/vocabid.hh index f9c9b2dff..7e1390874 100644 --- a/moses/TranslationModel/ProbingPT/vocabid.hh +++ b/moses/TranslationModel/ProbingPT/vocabid.hh @@ -19,10 +19,10 @@ template class StoreVocab; void add_to_map(StoreVocab &sourceVocab, - const StringPiece &textin); + const StringPiece &textin); void serialize_map(const std::map &karta, - const std::string &filename); + const std::string &filename); void read_map(std::map &karta, const char* filename); -- cgit v1.2.3