string UserMessage::GetQueue() { stringstream strme(""); while (!m_msgQueue.empty()) { strme << m_msgQueue.front() << endl; m_msgQueue.pop(); } return strme.str(); }
void DeleteRules::Load() { std::vector<FactorType> factorOrder; factorOrder.push_back(0); // unfactored for now InputFileStream strme(m_path); string line; while (getline(strme, line)) { vector<string> toks = TokenizeMultiCharSeparator(line, "|||"); UTIL_THROW_IF2(toks.size() != 2, "Line must be source ||| target"); Phrase source, target; source.CreateFromString(Input, factorOrder, toks[0], NULL); target.CreateFromString(Output, factorOrder, toks[1], NULL); size_t hash = 0; boost::hash_combine(hash, source); boost::hash_combine(hash, target); m_ruleHashes.insert(hash); } }
void InMemoryPerSentenceOnDemandLM::InitializeForInput(ttasksptr const& ttask) { // The context scope object for this translation task // contains a map of translation task-specific data boost::shared_ptr<Moses::ContextScope> contextScope = ttask->GetScope(); // The key to the map is this object void const* key = static_cast<void const*>(this); // The value stored in the map is a string representing a phrase table boost::shared_ptr<string> value = contextScope->get<string>(key); // Create a stream to read the phrase table data stringstream strme(*(value.get())); char * nullpointer = (char *) 0; const char * filename = std::tmpnam(nullpointer); ofstream tmp; tmp.open(filename); // Read the phrase table data, one line at a time string line; while (getline(strme, line)) { tmp << line << "\n"; } tmp.close(); // m_tmpFilename.reset(new std::string("/home/lanes/mosesdecoder/tiny.with_per_sentence/europarl.en.srilm")); m_tmpFilename.reset(new std::string(filename)); //LanguageModelKen<lm::ngram::ProbingModel> & lm = GetPerThreadLM(); // std::remove(filename); }