bool CommonLanguageAnalyzer::getSynonym( const UString& combine, int offset, const unsigned char andOrBit, const unsigned int level, TermList& syOutList, unsigned int& subLevel) { bool ret = false; //cout << "combined: "; combine.displayStringValue(izenelib::util::UString::UTF_8); cout << endl; char* combineStr = lowercase_string_buffer_; UString::convertString(UString::UTF_8, combine.c_str(), combine.length(), lowercase_string_buffer_, term_string_buffer_limit_); //cout << "combined string: " << string(combineStr) << endl; UString::CharT * synonymResultUstr = NULL; size_t synonymResultUstrLen = 0; pSynonymContainer_ = uscSPtr_->getSynonymContainer(); pSynonymContainer_->searchNgetSynonym(combineStr, pSynonymResult_); for (int i =0; i<pSynonymResult_->getSynonymCount(0); i++) { char * synonymResult = pSynonymResult_->getWord(0, i); if (synonymResult) { if (strcmp(combineStr, synonymResult) == 0) { //cout << "synonym self: "<<string(synonymResult) <<endl; continue; } cout << "synonym : "<<string(synonymResult) <<endl; ret = true; size_t synonymResultLen = strlen(synonymResult); if (synonymResultLen <= term_ustring_buffer_limit_) { synonymResultUstr = synonym_ustring_buffer_; synonymResultUstrLen = UString::toUcs2(synonymEncode_, synonymResult, synonymResultLen, synonym_ustring_buffer_, term_ustring_buffer_limit_); } // word segmentment UString term(synonymResultUstr, synonymResultUstrLen); TermList termList; if (innerAnalyzer_.get()) { innerAnalyzer_->analyze(term, termList); if (termList.size() <= 1) { syOutList.add(synonymResultUstr, synonymResultUstrLen, offset, NULL, andOrBit, level+subLevel); subLevel++; } else { for (TermList::iterator iter = termList.begin(); iter != termList.end(); ++iter) { syOutList.add(iter->text_.c_str(), iter->text_.length(), offset, NULL, Term::AND, level+subLevel); } subLevel++; } } else { syOutList.add(synonymResultUstr, synonymResultUstrLen, offset, NULL, andOrBit, level+subLevel); subLevel++; } } } return ret; }