diff --git a/ChangeLog.md b/ChangeLog.md index 65fd53c..079ca19 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,6 +4,7 @@ 1. 支持多个userdict载入,多词典路径用英文冒号(:)作为分隔符,就当是向环境变量PATH致敬,哈哈。 2. userdict是不带权重的,之前对于新的userword默认设置词频权重为最大值,现已支持可配置,默认使用中位值。 +3. 修改一些代码风格,比如命名空间小写化,从CppJieba变成cppjieba。 ## v3.2.1 diff --git a/server/server.cpp b/server/server.cpp index 8c8274c..9279801 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -8,11 +8,11 @@ #include "Jieba.hpp" using namespace husky; -using namespace CppJieba; +using namespace cppjieba; class ReqHandler: public IRequestHandler { public: - ReqHandler(const CppJieba::Jieba& jieba) + ReqHandler(const cppjieba::Jieba& jieba) : jieba_(jieba) { } @@ -63,7 +63,7 @@ class ReqHandler: public IRequestHandler { } } private: - const CppJieba::Jieba& jieba_; + const cppjieba::Jieba& jieba_; }; bool Run(int argc, char** argv) { @@ -83,7 +83,7 @@ bool Run(int argc, char** argv) { LogInfo("config info: %s", conf.getConfigInfo().c_str()); - CppJieba::Jieba jieba(dictPath, + cppjieba::Jieba jieba(dictPath, modelPath, userDictPath); diff --git a/src/DictTrie.hpp b/src/DictTrie.hpp index 39b6b8a..c704644 100644 --- a/src/DictTrie.hpp +++ b/src/DictTrie.hpp @@ -13,7 +13,7 @@ #include "TransCode.hpp" #include "Trie.hpp" -namespace CppJieba { +namespace cppjieba { using namespace limonp; diff --git a/src/FullSegment.hpp b/src/FullSegment.hpp index e3c2fc1..0464e05 100644 --- a/src/FullSegment.hpp +++ b/src/FullSegment.hpp @@ -9,7 +9,7 @@ #include "SegmentBase.hpp" #include "TransCode.hpp" -namespace CppJieba { +namespace cppjieba { class FullSegment: public SegmentBase { public: FullSegment(const string& dictPath) { diff --git a/src/HMMModel.hpp b/src/HMMModel.hpp index ae07703..625507c 100644 --- a/src/HMMModel.hpp +++ b/src/HMMModel.hpp @@ -3,7 +3,7 @@ #include "limonp/StringUtil.hpp" -namespace CppJieba { +namespace cppjieba { using namespace limonp; typedef unordered_map EmitProbMap; @@ -137,6 +137,6 @@ struct HMMModel { vector emitProbVec; }; // struct HMMModel -} // namespace CppJieba +} // namespace cppjieba #endif diff --git a/src/HMMSegment.hpp b/src/HMMSegment.hpp index 90daa56..839a610 100644 --- a/src/HMMSegment.hpp +++ b/src/HMMSegment.hpp @@ -8,7 +8,7 @@ #include "HMMModel.hpp" #include "SegmentBase.hpp" -namespace CppJieba { +namespace cppjieba { class HMMSegment: public SegmentBase { public: HMMSegment(const string& filePath) { @@ -175,6 +175,6 @@ class HMMSegment: public SegmentBase { bool isNeedDestroy_; }; // class HMMSegment -} // namespace CppJieba +} // namespace cppjieba #endif diff --git a/src/Jieba.hpp b/src/Jieba.hpp index 879134b..bbe88fc 100644 --- a/src/Jieba.hpp +++ b/src/Jieba.hpp @@ -5,7 +5,7 @@ #include "PosTagger.hpp" #include "LevelSegment.hpp" -namespace CppJieba { +namespace cppjieba { class Jieba { public: diff --git a/src/KeywordExtractor.hpp b/src/KeywordExtractor.hpp index 3f6acd5..6977fdd 100644 --- a/src/KeywordExtractor.hpp +++ b/src/KeywordExtractor.hpp @@ -5,7 +5,7 @@ #include #include -namespace CppJieba { +namespace cppjieba { using namespace limonp; /*utf8*/ diff --git a/src/LevelSegment.hpp b/src/LevelSegment.hpp index dbc37d1..0fc14dc 100644 --- a/src/LevelSegment.hpp +++ b/src/LevelSegment.hpp @@ -3,7 +3,7 @@ #include "MPSegment.hpp" -namespace CppJieba { +namespace cppjieba { class LevelSegment: public SegmentBase{ public: @@ -77,6 +77,6 @@ class LevelSegment: public SegmentBase{ MPSegment mpSeg_; }; // class LevelSegment -} // namespace CppJieba +} // namespace cppjieba #endif // CPPJIEBA_LEVELSEGMENT_H diff --git a/src/MPSegment.hpp b/src/MPSegment.hpp index bcf5c99..f031fdc 100644 --- a/src/MPSegment.hpp +++ b/src/MPSegment.hpp @@ -8,7 +8,7 @@ #include "DictTrie.hpp" #include "SegmentBase.hpp" -namespace CppJieba { +namespace cppjieba { class MPSegment: public SegmentBase { public: @@ -109,6 +109,6 @@ class MPSegment: public SegmentBase { bool isNeedDestroy_; }; // class MPSegment -} // namespace CppJieba +} // namespace cppjieba #endif diff --git a/src/MixSegment.hpp b/src/MixSegment.hpp index 8d8a8b6..5732654 100644 --- a/src/MixSegment.hpp +++ b/src/MixSegment.hpp @@ -6,7 +6,7 @@ #include "HMMSegment.hpp" #include "limonp/StringUtil.hpp" -namespace CppJieba { +namespace cppjieba { class MixSegment: public SegmentBase { public: MixSegment(const string& mpSegDict, const string& hmmSegDict, @@ -86,6 +86,6 @@ class MixSegment: public SegmentBase { }; // class MixSegment -} // namespace CppJieba +} // namespace cppjieba #endif diff --git a/src/PosTagger.hpp b/src/PosTagger.hpp index 076d9f3..8148a10 100644 --- a/src/PosTagger.hpp +++ b/src/PosTagger.hpp @@ -5,7 +5,7 @@ #include "limonp/StringUtil.hpp" #include "DictTrie.hpp" -namespace CppJieba { +namespace cppjieba { using namespace limonp; static const char* const POS_M = "m"; @@ -74,6 +74,6 @@ class PosTagger { MixSegment segment_; }; // class PosTagger -} // namespace CppJieba +} // namespace cppjieba #endif diff --git a/src/PreFilter.hpp b/src/PreFilter.hpp index bea43f0..64caa7a 100644 --- a/src/PreFilter.hpp +++ b/src/PreFilter.hpp @@ -3,7 +3,7 @@ #include "TransCode.hpp" -namespace CppJieba { +namespace cppjieba { //class PreFilterIterator { // public: @@ -56,6 +56,6 @@ class PreFilter { const unordered_set& symbols_; }; // class PreFilter -} // namespace CppJieba +} // namespace cppjieba #endif // CPPJIEBA_PRE_FILTER_H diff --git a/src/QuerySegment.hpp b/src/QuerySegment.hpp index b5d7bb4..7c95035 100644 --- a/src/QuerySegment.hpp +++ b/src/QuerySegment.hpp @@ -12,7 +12,7 @@ #include "TransCode.hpp" #include "DictTrie.hpp" -namespace CppJieba { +namespace cppjieba { class QuerySegment: public SegmentBase { public: QuerySegment(const string& dict, const string& model, const string& userDict = "", size_t maxWordLen = 4) diff --git a/src/SegmentBase.hpp b/src/SegmentBase.hpp index f1ece55..12980d0 100644 --- a/src/SegmentBase.hpp +++ b/src/SegmentBase.hpp @@ -6,7 +6,7 @@ #include -namespace CppJieba { +namespace cppjieba { //const char* const SPECIAL_CHARS = " \t\n,。"; const Rune SPECIAL_SYMBOL[] = {32u, 9u, 10u, 65292u, 12290u}; @@ -32,6 +32,6 @@ class SegmentBase { unordered_set symbols_; }; // class SegmentBase -} // CppJieba +} // cppjieba #endif diff --git a/src/TransCode.hpp b/src/TransCode.hpp index 5583f46..feba971 100644 --- a/src/TransCode.hpp +++ b/src/TransCode.hpp @@ -9,7 +9,7 @@ #include "limonp/StringUtil.hpp" #include "limonp/LocalVector.hpp" -namespace CppJieba { +namespace cppjieba { using namespace limonp; @@ -65,6 +65,6 @@ inline void encode(const vector& input, vector& output) { } } // namespace TransCode -} // namespace CppJieba +} // namespace cppjieba #endif diff --git a/src/Trie.hpp b/src/Trie.hpp index 8ab502b..4fbaa11 100644 --- a/src/Trie.hpp +++ b/src/Trie.hpp @@ -5,7 +5,7 @@ #include #include -namespace CppJieba { +namespace cppjieba { using namespace std; const size_t MAX_WORD_LENGTH = 512; diff --git a/test/demo.cpp b/test/demo.cpp index ab1c21d..2477b20 100644 --- a/test/demo.cpp +++ b/test/demo.cpp @@ -3,7 +3,7 @@ using namespace std; int main(int argc, char** argv) { - CppJieba::Jieba jieba("../dict/jieba.dict.utf8", + cppjieba::Jieba jieba("../dict/jieba.dict.utf8", "../dict/hmm_model.utf8", "../dict/user.dict.utf8"); vector words; diff --git a/test/load_test.cpp b/test/load_test.cpp index 26d3a54..44aee66 100644 --- a/test/load_test.cpp +++ b/test/load_test.cpp @@ -7,7 +7,7 @@ #include "../src/KeywordExtractor.hpp" #include "../src/limonp/Colors.hpp" -using namespace CppJieba; +using namespace cppjieba; void cut(size_t times = 50) { MixSegment seg("../dict/jieba.dict.utf8", "../dict/hmm_model.utf8"); diff --git a/test/unittest/jieba_test.cpp b/test/unittest/jieba_test.cpp index e5ec8fb..eaaf548 100644 --- a/test/unittest/jieba_test.cpp +++ b/test/unittest/jieba_test.cpp @@ -1,10 +1,10 @@ #include "src/Jieba.hpp" #include "gtest/gtest.h" -using namespace CppJieba; +using namespace cppjieba; TEST(JiebaTest, Test1) { - CppJieba::Jieba jieba("../dict/jieba.dict.utf8", + cppjieba::Jieba jieba("../dict/jieba.dict.utf8", "../dict/hmm_model.utf8", "../dict/user.dict.utf8"); vector words; @@ -58,7 +58,7 @@ TEST(JiebaTest, Test1) { } TEST(JiebaTest, InsertUserWord) { - CppJieba::Jieba jieba("../dict/jieba.dict.utf8", + cppjieba::Jieba jieba("../dict/jieba.dict.utf8", "../dict/hmm_model.utf8", "../dict/user.dict.utf8"); vector words; diff --git a/test/unittest/keyword_extractor_test.cpp b/test/unittest/keyword_extractor_test.cpp index ca1041d..1b9327d 100644 --- a/test/unittest/keyword_extractor_test.cpp +++ b/test/unittest/keyword_extractor_test.cpp @@ -1,7 +1,7 @@ #include "src/KeywordExtractor.hpp" #include "gtest/gtest.h" -using namespace CppJieba; +using namespace cppjieba; TEST(KeywordExtractorTest, Test1) { KeywordExtractor extractor("../test/testdata/extra_dict/jieba.dict.small.utf8", "../dict/hmm_model.utf8", "../dict/idf.utf8", "../dict/stop_words.utf8"); diff --git a/test/unittest/pos_tagger_test.cpp b/test/unittest/pos_tagger_test.cpp index a157a2b..f9733fc 100644 --- a/test/unittest/pos_tagger_test.cpp +++ b/test/unittest/pos_tagger_test.cpp @@ -1,7 +1,7 @@ #include "src/PosTagger.hpp" #include "gtest/gtest.h" -using namespace CppJieba; +using namespace cppjieba; static const char * const QUERY_TEST1 = "我是蓝翔技工拖拉机学院手扶拖拉机专业的。不用多久,我就会升职加薪,当上总经理,出任CEO,迎娶白富美,走上人生巅峰。"; static const char * const ANS_TEST1 = "[\"我:r\", \"是:v\", \"蓝翔:x\", \"技工:n\", \"拖拉机:n\", \"学院:n\", \"手扶拖拉机:n\", \"专业:n\", \"的:uj\", \"。:x\", \"不用:v\", \"多久:m\", \",:x\", \"我:r\", \"就:d\", \"会:v\", \"升职:v\", \"加薪:nr\", \",:x\", \"当上:t\", \"总经理:n\", \",:x\", \"出任:v\", \"CEO:eng\", \",:x\", \"迎娶:v\", \"白富:x\", \"美:ns\", \",:x\", \"走上:v\", \"人生:n\", \"巅峰:n\", \"。:x\"]"; diff --git a/test/unittest/pre_filter_test.cpp b/test/unittest/pre_filter_test.cpp index 12409e2..9dd64f7 100644 --- a/test/unittest/pre_filter_test.cpp +++ b/test/unittest/pre_filter_test.cpp @@ -1,7 +1,7 @@ #include "gtest/gtest.h" #include "src/PreFilter.hpp" -using namespace CppJieba; +using namespace cppjieba; TEST(PreFilterTest, Test1) { unordered_set symbol; diff --git a/test/unittest/segments_test.cpp b/test/unittest/segments_test.cpp index e631a78..9458813 100644 --- a/test/unittest/segments_test.cpp +++ b/test/unittest/segments_test.cpp @@ -7,7 +7,7 @@ #include "src/LevelSegment.hpp" #include "gtest/gtest.h" -using namespace CppJieba; +using namespace cppjieba; TEST(MixSegmentTest, Test1) { MixSegment segment("../dict/jieba.dict.utf8", "../dict/hmm_model.utf8");; diff --git a/test/unittest/trie_test.cpp b/test/unittest/trie_test.cpp index 035be26..ffdfd8c 100644 --- a/test/unittest/trie_test.cpp +++ b/test/unittest/trie_test.cpp @@ -2,7 +2,7 @@ #include "src/MPSegment.hpp" #include "gtest/gtest.h" -using namespace CppJieba; +using namespace cppjieba; static const char* const DICT_FILE = "../test/testdata/extra_dict/jieba.dict.small.utf8";