From 27515f5de1fe952489d9cab8d6dee6304dc612ae Mon Sep 17 00:00:00 2001 From: Tetsuo Kiso Date: Wed, 4 Apr 2012 22:04:51 +0900 Subject: 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. --- mert/Data.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mert/Data.cpp') 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); -- cgit v1.2.3