From 0841b45d67b355a963e5cf5b0ba479545c4ce7a6 Mon Sep 17 00:00:00 2001 From: gwdwyy Date: Fri, 12 Jul 2013 17:59:30 +0800 Subject: [PATCH] init KeyWordExt.cpp/h --- src/KeyWordExt.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/KeyWordExt.h | 22 ++++++++++++++++++++++ src/Makefile | 5 ++++- src/Segment.cpp | 8 ++++---- 4 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 src/KeyWordExt.cpp create mode 100644 src/KeyWordExt.h diff --git a/src/KeyWordExt.cpp b/src/KeyWordExt.cpp new file mode 100644 index 0000000..f8369b1 --- /dev/null +++ b/src/KeyWordExt.cpp @@ -0,0 +1,38 @@ +#include "KeyWordExt.h" + + +namespace CppJieba +{ + + KeyWordExt::KeyWordExt() + { + } + + KeyWordExt::~KeyWordExt() + { + } + + bool KeyWordExt::init(const char * const filePath) + { + return true; + } + + bool KeyWordExt::destroy() + { + return true; + } + +} + + +#ifdef KEYWORDEXT_UT + +using namespace CppJieba; + +int main() +{ + KeyWordExt ext; + return 0; +} + +#endif diff --git a/src/KeyWordExt.h b/src/KeyWordExt.h new file mode 100644 index 0000000..72b7eaa --- /dev/null +++ b/src/KeyWordExt.h @@ -0,0 +1,22 @@ +#ifndef CPPJIEBA_KEYWORDEXT_H +#define CPPJIEBA_KEYWORDEXT_H + +#include "Segment.h" + +namespace CppJieba +{ + class KeyWordExt + { + private: + Segment _segment; + public: + KeyWordExt(); + ~KeyWordExt(); + bool init(const char * const filePath); + bool destroy(); + + }; + +} + +#endif diff --git a/src/Makefile b/src/Makefile index 851d984..603b0c5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -41,7 +41,10 @@ Trie.ut: Trie.cpp Trie.h globals.h $(CMLIB) $(CC) -o $@ $< -DTRIE_UT $(CMLIB) Segment.ut: Segment.cpp Trie.cpp Segment.h Trie.h globals.h $(CMLIB) - $(CC) -o $@ Segment.cpp Trie.cpp -DSEGMENT_UT $(CMLIB) + $(CC) -o $@ Segment.cpp Trie.cpp -DSEGMENT_UT $(CMLIB) -liconv + +KeyWordExt.ut: KeyWordExt.cpp KeyWordExt.h Segment.h Trie.h globals.h $(CMLIB) + $(CC) -o $@ KeyWordExt.cpp Segment.cpp Trie.cpp -DKEYWORDEXT_UT $(CMLIB) -liconv clean: rm -f *.o *.d *.ut $(LIBA) diff --git a/src/Segment.cpp b/src/Segment.cpp index 41479b2..9a4520e 100644 --- a/src/Segment.cpp +++ b/src/Segment.cpp @@ -366,19 +366,19 @@ int main() string title; title = "我来到北京清华大学"; res.clear(); - segment.extract(title, res); + segment.extract(title, res, 5); title = "特价!camel骆驼 柔软舒适头层牛皮平底凉鞋女 休闲平跟妈妈鞋夏"; res.clear(); - segment.extract(title, res); + segment.extract(title, res, 5); title = "包邮拉菲草18cm大檐进口草帽子超强遮阳防晒欧美日韩新款夏天 女"; res.clear(); - segment.extract(title, res); + segment.extract(title, res, 5); title = "2013新款19CM超大檐帽 遮阳草帽子 沙滩帽防晒大檐欧美新款夏天女"; res.clear(); - segment.extract(title, res); + segment.extract(title, res, 5); segment.destroy(); return 0;