1diff -Npur cppjieba/deps/limonp/StringUtil.hpp cppjiebap/deps/limonp/StringUtil.hpp 2--- cppjieba/deps/limonp/StringUtil.hpp 2020-03-11 09:30:52.000000000 +0800 3+++ cppjiebap/deps/limonp/StringUtil.hpp 2020-12-15 16:02:38.000000000 +0800 4@@ -84,12 +84,12 @@ inline bool IsSpace(unsigned c) { 5 } 6 7 inline std::string& LTrim(std::string &s) { 8- s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<unsigned, bool>(IsSpace)))); 9+ s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::function<unsigned(bool)>(IsSpace)))); 10 return s; 11 } 12 13 inline std::string& RTrim(std::string &s) { 14- s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<unsigned, bool>(IsSpace))).base(), s.end()); 15+ s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::function<unsigned(bool)>(IsSpace))).base(), s.end()); 16 return s; 17 } 18 19@@ -98,12 +98,12 @@ inline std::string& Trim(std::string &s) 20 } 21 22 inline std::string& LTrim(std::string & s, char x) { 23- s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::bind2nd(std::equal_to<char>(), x)))); 24+ s.erase(s.begin(), std::find_if(s.begin(), s.end(), [x](char c) -> bool { return c != x; })); 25 return s; 26 } 27 28 inline std::string& RTrim(std::string & s, char x) { 29- s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::bind2nd(std::equal_to<char>(), x))).base(), s.end()); 30+ s.erase(std::find_if(s.rbegin(), s.rend(), [x](char c) -> bool { return c != x; } ).base(), s.end()); 31 return s; 32 } 33 34diff -Npur cppjieba/include/cppjieba/Jieba.hpp cppjiebap/include/cppjieba/Jieba.hpp 35--- cppjieba/include/cppjieba/Jieba.hpp 2020-03-11 09:30:52.000000000 +0800 36+++ cppjiebap/include/cppjieba/Jieba.hpp 2020-12-15 16:01:46.000000000 +0800 37@@ -10,17 +10,14 @@ class Jieba { 38 public: 39 Jieba(const string& dict_path, 40 const string& model_path, 41- const string& user_dict_path, 42- const string& idfPath, 43- const string& stopWordPath) 44+ const string& user_dict_path) 45 : dict_trie_(dict_path, user_dict_path), 46 model_(model_path), 47 mp_seg_(&dict_trie_), 48 hmm_seg_(&model_), 49 mix_seg_(&dict_trie_, &model_), 50 full_seg_(&dict_trie_), 51- query_seg_(&dict_trie_, &model_), 52- extractor(&dict_trie_, &model_, idfPath, stopWordPath) { 53+ query_seg_(&dict_trie_, &model_) { 54 } 55 ~Jieba() { 56 } 57@@ -121,8 +118,6 @@ class Jieba { 58 FullSegment full_seg_; 59 QuerySegment query_seg_; 60 61- public: 62- KeywordExtractor extractor; 63 }; // class Jieba 64 65 } // namespace cppjieba 66diff -Npur cppjieba/test/demo.cpp cppjiebap/test/demo.cpp 67--- cppjieba/test/demo.cpp 2020-03-11 09:30:52.000000000 +0800 68+++ cppjiebap/test/demo.cpp 2020-12-15 16:01:46.000000000 +0800 69@@ -11,9 +11,7 @@ const char* const STOP_WORD_PATH = "../d 70 int main(int argc, char** argv) { 71 cppjieba::Jieba jieba(DICT_PATH, 72 HMM_PATH, 73- USER_DICT_PATH, 74- IDF_PATH, 75- STOP_WORD_PATH); 76+ USER_DICT_PATH); 77 vector<string> words; 78 vector<cppjieba::Word> jiebawords; 79 string s; 80@@ -71,10 +69,5 @@ int main(int argc, char** argv) { 81 cout << tagres << endl; 82 83 cout << "[demo] Keyword Extraction" << endl; 84- const size_t topk = 5; 85- vector<cppjieba::KeywordExtractor::Word> keywordres; 86- jieba.extractor.Extract(s, keywordres, topk); 87- cout << s << endl; 88- cout << keywordres << endl; 89 return EXIT_SUCCESS; 90 } 91diff -Npur cppjieba/test/unittest/jieba_test.cpp cppjiebap/test/unittest/jieba_test.cpp 92--- cppjieba/test/unittest/jieba_test.cpp 2020-03-11 09:30:52.000000000 +0800 93+++ cppjiebap/test/unittest/jieba_test.cpp 2020-12-15 16:01:46.000000000 +0800 94@@ -6,9 +6,7 @@ using namespace cppjieba; 95 TEST(JiebaTest, Test1) { 96 cppjieba::Jieba jieba("../dict/jieba.dict.utf8", 97 "../dict/hmm_model.utf8", 98- "../dict/user.dict.utf8", 99- "../dict/idf.utf8", 100- "../dict/stop_words.utf8"); 101+ "../dict/user.dict.utf8"); 102 vector<string> words; 103 string result; 104 105@@ -43,9 +41,7 @@ TEST(JiebaTest, Test1) { 106 TEST(JiebaTest, WordTest) { 107 cppjieba::Jieba jieba("../dict/jieba.dict.utf8", 108 "../dict/hmm_model.utf8", 109- "../dict/user.dict.utf8", 110- "../dict/idf.utf8", 111- "../dict/stop_words.utf8"); 112+ "../dict/user.dict.utf8"); 113 vector<Word> words; 114 string result; 115 116@@ -85,9 +81,7 @@ TEST(JiebaTest, WordTest) { 117 TEST(JiebaTest, InsertUserWord) { 118 cppjieba::Jieba jieba("../dict/jieba.dict.utf8", 119 "../dict/hmm_model.utf8", 120- "../dict/user.dict.utf8", 121- "../dict/idf.utf8", 122- "../dict/stop_words.utf8"); 123+ "../dict/user.dict.utf8"); 124 vector<string> words; 125 string result; 126 127@@ -120,14 +114,4 @@ TEST(JiebaTest, InsertUserWord) { 128 jieba.Cut("同一个世界,同一个梦想", words); 129 result = Join(words.begin(), words.end(), "/"); 130 ASSERT_EQ(result, "同一个世界,同一个梦想"); 131- 132- { 133- string s("一部iPhone6"); 134- string res; 135- vector<KeywordExtractor::Word> wordweights; 136- size_t topN = 5; 137- jieba.extractor.Extract(s, wordweights, topN); 138- res << wordweights; 139- ASSERT_EQ(res, "[{\"word\": \"iPhone6\", \"offset\": [6], \"weight\": 11.7392}, {\"word\": \"\xE4\xB8\x80\xE9\x83\xA8\", \"offset\": [0], \"weight\": 6.47592}]"); 140- } 141 } 142