diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2015-05-13 13:29:16 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2015-05-13 13:29:16 +0300 |
commit | 5173b9f6172cb695461b00826da935c2b2907c78 (patch) | |
tree | 1e39253453f4eef9934f5df5f342ade079fea9ed /moses/IOWrapper.cpp | |
parent | 0859e9a844cc23ff04b09b4ac3d580da9197d1a1 (diff) |
beautify. Add sed for trailing spaces
Diffstat (limited to 'moses/IOWrapper.cpp')
-rw-r--r-- | moses/IOWrapper.cpp | 74 |
1 files changed, 33 insertions, 41 deletions
diff --git a/moses/IOWrapper.cpp b/moses/IOWrapper.cpp index 1e93d868d..29769f180 100644 --- a/moses/IOWrapper.cpp +++ b/moses/IOWrapper.cpp @@ -101,7 +101,7 @@ IOWrapper::IOWrapper() m_inputType = staticData.GetInputType(); UTIL_THROW_IF2((m_look_ahead || m_look_back) && m_inputType != SentenceInput, - "Context-sensitive decoding currently works only with sentence input."); + "Context-sensitive decoding currently works only with sentence input."); m_currentLine = staticData.GetStartTranslationId(); @@ -224,17 +224,15 @@ IOWrapper::IOWrapper() // first, determine the output directory if (p && p->size() > 2) fmt = p->at(2); else if (nBestFilePath.size() && nBestFilePath != "-" && - ! boost::starts_with(nBestFilePath, "/dev/stdout")) - { - fmt = boost::filesystem::path(nBestFilePath).parent_path().string(); - if (fmt.empty()) fmt = "."; - } - else fmt = boost::filesystem::current_path().string() + "/hypergraph"; + ! boost::starts_with(nBestFilePath, "/dev/stdout")) { + fmt = boost::filesystem::path(nBestFilePath).parent_path().string(); + if (fmt.empty()) fmt = "."; + } else fmt = boost::filesystem::current_path().string() + "/hypergraph"; if (*fmt.rbegin() != '/') fmt += "/"; std::string extension = (p && p->size() > 1 ? p->at(1) : std::string("txt")); UTIL_THROW_IF2(extension != "txt" && extension != "gz" && extension != "bz2", - "Unknown compression type '" << extension - << "' for hypergraph output!"); + "Unknown compression type '" << extension + << "' for hypergraph output!"); fmt += string("%d.") + extension; if (staticData.GetParameter().GetParam("spe-src")) { @@ -304,11 +302,10 @@ IOWrapper::ReadInput() boost::lock_guard<boost::mutex> lock(m_lock); #endif boost::shared_ptr<InputType> source = GetBufferedInput(); - if (source) - { - source->SetTranslationId(m_currentLine++); - this->set_context_for(*source); - } + if (source) { + source->SetTranslationId(m_currentLine++); + this->set_context_for(*source); + } m_past_input.push_back(source); return source; } @@ -320,37 +317,32 @@ set_context_for(InputType& source) boost::shared_ptr<string> context(new string); list<boost::shared_ptr<InputType> >::iterator m = m_past_input.end(); // remove obsolete past input from buffer: - if (m_past_input.end() != m_past_input.begin()) - { - for (size_t cnt = 0; cnt < m_look_back && --m != m_past_input.begin(); - cnt += (*m)->GetSize()); - while (m_past_input.begin() != m) m_past_input.pop_front(); - } + if (m_past_input.end() != m_past_input.begin()) { + for (size_t cnt = 0; cnt < m_look_back && --m != m_past_input.begin(); + cnt += (*m)->GetSize()); + while (m_past_input.begin() != m) m_past_input.pop_front(); + } // cerr << string(80,'=') << endl; - if (m_past_input.size()) - { - m = m_past_input.begin(); - *context += (*m)->ToString(); - // cerr << (*m)->ToString() << endl; - for (++m; m != m_past_input.end(); ++m) - { - // cerr << "\n" << (*m)->ToString() << endl; - *context += string(" ") + (*m)->ToString(); - } - // cerr << string(80,'-') << endl; + if (m_past_input.size()) { + m = m_past_input.begin(); + *context += (*m)->ToString(); + // cerr << (*m)->ToString() << endl; + for (++m; m != m_past_input.end(); ++m) { + // cerr << "\n" << (*m)->ToString() << endl; + *context += string(" ") + (*m)->ToString(); } + // cerr << string(80,'-') << endl; + } // cerr << source.ToString() << endl; - if (m_future_input.size()) - { - // cerr << string(80,'-') << endl; - for (m = m_future_input.begin(); m != m_future_input.end(); ++m) - { - // if (m != m_future_input.begin()) cerr << "\n"; - // cerr << (*m)->ToString() << endl; - if (context->size()) *context += " "; - *context += (*m)->ToString(); - } + if (m_future_input.size()) { + // cerr << string(80,'-') << endl; + for (m = m_future_input.begin(); m != m_future_input.end(); ++m) { + // if (m != m_future_input.begin()) cerr << "\n"; + // cerr << (*m)->ToString() << endl; + if (context->size()) *context += " "; + *context += (*m)->ToString(); } + } // cerr << string(80,'=') << endl; source.SetContext(context); } |