forked from HIT-SCIR/ltp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test directories and move src/test to test
- Loading branch information
Showing
14 changed files
with
56,899 additions
and
31,351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,38 @@ | ||
PROJECT ("LTP - Language Technology Platform") | ||
cmake_minimum_required (VERSION 2.8.0) | ||
project ("LTP - Language Technology Platform") | ||
|
||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0) | ||
# project attributes section | ||
# -- config cmake modules path | ||
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) | ||
|
||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) | ||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) | ||
SET(SOURCE ${PROJECT_SOURCE_DIR}/src) | ||
SET(THIRDPARTY ${PROJECT_SOURCE_DIR}/thirdparty) | ||
# -- config output directories | ||
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) | ||
set (LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) | ||
set (INCLUDE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/include) | ||
|
||
SET(CONFIGURE_DIR ${PROJECT_SOURCE_DIR}/conf) | ||
SET(DATA_DIR ${PROJECT_SOURCE_DIR}/ltp_data) | ||
# -- config source directories | ||
set (SOURCE_DIR ${PROJECT_SOURCE_DIR}/src) | ||
set (THIRDPARTY_DIR ${PROJECT_SOURCE_DIR}/thirdparty) | ||
|
||
ADD_SUBDIRECTORY(thirdparty) | ||
ADD_SUBDIRECTORY(src) | ||
# -- config resource directories | ||
set (CONFIGURE_DIR ${PROJECT_SOURCE_DIR}/conf) | ||
set (DATA_DIR ${PROJECT_SOURCE_DIR}/ltp_data) | ||
|
||
# --- GENERATE CONFIGURE FILE AUTOMATICALLY --- | ||
CONFIGURE_FILE( | ||
# compiling section | ||
# -- compile shipped libraries | ||
add_subdirectory (thirdparty) | ||
|
||
# -- compile source code | ||
add_subdirectory (src) | ||
|
||
# testing section | ||
# -- generate configure file for ltp_test | ||
configure_file ( | ||
${CONFIGURE_DIR}/ltp_all_modules.conf.in | ||
${EXECUTABLE_OUTPUT_PATH}/ltp_all_modules.conf) | ||
|
||
# enable test | ||
enable_testing() | ||
|
||
# compile testing | ||
add_subdirectory (test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
SET(util_dir ${SOURCE}/__util/) | ||
SET(xml4nlp_dir ${SOURCE}/__xml4nlp/) | ||
SET(crfwordseg_dir ${SOURCE}/_crfwordsegment/) | ||
SET(svmtagger_dir ${SOURCE}/_svmtagger/) | ||
SET(splitsnt_dir ${SOURCE}/_split_sentence/) | ||
SET(ner_dir ${SOURCE}/_ner/) | ||
SET(gparser_dir ${SOURCE}/_gparser) | ||
SET(srl_dir ${SOURCE}/_srl/) | ||
SET(ltp_dll_dir ${SOURCE}/__ltp_dll/) | ||
set (util_DIR ${SOURCE_DIR}/__util/) | ||
set (xml4nlp_DIR ${SOURCE_DIR}/__xml4nlp/) | ||
set (crfwordseg_DIR ${SOURCE_DIR}/_crfwordsegment/) | ||
set (svmtagger_DIR ${SOURCE_DIR}/_svmtagger/) | ||
set (splitsnt_DIR ${SOURCE_DIR}/_split_sentence/) | ||
set (ner_DIR ${SOURCE_DIR}/_ner/) | ||
set (gparser_DIR ${SOURCE_DIR}/_gparser) | ||
set (srl_DIR ${SOURCE_DIR}/_srl/) | ||
set (ltp_dll_DIR ${SOURCE_DIR}/__ltp_dll/) | ||
|
||
ADD_SUBDIRECTORY("__util") | ||
ADD_SUBDIRECTORY("__xml4nlp") | ||
ADD_SUBDIRECTORY("_split_sentence") | ||
ADD_SUBDIRECTORY("_crfwordsegment") | ||
ADD_SUBDIRECTORY("_svmtagger") | ||
ADD_SUBDIRECTORY("_ner") | ||
ADD_SUBDIRECTORY("_gparser") | ||
ADD_SUBDIRECTORY("_srl") | ||
add_subdirectory ("__util") | ||
add_subdirectory ("__xml4nlp") | ||
add_subdirectory ("_split_sentence") | ||
add_subdirectory ("_crfwordsegment") | ||
add_subdirectory ("_svmtagger") | ||
add_subdirectory ("_ner") | ||
add_subdirectory ("_gparser") | ||
add_subdirectory ("_srl") | ||
|
||
ADD_SUBDIRECTORY("__ltp_dll") | ||
add_subdirectory ("__ltp_dll") | ||
|
||
ADD_SUBDIRECTORY("test") | ||
#add_subdirectory ("test") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
INCLUDE_DIRECTORIES(./ | ||
${xml4nlp_dir} | ||
${util_dir} | ||
${crfwordseg_dir} | ||
${svmtagger_dir} | ||
${gparser_dir} | ||
${ner_dir} | ||
${srl_dir} | ||
${splitsnt_dir} | ||
${THIRDPARTY}/tinyxml) | ||
include_directories (./ | ||
${xml4nlp_DIR} | ||
${util_DIR} | ||
${crfwordseg_DIR} | ||
${svmtagger_DIR} | ||
${gparser_DIR} | ||
${ner_DIR} | ||
${srl_DIR} | ||
${splitsnt_DIR} | ||
${THIRDPARTY_DIR}/tinyxml) | ||
|
||
SET(ltp_source | ||
SET(ltp_SRC | ||
Ltp.cpp | ||
Ltp.h | ||
LTPOption.h | ||
LTPResource.cpp | ||
LTPResource.h) | ||
|
||
ADD_LIBRARY(ltp ${ltp_source}) | ||
ADD_LIBRARY(ltp ${ltp_SRC}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
include_directories (./ | ||
${SOURCE_DIR}/__util | ||
${SOURCE_DIR}/__xml4nlp | ||
${SOURCE_DIR}/_split_sentence | ||
${SOURCE_DIR}/_crfwordsegment | ||
${SOURCE_DIR}/_svmtagger | ||
${SOURCE_DIR}/_ner | ||
${SOURCE_DIR}/_gparser | ||
${SOURCE_DIR}/_srl | ||
${SOURCE_DIR}/__ltp_dll | ||
${THIRDPARTY_DIR}/crfpp | ||
${THIRDPARTY_DIR}/maxent | ||
${THIRDPARTY_DIR}/tinyxml) | ||
|
||
set (ltp_test_SRC ltp_test.cpp) | ||
set (ltp_test_xml_SRC ltp_test_xml.cpp) | ||
|
||
add_executable (ltp_test ${ltp_test_SRC}) | ||
add_executable (ltp_test_xml ${ltp_test_xml_SRC}) | ||
|
||
link_directories ( ${LIBRARY_OUTPUT_PATH} ) | ||
|
||
target_link_libraries (ltp_test | ||
maxent | ||
crfpp | ||
util | ||
ltp | ||
splitsnt | ||
crfwordseg | ||
postagger | ||
gparser | ||
ner | ||
srl | ||
xml4nlp | ||
dl | ||
pthread | ||
boost_regex) | ||
|
||
target_link_libraries (ltp_test_xml | ||
maxent | ||
crfpp | ||
util | ||
ltp | ||
splitsnt | ||
crfwordseg | ||
postagger | ||
gparser | ||
ner | ||
srl | ||
xml4nlp | ||
dl | ||
pthread | ||
boost_regex) | ||
|
||
#add_test (NAME ltp_test | ||
# COMMAND "${CMAKE_COMMAND}" | ||
# -DTEST_PROG=${EXECUTABLE_TEST_OUTPUT} | ||
# -P ${CMAKE_MODULE_PATH}/LtpDiff.cmake) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Defines the entry point for the console application. | ||
// | ||
|
||
#include <stdlib.h> | ||
#include <iostream> | ||
|
||
#include "Xml4nlp.h" | ||
#include "Ltp.h" | ||
|
||
using namespace std; | ||
|
||
static XML4NLP xml4nlp; | ||
static LTP ltp(xml4nlp); | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
if (argc != 3) | ||
{ | ||
cerr << "Usage: ./ltp_test <type> <test_file>" << endl; | ||
exit(1); | ||
} | ||
|
||
cout << "Begin ..." << endl; | ||
string sentence; | ||
string type(argv[1]); | ||
ifstream in(argv[2]); | ||
ofstream log_file("test.log"); | ||
|
||
if (!in.is_open()) | ||
{ | ||
cerr << "Cann't open file!" << endl; | ||
exit(1); | ||
} | ||
|
||
while(in >> sentence){ | ||
cout << "Input sentence is: " << sentence << endl; | ||
|
||
xml4nlp.CreateDOMFromString(sentence); | ||
if(type == "ws"){ | ||
ltp.crfWordSeg(); | ||
int wordNum = xml4nlp.CountWordInDocument(); | ||
for (int i = 0; i < wordNum; ++i) | ||
{ | ||
const char* word = xml4nlp.GetWord(i); | ||
if (word != NULL) | ||
{ | ||
log_file << word << " "; | ||
} | ||
} | ||
} else if(type == "pos"){ | ||
ltp.postag(); | ||
} else if(type == "ner"){ | ||
ltp.ner(); | ||
} else if(type == "dp"){ | ||
ltp.gparser(); | ||
} else if(type == "srl"){ | ||
ltp.srl(); | ||
} else { | ||
ltp.srl(); | ||
} | ||
|
||
string result; | ||
xml4nlp.SaveDOM(result); | ||
|
||
cout << "Result is: " << result << endl; | ||
xml4nlp.ClearDOM(); | ||
} | ||
|
||
return 0; | ||
} | ||
|
Oops, something went wrong.