From f2cc6c07e3770cbbd0f1285d248b59109bee19f8 Mon Sep 17 00:00:00 2001 From: wyy Date: Sat, 23 Nov 2013 06:19:11 -0800 Subject: [PATCH] modify some staff for install --- scripts/CMakeLists.txt | 1 + scripts/cjseg.sh | 5 +++++ src/CMakeLists.txt | 12 ++++++------ src/segment.cpp | 26 +++++++++++++------------- test/testlines.utf8 | 3 +++ 5 files changed, 28 insertions(+), 19 deletions(-) create mode 100755 scripts/cjseg.sh diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 6e31ae6..845f58a 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -1 +1,2 @@ INSTALL(FILES start.sh stop.sh restart.sh DESTINATION /etc/init.d/CppJieba) +INSTALL(FILES cjseg.sh stop.sh restart.sh DESTINATION bin) diff --git a/scripts/cjseg.sh b/scripts/cjseg.sh new file mode 100755 index 0000000..cad476e --- /dev/null +++ b/scripts/cjseg.sh @@ -0,0 +1,5 @@ +if [ $# -lt 2 ]; then + echo "usage: $0 " + exit 1 +fi +cjsegment --dictpath /usr/share/CppJieba/dicts/jieba.dict.utf8 --modelpath /usr/share/CppJieba/dicts/hmm_model.utf8 $1 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c218ff3..1196cef 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,19 +3,19 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) SET(LIBCPPJIEBA_SRC HMMSegment.cpp MixSegment.cpp MPSegment.cpp Trie.cpp) ADD_LIBRARY(cppjieba STATIC ${LIBCPPJIEBA_SRC}) -ADD_EXECUTABLE(segment segment.cpp) -ADD_EXECUTABLE(server server.cpp) +ADD_EXECUTABLE(cjsegment segment.cpp) +ADD_EXECUTABLE(cjserver server.cpp) LINK_DIRECTORIES(Husky) -TARGET_LINK_LIBRARIES(segment cppjieba) -TARGET_LINK_LIBRARIES(server cppjieba husky pthread) +TARGET_LINK_LIBRARIES(cjsegment cppjieba) +TARGET_LINK_LIBRARIES(cjserver cppjieba husky pthread) SET_TARGET_PROPERTIES(cppjieba PROPERTIES VERSION 1.2 SOVERSION 1) +INSTALL(TARGETS cjsegment RUNTIME DESTINATION bin) +INSTALL(TARGETS cjserver RUNTIME DESTINATION bin) INSTALL(TARGETS cppjieba ARCHIVE DESTINATION lib/CppJieba) -INSTALL(TARGETS segment RUNTIME DESTINATION bin/CppJieba) -INSTALL(TARGETS server RUNTIME DESTINATION bin/CppJieba) INSTALL(FILES ChineseFilter.hpp HMMSegment.h MPSegment.h structs.h Trie.h globals.h ISegment.hpp MixSegment.h SegmentBase.hpp TransCode.hpp DESTINATION include/CppJieba) diff --git a/src/segment.cpp b/src/segment.cpp index fbd367d..e4b3835 100644 --- a/src/segment.cpp +++ b/src/segment.cpp @@ -29,7 +29,7 @@ int main(int argc, char ** argv) { cout<<"usage: \n\t"<\n" <<"options:\n" - <<"\t--algorithm\tSupported methods are [cutDAG, cutHMM, cutMix] for now. \n\t\t\tIf not specified, the default is cutDAG\n" + <<"\t--algorithm\tSupported methods are [cutDAG, cutHMM, cutMix] for now. \n\t\t\tIf not specified, the default is cutMix\n" <<"\t--dictpath\tsee example\n" <<"\t--modelpath\tsee example\n" <<"example:\n" @@ -56,18 +56,7 @@ int main(int argc, char ** argv) cut(&seg, arg[1].c_str()); seg.dispose(); } - else if("cutMix" == algorithm) - { - MixSegment seg; - if(!seg.init(dictPath.c_str(), modelPath.c_str())) - { - cout<<"seg init failed."<