diff options
author | Tetsuo Kiso <tetsuo-s@is.naist.jp> | 2012-04-04 17:04:51 +0400 |
---|---|---|
committer | Tetsuo Kiso <tetsuo-s@is.naist.jp> | 2012-04-04 17:04:51 +0400 |
commit | 1ade69a546120ab3f8444f9aaa83e49fa8a98fbb (patch) | |
tree | b948f6b01c85bfe7f9a6d043fec2b900f9726eba /mert/Data.cpp | |
parent | ad6e1e210eae3ed339f050c59e1df8853c541fb2 (diff) |
Add a function to check whether a string ends with a suffix.
- Use the function in Data::InitFeatureMap().
- Add an unit test for InitFeatureMap().
- Move helper functions for Data::loadnbest() to public for unit testing.
Diffstat (limited to 'mert/Data.cpp')
-rw-r--r-- | mert/Data.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/mert/Data.cpp b/mert/Data.cpp index b1950ea4e..b0b8f12be 100644 --- a/mert/Data.cpp +++ b/mert/Data.cpp @@ -173,14 +173,13 @@ void Data::InitFeatureMap(const string& str) { string features = ""; string tmp_name = ""; size_t tmp_index = 0; - string::size_type loc; char tmp[64]; // for snprintf(); while (!buf.empty()) { getNextPound(buf, substr); // string ending with ":" are skipped, because they are the names of the features - if ((loc = substr.find_last_of(":")) != substr.length()-1) { + if (!EndsWith(substr, ":")) { snprintf(tmp, sizeof(tmp), "%s_%lu ", tmp_name.c_str(), tmp_index); features.append(tmp); |