diff -Npur cppjieba/deps/limonp/StringUtil.hpp cppjiebap/deps/limonp/StringUtil.hpp --- cppjieba/deps/limonp/StringUtil.hpp 2020-03-11 09:30:52.000000000 +0800 +++ cppjiebap/deps/limonp/StringUtil.hpp 2020-12-15 16:02:38.000000000 +0800 @@ -84,12 +84,12 @@ inline bool IsSpace(unsigned c) { } inline std::string& LTrim(std::string &s) { - s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun(IsSpace)))); + s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::function(IsSpace)))); return s; } inline std::string& RTrim(std::string &s) { - s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun(IsSpace))).base(), s.end()); + s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::function(IsSpace))).base(), s.end()); return s; } @@ -98,12 +98,12 @@ inline std::string& Trim(std::string &s) } inline std::string& LTrim(std::string & s, char x) { - s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::bind2nd(std::equal_to(), x)))); + s.erase(s.begin(), std::find_if(s.begin(), s.end(), [x](char c) -> bool { return c != x; })); return s; } inline std::string& RTrim(std::string & s, char x) { - s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::bind2nd(std::equal_to(), x))).base(), s.end()); + s.erase(std::find_if(s.rbegin(), s.rend(), [x](char c) -> bool { return c != x; } ).base(), s.end()); return s; } diff -Npur cppjieba/include/cppjieba/Jieba.hpp cppjiebap/include/cppjieba/Jieba.hpp --- cppjieba/include/cppjieba/Jieba.hpp 2020-03-11 09:30:52.000000000 +0800 +++ cppjiebap/include/cppjieba/Jieba.hpp 2020-12-15 16:01:46.000000000 +0800 @@ -10,17 +10,14 @@ class Jieba { public: Jieba(const string& dict_path, const string& model_path, - const string& user_dict_path, - const string& idfPath, - const string& stopWordPath) + const string& user_dict_path) : dict_trie_(dict_path, user_dict_path), model_(model_path), mp_seg_(&dict_trie_), hmm_seg_(&model_), mix_seg_(&dict_trie_, &model_), full_seg_(&dict_trie_), - query_seg_(&dict_trie_, &model_), - extractor(&dict_trie_, &model_, idfPath, stopWordPath) { + query_seg_(&dict_trie_, &model_) { } ~Jieba() { } @@ -121,8 +118,6 @@ class Jieba { FullSegment full_seg_; QuerySegment query_seg_; - public: - KeywordExtractor extractor; }; // class Jieba } // namespace cppjieba diff -Npur cppjieba/test/demo.cpp cppjiebap/test/demo.cpp --- cppjieba/test/demo.cpp 2020-03-11 09:30:52.000000000 +0800 +++ cppjiebap/test/demo.cpp 2020-12-15 16:01:46.000000000 +0800 @@ -11,9 +11,7 @@ const char* const STOP_WORD_PATH = "../d int main(int argc, char** argv) { cppjieba::Jieba jieba(DICT_PATH, HMM_PATH, - USER_DICT_PATH, - IDF_PATH, - STOP_WORD_PATH); + USER_DICT_PATH); vector words; vector jiebawords; string s; @@ -71,10 +69,5 @@ int main(int argc, char** argv) { cout << tagres << endl; cout << "[demo] Keyword Extraction" << endl; - const size_t topk = 5; - vector keywordres; - jieba.extractor.Extract(s, keywordres, topk); - cout << s << endl; - cout << keywordres << endl; return EXIT_SUCCESS; } diff -Npur cppjieba/test/unittest/jieba_test.cpp cppjiebap/test/unittest/jieba_test.cpp --- cppjieba/test/unittest/jieba_test.cpp 2020-03-11 09:30:52.000000000 +0800 +++ cppjiebap/test/unittest/jieba_test.cpp 2020-12-15 16:01:46.000000000 +0800 @@ -6,9 +6,7 @@ using namespace cppjieba; TEST(JiebaTest, Test1) { cppjieba::Jieba jieba("../dict/jieba.dict.utf8", "../dict/hmm_model.utf8", - "../dict/user.dict.utf8", - "../dict/idf.utf8", - "../dict/stop_words.utf8"); + "../dict/user.dict.utf8"); vector words; string result; @@ -43,9 +41,7 @@ TEST(JiebaTest, Test1) { TEST(JiebaTest, WordTest) { cppjieba::Jieba jieba("../dict/jieba.dict.utf8", "../dict/hmm_model.utf8", - "../dict/user.dict.utf8", - "../dict/idf.utf8", - "../dict/stop_words.utf8"); + "../dict/user.dict.utf8"); vector words; string result; @@ -85,9 +81,7 @@ TEST(JiebaTest, WordTest) { TEST(JiebaTest, InsertUserWord) { cppjieba::Jieba jieba("../dict/jieba.dict.utf8", "../dict/hmm_model.utf8", - "../dict/user.dict.utf8", - "../dict/idf.utf8", - "../dict/stop_words.utf8"); + "../dict/user.dict.utf8"); vector words; string result; @@ -120,14 +114,4 @@ TEST(JiebaTest, InsertUserWord) { jieba.Cut("同一个世界,同一个梦想", words); result = Join(words.begin(), words.end(), "/"); ASSERT_EQ(result, "同一个世界,同一个梦想"); - - { - string s("一部iPhone6"); - string res; - vector wordweights; - size_t topN = 5; - jieba.extractor.Extract(s, wordweights, topN); - res << wordweights; - ASSERT_EQ(res, "[{\"word\": \"iPhone6\", \"offset\": [6], \"weight\": 11.7392}, {\"word\": \"\xE4\xB8\x80\xE9\x83\xA8\", \"offset\": [0], \"weight\": 6.47592}]"); - } }