Skip to content

Commit 98086d8

Browse files
committed
[add] fix commit
0 parents  commit 98086d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+16191
-0
lines changed

.gitignore

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
###############
2+
# object file #
3+
###############
4+
*.o
5+
*.lo
6+
*.la
7+
*.deps
8+
*.libs
9+
10+
###############
11+
# build #
12+
###############
13+
build
14+
config.h
15+
16+
###############
17+
# config #
18+
###############
19+
*.cnf
20+
21+
###############
22+
# output #
23+
###############
24+
include/
25+
lib/
26+
bin/
27+
tools/train/lgdpj
28+
tools/train/lgsrl
29+
tools/train/otcws
30+
tools/train/otcws-customized
31+
tools/train/otpos
32+
tools/train/otner
33+
tools/train/maxent
34+
35+
###############
36+
# data file #
37+
###############
38+
new_ltp_data/
39+
ltp_data/
40+
41+
##################
42+
# running folder #
43+
##################
44+
dummy/

CMakeLists.txt

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
cmake_minimum_required (VERSION 2.8.0)
2+
project ("LTP - Chinese Word Segmentation Component.")
3+
4+
# project attributes section
5+
# -- config cmake modules path
6+
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
7+
8+
set (CMAKE_CXX_FLAGS "-g")
9+
10+
if (APPLE)
11+
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libstdc++ -Wno-error=c++11-narrowing")
12+
endif(APPLE)
13+
14+
if (MINGW)
15+
set(CMAKE_CXX_FLAGS "-std=c++11 -Wno-narrowing -fpermissive")
16+
endif (MINGW)
17+
18+
# -- config output directories
19+
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
20+
set (LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
21+
set (INCLUDE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/include)
22+
23+
# -- config source directories
24+
set (SOURCE_DIR ${PROJECT_SOURCE_DIR}/src)
25+
set (THIRDPARTY_DIR ${PROJECT_SOURCE_DIR}/thirdparty)
26+
27+
# -- config resource directories
28+
set (CONFIGURE_DIR ${PROJECT_SOURCE_DIR}/conf)
29+
30+
# compiling section
31+
# -- compile shipped libraries
32+
add_subdirectory (thirdparty)
33+
34+
# -- compile source code
35+
add_subdirectory (src)
36+
37+
# compile testing
38+
add_subdirectory (test)

Makefile

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
##############################################################
2+
# CMake Project Wrapper Makefile #
3+
##############################################################
4+
5+
SHELL := /bin/bash
6+
RM := rm -rf
7+
8+
all: ./build/Makefile
9+
@ $(MAKE) -C build
10+
11+
./build/Makefile:
12+
@ (cd build >/dev/null 2>&1 && cmake ..)
13+
14+
distclean:
15+
@- (cd build >/dev/null 2>&1 && cmake .. >/dev/null 2>&1)
16+
@- $(MAKE) --silent -C build clean || true
17+
@- $(RM) ./build/Makefile
18+
@- $(RM) ./build/src
19+
@- $(RM) ./build/test
20+
@- $(RM) ./build/CMake*
21+
@- $(RM) ./build/cmake.*
22+
@- $(RM) ./build/*.cmake
23+
@- $(RM) ./build/*.txt
24+
@- $(RM) ./docs/*.html
25+
@- $(RM) ./docs/*.css
26+
@- $(RM) ./docs/*.png
27+
@- $(RM) ./docs/*.jpg
28+
@- $(RM) ./docs/*.gif
29+
@- $(RM) ./docs/*.tiff
30+
@- $(RM) ./docs/*.php
31+
@- $(RM) ./docs/search
32+
@- $(RM) ./docs/installdox
33+
34+
35+
ifeq ($(findstring distclean,$(MAKECMDGOALS)),)
36+
37+
$(MAKECMDGOALS): ./build/Makefile
38+
@ $(MAKE) -C build $(MAKECMDGOALS)
39+
40+
endif

configure

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#! /bin/bash
2+
if [ ! -d build ]; then
3+
mkdir -p build
4+
fi
5+
6+
(cd build >/dev/null 2>&1 && cmake -DCMAKE_BUILD_TYPE=Release .. "$@")

src/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set (utils_DIR ${SOURCE_DIR}/utils)
2+
set (segmentor_DIR ${SOURCE_DIR}/segmentor)
3+
4+
add_subdirectory ("segmentor")
5+

src/framework/serializable.h

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef __LTP_FRAMEWORK_SERIALIZABLE_H__
2+
#define __LTP_FRAMEWORK_SERIALIZABLE_H__
3+
4+
#include <iostream>
5+
6+
namespace ltp {
7+
namespace framework {
8+
9+
class Serializable {
10+
protected:
11+
void write_uint(std::ostream & out, unsigned int val) {
12+
out.write(reinterpret_cast<const char *>(&val), sizeof(unsigned int));
13+
}
14+
15+
unsigned int read_uint(std::istream & in) {
16+
char p[4];
17+
in.read(reinterpret_cast<char*>(p), sizeof(unsigned int));
18+
return *reinterpret_cast<const unsigned int*>(p);
19+
}
20+
};
21+
22+
} // end for framework
23+
} // end for ltp
24+
25+
#endif // end for __LTP_FRAMEWORK_SERIALIZABLE_H__

src/segmentor/CMakeLists.txt

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
include_directories ( ${SOURCE_DIR} ${THIRDPARTY_DIR}/boost/include )
2+
3+
set (segment_VERSION "0.1.0")
4+
5+
set (segment_SRC
6+
decoder.cpp
7+
featurespace.cpp
8+
rulebase.cpp
9+
model.cpp
10+
extractor.cpp
11+
segmentor.cpp)
12+
13+
# -----------------------------------------------
14+
# STATIC LIBRARY
15+
# -----------------------------------------------
16+
add_library (segmentor_static_lib segment_dll.cpp ${segment_SRC})
17+
18+
target_link_libraries (segmentor_static_lib boost_regex_static_lib)
19+
20+
set_target_properties (segmentor_static_lib
21+
PROPERTIES
22+
OUTPUT_NAME segmentor)
23+
24+
# -----------------------------------------------
25+
# SHARED LIBRARY
26+
# -----------------------------------------------
27+
add_library (segmentor_shared_lib SHARED segment_dll.cpp ${segment_SRC})
28+
29+
target_link_libraries (segmentor_shared_lib boost_regex_shared_lib)
30+
31+
set_target_properties (segmentor_shared_lib PROPERTIES
32+
VERSION ${segment_VERSION}
33+
OUTPUT_NAME segmentor)
34+
35+
link_directories ( ${LIBRARY_OUTPUT_PATH} )
36+
37+
# -----------------------------------------------
38+
# TOOLKIT #1
39+
# -----------------------------------------------
40+
add_executable (otcws otcws.cpp ${segment_SRC})
41+
42+
target_link_libraries (otcws boost_regex_static_lib)
43+
44+
# -----------------------------------------------
45+
# TOOLKIT #2
46+
# -----------------------------------------------
47+
add_executable (otcws-customized otcws_customized.cpp
48+
${segment_SRC} customized_segmentor.cpp)
49+
50+
target_link_libraries (otcws-customized boost_regex_static_lib)
51+
52+
configure_file (
53+
segment_dll.h
54+
${INCLUDE_OUTPUT_PATH}/ltp/segment_dll.h)

src/segmentor/customized_options.h

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifndef __LTP_SEGMENTOR_CUSTOMIZED_SEGMENTOR_OPTIONS_H__
2+
#define __LTP_SEGMENTOR_CUSTOMIZED_SEGMENTOR_OPTIONS_H__
3+
4+
#include "options.h"
5+
6+
namespace ltp {
7+
namespace segmentor {
8+
9+
struct CustomizedTrainOptions : public TrainOptions {
10+
//! The name of the baseline model. aka. model from phase#1
11+
std::string baseline_model_file;
12+
};
13+
14+
struct CustomizedTestOptions : public TestOptions {
15+
//! The name of the baseline model. aka. model from phase#1
16+
std::string baseline_model_file;
17+
};
18+
19+
struct CustomizedDumpOptions : public DumpOptions {
20+
};
21+
22+
} // end for namespace segmentor
23+
} // end for namespace ltp
24+
25+
#endif // end for __LTP_SEGMENTOR_CUSTOMIZED_SEGMENTOR_OPTIONS_H__

0 commit comments

Comments
 (0)