From 6e25c55c148ea91e3fb603dc38ab8cf291a66ce5 Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Thu, 27 Nov 2014 08:43:39 +0000 Subject: [PATCH] linux --- rudict/rudict/linux/makefile | 6 ++--- rudict/rudict/noun.cpp | 46 +++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/rudict/rudict/linux/makefile b/rudict/rudict/linux/makefile index aeaa76a..db4eebd 100644 --- a/rudict/rudict/linux/makefile +++ b/rudict/rudict/linux/makefile @@ -1,6 +1,6 @@ -CC=g++ -CFLAGS=-Wall -O3 -std=gnu++0x -LDFLAGS= -lpthread -lrt -lmysqlconn-static -L/usr/local/lib +CC=g++-4.8.3 +CFLAGS=-Wall -O3 -std=gnu++11 -finput-charset=UTF-8 -fexec-charset=UTF-8 +LDFLAGS= -lpthread -lrt -L/usr/local/lib BoostPath=../../../boost_1_56_0 diff --git a/rudict/rudict/noun.cpp b/rudict/rudict/noun.cpp index f1eadf4..8a2abdf 100644 --- a/rudict/rudict/noun.cpp +++ b/rudict/rudict/noun.cpp @@ -194,8 +194,27 @@ std::map getNounEndingTable() bool NounIsInDictionary(std::wstring nounNominative) { + +std::cout <c_str()) << std::endl; +std::cout <<"$$" << UTF16to8(nounNominative.c_str()) << std::endl; + +std::cout << "count" << frequentWordSet.count(nounNominative) << std::endl; + +if (nounNominative == frequentWordSet.begin()->c_str()) +{ +std::cout <<"true!" << std::endl; + +} +else +{ +std::cout << "false!" << std::endl; +} + if (frequentWordSet.count(nounNominative) != 0) { + return true; } return false; @@ -338,31 +357,47 @@ std::wstring RestoreNounByTuple(std::wstring nounBase, NounTuple nounTuple) } std::vector RecognizeNoun(std::wstring noun) -{ +{ + +std::cout << "!" << UTF16to8(noun.c_str()) << std::endl; + +std::cout << "?" << UTF16to8(frequentWordSet.begin()->c_str()) < result; auto nounEndingDivisionArr = getPossibleNounEndingDivisionArr(noun); +std::cout << nounEndingDivisionArr.size() << std::endl; + for (auto nounEndingDivision : nounEndingDivisionArr) { std::wstring nounBase = nounEndingDivision.first; std::wstring nounEnding = nounEndingDivision.second; std::vector possibleTupleArr = GetPossibleNounTupleArr(nounEnding); + +std::cout << "BASE" << UTF16to8(nounBase.c_str()) << std::endl; for (auto nounTuple : possibleTupleArr) { std::wstring nounNominative = RestoreNounByTuple(nounBase, nounTuple); +std::cout <<"Nominative" << UTF16to8(nounNominative.c_str()) << std::endl; auto possibleNounDetectionSet = GetPossibleNounDeclencionSet(nounNominative); + +std::cout <<"setsize" << possibleNounDetectionSet.size() << std::endl; + if (possibleNounDetectionSet.count(std::get<0>(nounTuple)) != 0) { + + std::cout<<"if1" << std::endl; if (NounIsInDictionary(nounNominative)) { + std::cout <<"result1 go!" << std::endl; result.push_back({ nounTuple, nounNominative }); } } @@ -377,8 +412,12 @@ std::vector RecognizeNoun(std::wstring noun) void LoadFrequentWordSet() { +#ifdef _WIN32 std::ifstream f("C:/Workplace/ChineseJournal/rudict/frequent_words.txt"); +#else +std::ifstream f("/home/devuser/workplace/rudict/frequent_words.txt"); +#endif //f.imbue(std::locale(std::locale::empty(), new std::codecvt_utf8)); std::string line; @@ -386,6 +425,7 @@ void LoadFrequentWordSet() if (f.is_open()) { + std::cout<<"File found!" << std::endl; while (getline(f, line)) { wline = UTF8to16(line.c_str()); @@ -393,4 +433,8 @@ void LoadFrequentWordSet() } f.close(); } + else + { + std::cout <<"file not found!" << std::endl; + } } \ No newline at end of file