Skip to content

Commit

Permalink
Include boost::po in ltp-server
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneplus committed May 18, 2015
1 parent b85e973 commit 943415d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/console/ltp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ int main(int argc, char *argv[]) {
is = (&ifs);
}

ltp::utility::timer t;
ltp::utility::WallClockTimer t;
Dispatcher* dispatcher = new Dispatcher(&engine, (*is), std::cout);
int num_threads = threads;
std::cerr << "TRACE: LTP is built" << std::endl;
Expand Down
5 changes: 3 additions & 2 deletions src/server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
include_directories (./
${SOURCE_DIR}/
${THIRDPARTY_DIR}/maxent
${THIRDPARTY_DIR}/tinyxml)
${THIRDPARTY_DIR}/boost/include/
${THIRDPARTY_DIR}/maxent/
${THIRDPARTY_DIR}/tinyxml/)

set (ltp_server_SRC ltp_server.cpp mongoose.c mongoose.h)
link_directories ( ${LIBRARY_OUTPUT_PATH} )
Expand Down
28 changes: 22 additions & 6 deletions src/server/ltp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ int main(int argc, char *argv[]) {
"The path to the parser model [default=ltp_data/parser.model].")
("srl-data", value<std::string>(),
"The path to the SRL model directory [default=ltp_data/srl_data/].")
("debug-level", value<int>(), "The debug level.")
("log-level", value<int>(), "The log level:\n"
"- 0: TRACE level\n"
"- 1: DEBUG level\n"
"- 2: INFO level\n")
("help,h", "Show help information");

if (argc == 1) {
Expand Down Expand Up @@ -151,6 +154,16 @@ int main(int argc, char *argv[]) {
srl_data = vm["srl-data"].as<std::string>();
}

int log_level = LTP_LOG_INFO;
if (vm.count("log-level")) {
log_level = vm["log-level"].as<int>();
if (log_level == 0) {
ltp::utility::Logger<void>::get_logger()->set_lvl(LTP_LOG_TRACE);
} else if (log_level == 1) {
ltp::utility::Logger<void>::get_logger()->set_lvl(LTP_LOG_DEBUG);
}
}

engine = new LTP(last_stage, segmentor_model, segmentor_lexicon, postagger_model,
postagger_lexcion, ner_model, parser_model, srl_data);

Expand Down Expand Up @@ -257,11 +270,14 @@ static int Service(struct mg_connection *conn) {
str_post_data += buffer;
}

// TRACE_LOG("CDATA: %s", str_post_data.c_str());
// TRACE_LOG("CDATA length: %d", str_post_data.size());
DEBUG_LOG("CDATA: %s (length=%d)", str_post_data.c_str(), str_post_data.size());
if (str_post_data.size() == 0) {
WARNING_LOG("Input request is empty");
ErrorResponse(conn, kEmptyStringError);
return 0;
}

sentence = new char[str_post_data.size() + 1];

mg_get_var(str_post_data.c_str(),
str_post_data.size(),
"s",
Expand Down Expand Up @@ -308,7 +324,7 @@ static int Service(struct mg_connection *conn) {
}

delete []sentence;
// TRACE_LOG("Input sentence is: %s", strSentence.c_str());
DEBUG_LOG("Input sentence is: %s", strSentence.c_str());

//Get a XML4NLP instance here.
XML4NLP xml4nlp;
Expand Down Expand Up @@ -355,7 +371,7 @@ static int Service(struct mg_connection *conn) {
}
}

// TRACE_LOG("Analysis is done.");
TRACE_LOG("Analysis is done.");

std::string strResult;
xml4nlp.SaveDOM(strResult);
Expand Down
5 changes: 5 additions & 0 deletions src/utils/logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ class Logger {
return;
}


void set_lvl(int lvl) {
log_lvl = lvl;
}

/**
*
*
Expand Down

0 comments on commit 943415d

Please sign in to comment.