diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..bb5d97030 --- /dev/null +++ b/Makefile @@ -0,0 +1,40 @@ +############################################################## +# CMake Project Wrapper Makefile # +############################################################## + +SHELL := /bin/bash +RM := rm -rf + +all: ./build/Makefile + @ $(MAKE) -C build + +./build/Makefile: + @ (cd build >/dev/null 2>&1 && cmake ..) + +distclean: + @- (cd build >/dev/null 2>&1 && cmake .. >/dev/null 2>&1) + @- $(MAKE) --silent -C build clean || true + @- $(RM) ./build/Makefile + @- $(RM) ./build/src + @- $(RM) ./build/test + @- $(RM) ./build/CMake* + @- $(RM) ./build/cmake.* + @- $(RM) ./build/*.cmake + @- $(RM) ./build/*.txt + @- $(RM) ./docs/*.html + @- $(RM) ./docs/*.css + @- $(RM) ./docs/*.png + @- $(RM) ./docs/*.jpg + @- $(RM) ./docs/*.gif + @- $(RM) ./docs/*.tiff + @- $(RM) ./docs/*.php + @- $(RM) ./docs/search + @- $(RM) ./docs/installdox + + +ifeq ($(findstring distclean,$(MAKECMDGOALS)),) + + $(MAKECMDGOALS): ./build/Makefile + @ $(MAKE) -C build $(MAKECMDGOALS) + +endif diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 393ad76c6..c485f3d51 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -102,6 +102,7 @@ MACRO (CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE) CHECK_INCLUDE_FILES ("${USE_INCLUDES};${FILE}" ${VARIABLE}) IF (${VARIABLE}) SET (USE_INCLUDES ${USE_INCLUDES} ${FILE}) + ADD_DEFINITIONS( -D${VARIABLE} ) ENDIF (${VARIABLE}) ENDMACRO (CHECK_INCLUDE_FILE_CONCAT) diff --git a/src/__ltp_dll/Ltp.cpp b/src/__ltp_dll/Ltp.cpp index 40579ea26..29f4ce7c2 100644 --- a/src/__ltp_dll/Ltp.cpp +++ b/src/__ltp_dll/Ltp.cpp @@ -33,9 +33,9 @@ const unsigned int LTP::DO_PARSER = 1 << 4; const unsigned int LTP::DO_SRL = 1 << 6; // create a platform -LTP::LTP(XML4NLP &xml4nlp) : - m_ltpResource(), - m_ltpOption(), +LTP::LTP(XML4NLP &xml4nlp) : + m_ltpResource(), + m_ltpOption(), m_xml4nlp(xml4nlp) { ReadConfFile(); } @@ -134,7 +134,7 @@ int LTP::ReadConfFile(const char * config_file) { return 0; } -// If you do NOT split sentence explicitly, +// If you do NOT split sentence explicitly, // this will be called according to dependencies among modules int LTP::splitSentence_dummy() { if ( m_xml4nlp.QueryNote(NOTE_SENT) ) { @@ -155,7 +155,7 @@ int LTP::splitSentence_dummy() { m_xml4nlp.GetParagraph(i, para); if (0 == SplitSentence( para, vecSentences )) { ERROR_LOG("in LTP::splitsent, failed to split sentence"); - return -1; + return -1; } // dummy // vecSentences.push_back(para); @@ -175,7 +175,7 @@ int LTP::wordseg() { return 0; } - // + // if (0 != splitSentence_dummy()) { ERROR_LOG("in LTP::wordseg, failed to perform split sentence preprocess."); return -1; @@ -261,7 +261,7 @@ int LTP::postag() { } if (m_xml4nlp.SetPOSsToSentence(vecPOS, i) != 0) { - ERROR_LOG("in LTP::postag, failed to write postag result to xml"); + ERROR_LOG("in LTP::postag, failed to write postag result to xml"); return -1; } } @@ -295,8 +295,8 @@ int LTP::ner() { return -1; } - NER_SetOption(m_ltpOption.neOpt.isEntity, - m_ltpOption.neOpt.isTime, + NER_SetOption(m_ltpOption.neOpt.isEntity, + m_ltpOption.neOpt.isTime, m_ltpOption.neOpt.isNum); int stnsNum = m_xml4nlp.CountSentenceInDocument(); @@ -469,83 +469,3 @@ int LTP::srl() { return 0; } -#ifdef _WIN32 - -int LTP::main2(const char *cszFileName, const char *cszSaveFileName, unsigned int flag) -{ - if (flag & DO_XML) - { - if (CreateDOMFromXml(cszFileName) != 0) return -11; - } - else - { - if (CreateDOMFromTxt(cszFileName) != 0) return -12; - } - - if (flag & DO_SPLITSENTENCE) { - if (splitSentence() != 0) return -1; - } - /* - if (flag & DO_IRLAS) { - if (postag() != 0) return -2; - } - */ - if (flag & DO_NER) { - if (ner() != 0) return -3; - } - /* - if (flag & DO_WSD) { - if (wsd() != 0) return -4; - } - */ - if (flag & DO_PARSER) { - if (gparser() != 0) return -5; - } - if (flag & DO_SRL) { - if (srl() != 0) return -6; - } - if (SaveDOM(cszSaveFileName) != 0) return -10; - - return 0; -} - -// Need to split sentence explicitly. -int LTP::splitSentence() { - if ( m_xml4nlp.QueryNote(NOTE_SENT) ) return 0; - - int paraNum = m_xml4nlp.CountParagraphInDocument(); - - if (paraNum == 0) - { - cerr << "There is no paragraph in doc," << endl - << "you may have loaded a blank file or have not loaded a file yet" << endl; - return -1; - } - - for (int i = 0; i < paraNum; ++i) - { - vector vecSentences; - string para; - m_xml4nlp.GetParagraph(i, para); - if (0 == SplitSentence( para, vecSentences )) return -1; // func SplitSentence's return val is vecSentence.size() - //vecSentences.push_back(para); - if (0 != m_xml4nlp.SetSentencesToParagraph(vecSentences, i)) return -1; - } - - m_xml4nlp.SetNote(NOTE_SENT); - return 0; -} - -void SplitWordPOS(const vector &vecWordPOS, vector &vecWord, - vector &vecPOS) -{ - vector< pair > vecPair; - convert_to_pair(vecWordPOS, vecPair); - for (int i=0; i(NULL), + reinterpret_cast(NULL)); if(newLast != NULL && curPathNum >= MAX_N && newLast->accuProb < weight) return returnPath; diff --git a/src/_srl/CMakeLists.txt b/src/_srl/CMakeLists.txt index 167c275d9..99ca1bf4e 100644 --- a/src/_srl/CMakeLists.txt +++ b/src/_srl/CMakeLists.txt @@ -39,6 +39,8 @@ configure_file ( link_directories (${LIBRARY_OUTPUT_PATH}) +# Training suite is not supported in windows +if (NOT WIN32) set (SRLExtract_SRC SRLExtract.cpp Corpus.cpp) add_executable (SRLExtract ${SRLExtract_SRC}) target_link_libraries (SRLExtract srl) @@ -53,3 +55,4 @@ set_target_properties (SRLGetInstance PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TOOLS_DIR}/train/) +endif() \ No newline at end of file diff --git a/src/segmentor/instance.h b/src/segmentor/instance.h index cb70f4827..47fbdc480 100644 --- a/src/segmentor/instance.h +++ b/src/segmentor/instance.h @@ -110,6 +110,8 @@ class Instance { features.zero(); predicted_features.zero(); + + return 0; } public: std::vector< std::string > raw_forms; diff --git a/thirdparty/maxent/CMakeLists.txt b/thirdparty/maxent/CMakeLists.txt index 02ea15873..68d81ad25 100644 --- a/thirdparty/maxent/CMakeLists.txt +++ b/thirdparty/maxent/CMakeLists.txt @@ -76,10 +76,12 @@ set (maxent_exe_SRC f77_dummy_main.cpp ${GETOPT_FILES}) - +# Training suite is not supported in windows +if (NOT WIN32) add_executable (maxent_exe ${maxent_exe_SRC}) set_target_properties (maxent_exe PROPERTIES OUTPUT_NAME maxent RUNTIME_OUTPUT_DIRECTORY ${TOOLS_DIR}/train/) target_link_libraries (maxent_exe maxent_lib z m) +endif () \ No newline at end of file