diff --git a/contrib/moses2/PhraseBased/Manager.cpp b/contrib/moses2/PhraseBased/Manager.cpp index 7436b967a..7b62c5741 100644 --- a/contrib/moses2/PhraseBased/Manager.cpp +++ b/contrib/moses2/PhraseBased/Manager.cpp @@ -5,6 +5,8 @@ * Author: hieu */ #include +#include +#include #include #include #include "Manager.h" @@ -218,7 +220,7 @@ std::string Manager::OutputNBest() { arcLists.Sort(); - set distinctHypos; + boost::unordered_set distinctHypos; TrellisPaths contenders; m_search->AddInitialTrellisPaths(contenders); @@ -227,7 +229,7 @@ std::string Manager::OutputNBest() // MAIN LOOP stringstream out; - Moses2::FixPrecision(out); + Moses2::FixPrecision(out); size_t maxIter = system.options.nbest.nbest_size * system.options.nbest.factor; size_t bestInd = 0; @@ -243,8 +245,10 @@ std::string Manager::OutputNBest() if (system.options.nbest.only_distinct) { string tgtPhrase = path->OutputTargetPhrase(system); //cerr << "tgtPhrase=" << tgtPhrase << endl; + boost::hash string_hash; + size_t hash = string_hash(tgtPhrase); - if (distinctHypos.insert(tgtPhrase).second) { + if (distinctHypos.insert(hash).second) { ok = true; } } diff --git a/contrib/moses2/SCFG/KBestExtractor.cpp b/contrib/moses2/SCFG/KBestExtractor.cpp index 6f7f4ed2d..4674023c3 100644 --- a/contrib/moses2/SCFG/KBestExtractor.cpp +++ b/contrib/moses2/SCFG/KBestExtractor.cpp @@ -24,7 +24,7 @@ namespace SCFG KBestExtractor::KBestExtractor(const SCFG::Manager &mgr) :m_mgr(mgr) { - set distinctHypos; + boost::unordered_set distinctHypos; ArcLists &arcLists = mgr.arcLists; const Stack &lastStack = mgr.GetStacks().GetLastStack(); @@ -53,8 +53,10 @@ KBestExtractor::KBestExtractor(const SCFG::Manager &mgr) if (mgr.system.options.nbest.only_distinct) { string tgtPhrase = path->Output(); //cerr << "tgtPhrase=" << tgtPhrase << endl; + boost::hash string_hash; + size_t hash = string_hash(tgtPhrase); - if (distinctHypos.insert(tgtPhrase).second) { + if (distinctHypos.insert(hash).second) { ok = true; } }