diff options
author | Matthias Huck <mhuck@inf.ed.ac.uk> | 2015-04-30 21:44:29 +0300 |
---|---|---|
committer | Matthias Huck <mhuck@inf.ed.ac.uk> | 2015-04-30 21:44:29 +0300 |
commit | 34d1d3a9043d0bfa1e32dc0e5fc8b919fadf2bf1 (patch) | |
tree | 3c3aadcd860e6af20280054ae062357843691396 /moses/Util.h | |
parent | e98a2fc980b995c4422615f22126816a93326d20 (diff) |
sentence-bleu-nbest
Diffstat (limited to 'moses/Util.h')
-rw-r--r-- | moses/Util.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/moses/Util.h b/moses/Util.h index 5c9b493f2..b6d4ef613 100644 --- a/moses/Util.h +++ b/moses/Util.h @@ -19,8 +19,7 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ***********************************************************************/ -#ifndef moses_Util_h -#define moses_Util_h +#pragma once #include <iostream> #include <fstream> @@ -89,10 +88,17 @@ namespace Moses #define NTH_ELEMENT4(begin, middle, end, orderer) std::nth_element(begin, middle, end, orderer) #endif -//! delete white spaces at beginning and end of string -const std::string Trim(const std::string& str, const std::string dropChars = " \t\n\r"); + const std::string ToLower(const std::string& str); +//! delete white spaces at beginning and end of string +inline std::string Trim(const std::string& str, const std::string dropChars = " \t\n\r") +{ + std::string res = str; + res.erase(str.find_last_not_of(dropChars)+1); + return res.erase(0, res.find_first_not_of(dropChars)); +} + //! get string representation of any object/variable, as long as it can pipe to a stream template<typename T> inline std::string SPrint(const T &input) @@ -533,4 +539,3 @@ void ShowWeights(); } // namespace -#endif |