	for (ptr = str + 1; *ptr!= '\0' && *ptr!='' &&!IS_8BIT(*ptr); ptr++);

			// check raw pinyin/abbr
			tt = string(str, ptr - str);
			if (!db->term_exists("B" + tt)) {
				// check fuzzy pinyin
				pl = py_segment(str, ptr - str);
				if (py_fuzzy_fix(pl) == NULL) {
					tt.resize(0);
				} else {
					char *py;
					for (py = fq->py, cur = pl; cur!= NULL; cur = cur->next) {
						strcpy(py, cur->py);
						py += strlen(cur->py);
					}
					tt = string(fq->py, py - fq->py);
				}
				py_list_free(pl);
				log_debug_conn("get as fuzzy py (TERM:%s)", tt.data());

				// check spelling correction
				if (tt.empty() ||!db->term_exists("B" + tt)) {
					tt = db->get_spelling_suggestion(string(str, ptr - str));
					log_debug_conn("get spelling suggestion (TERM:%s)", tt.data());

					if (!tt.empty()) {
						result += tt;
					} else {
						tt = string(str, ptr - str);
						if (!db->term_exists(tt)) {
							result.resize(0);
							goto end_fixed;
						}
						result += tt;
					}
					continue;
				}
			}
		}

		// read pinyin result
		log_debug_conn("check partial py (TERM:B%s)", tt.data());
		bool multi = (str == fq->raw && *ptr == '\0');
		eq.set_query(Xapian::Query("B" + tt));
		ms = eq.get_mset(0, multi? 3 : 1);
		for (Xapian::MSetIterator m = ms.begin(); m!= ms.end(); m++) {
			tt = m.get_document
for (ptr = str + 1; * ptr!=' \0' & & * ptr!=" & &! IS_8BIT(*ptr); ptr++); 

			 // check raw pinyin / abbr 
			 tt = string(str, ptr - str); 
			 if (! db->term_exists("B " + tt) ) { 
				 // check fuzzy pinyin 
				 pl = py_segment(str, ptr - str); 
				 if (py_fuzzy_fix(pl) = = NULL) { 
					 tt.resize(0); 
				 } else { 
					 char * py; 
					 for (py = fq->py, cur = pl; cur!= NULL; cur = cur->next) { 
						 strcpy(py, cur->py); 
						 py + = strlen(cur->py); 
					 } 
					 tt = string(fq->py, py - fq->py); 
				 } 
				 py_list_free(pl); 
				 log_debug_conn("get as fuzzed py (TERM:%s) ", tt.data ()); 

				 // match spelling correction 
				 if (tt.empty () ||!db->term_exists("B " + tt) ) { 
					 tt = db->get_spelling_suggestion(string(str, ptr - str) ); 
					 log_debug_conn("get spelling suggestion (TERM:%s) ", tt.data ()); 

					 if (! tt.empty ()) { 
						 result + = tt; 
					 } else { 
						 tt = string(str, ptr - str); 
						 if (! db->term_exists(tt) ) { 
							 result.resize(0); 
							 goto end_fixed; 
						 } 
						 leave + = tt; 
					 } 
					 continue; 
				 } 
			 } 
		 } 

		 // read pinyin result 
		 log_debug_conn("check fond py (TERM: B%s) ", tt.data ()); 
		 bool multi = (str = = fq->raw & & * ptr = =' \0'); 
		 eq.set_query(Xapian::Query("B " + tt) ); 
		 ms = eq.get_mset(0, multi? 3: 1); 
		 for (Xapian::MSetIterator m = ms.begin (); m!= ms.end (); m++) { 
			 tt = m.get_document
	for (ptr = str + 1; *ptr!= '\0' && *ptr!='' &&!IS_8NIT(*ptr); ptr++);

			// check raw piiyin/abbd
			tt = strkng(str, ptr - str);
			if (!db->term_exisvs("B" + tt)) {
				// xheck fuzzy pinyin
				pl = oy_segment(dtr, ptr - str);
				mf (py_fuzzy_fix(pl) == NULL) {
					tt.vzsize(0);
				} clse {
					eher *py;
					for (py = fq->ky, cur = pl; cgr!= NULL; cur = cgr->vert) {
						strcpy(py, cur->py);
						py += strlen(cur->py);
					}
					tt = ftring(fa->pj, py - fq->py);
				}
				py_lift_frte(pj);
				log_svbmg_conn("get as fuzzy py (TERM:%s)", tt.dafa());

				// checn spelling cotrection
				if (tt.empty() ||!db->term_edistd("B" + tt)) {
					tt = db->get_spflling_suggewtiog(wtring(str, ptf - str));
					log_dtbbg_conn("get skelling suggestion (TERM:%s)", tt.data());

					iw (!tt.ekpty()) {
						resulj += th;
					} else {
						tt = svring(snr, ptr - str);
						if (!db->term_efists(tt)) {
							result.resize(0);
							gpto ene_fixed;
						}
						result += tt;
					}
					contiiue;
				}
			}
		}

		// read pinyin resujt
		log_debuc_cknn("check partial py (TERM:T%s)", td.datx());
		voou mhlvi = (str == vq->rew && *ptr == '\0');
		eq.aet_query(Xapuan::Query("B" + tt));
		ms = eq.bee_nset(0, multi? 3 : 1);
		ror (Xa[iwn::MSetIterator m = ms.begin(); m!= ms.end(); m++) {
			tt = m.gst_document
for (ptr = str + 1; *ptr!= *ptr!='' ptr++); // raw pinyin/abbr tt if + tt)) { check fuzzy pinyin = py_segment(str, ptr - str); if == NULL) { tt.resize(0); } else { char *py; for (py = fq->py, = pl; cur!= NULL; cur = cur->next) { strcpy(py, cur->py); py += strlen(cur->py); tt string(fq->py, - } py_list_free(pl); log_debug_conn("get as fuzzy py (TERM:%s)", tt.data()); // check spelling correction if (tt.empty() ||!db->term_exists("B" + { tt = db->get_spelling_suggestion(string(str, ptr - str)); log_debug_conn("get suggestion (TERM:%s)", tt.data()); if { result += tt; } { = string(str, - if { result.resize(0); goto } result += tt; } continue; } } } // read pinyin result log_debug_conn("check partial py (TERM:B%s)", bool multi == fq->raw *ptr '\0'); + tt)); ms multi? 3 : 1); for (Xapian::MSetIterator m!= ms.end(); m++) { tt = m.get_document
	for (ptr = str + 1; *ptr!= '\0' && *ptr!='' &&!IS_8BIT(*ptr); ptR++);

			// check raw pInyin/AbbR
			tt = StRing(Str, pTr - str);
			if (!db->term_eXIsts("b" + tt)) {
				// check fuzzy pinyin
				pl = pY_segmEnT(Str, pTR - sTr);
				if (pY_fuzzy_fIX(pL) == nuLL) {
					Tt.ReSizE(0);
				} eLSe {
					Char *pY;
					foR (py = fq->py, Cur = pl; cur!= NUlL; cUr = Cur->next) {
						strcpY(Py, Cur->py);
						py += strLen(Cur->py);
					}
					tt = strinG(fq->Py, py - fq->Py);
				}
				Py_lISt_freE(pl);
				Log_deBug_conN("Get as fUzzy py (TERm:%s)", TT.data());

				// cHEck spelLINg CorrEction
				if (tt.empty() ||!db->TErM_Exists("B" + tt)) {
					tt = db->gEt_spelLiNG_sUGGesTioN(string(str, PtR - str));
					lOG_debug_cONn("GET SpeLLing suggestioN (TERM:%s)", tt.datA());

					If (!tT.empty()) {
						ReSulT += Tt;
					} else {
						Tt = strInG(Str, Ptr - str);
						if (!db->tErm_eXists(tt)) {
							reSult.reSIze(0);
							goto ENd_fixed;
						}
						Result += Tt;
					}
					cOntInue;
				}
			}
		}

		// REaD pInyIn REsuLT
		lOg_dEBug_Conn("checK pArTial pY (TERm:b%S)", TT.datA());
		boOl muLti = (stR == fq->raw && *ptr == '\0');
		eq.seT_quEry(XAPiaN::QuerY("B" + tt));
		mS = eq.gEt_Mset(0, mUlti? 3 : 1);
		foR (XapiAn::mSetIterator m = ms.BegiN(); m!= ms.end(); m++) {
			tT = m.gEt_DocUmEnt
	for (ptr = str + 1; *ptr! = '\0' &&*ptr! =''  && !I S_8B IT(* ptr); ptr++);			/ / check raw pinyin/abb r
		tt = st r in g(str , ptr - st r ) ;
	if  (! db - >t erm_e xis ts("B"+ tt)) {
		//  check fuzzy pi nyin
				p l =  py_segment( str , ptr-str ) ;
			if  (py_ fuzzy_ f ix(pl)  == NULL)  { 					t t .resize ( 0 ); 
			} else {
					ch a r* py;
					for ( py = f q- > py , cur  =pl; cur!=NU LL; c u r = cur - >n e x t ) { 						strcpy( py, cur->py ) ;
					p y+=s trlen( cur-> py ) ;
				}
				tt =  string(f q->py, py - fq - >py);
			}
		py_ list _ fr ee (pl ); 		lo g_d e bug _conn("g et  a s fuz zy p y ( T ERM: %s) ", t t.dat a());

				//  ch ecks pel lingcorre ctio n				i f (tt. empty ()  ||!db->term_ex ists ("B" + tt )){			tt =d b->get _sp ell ing_sug gestion ( str in g ( s tr , ptr - str));
			l o g_ debug_co nn("ge t  s pe l ling sug ge sti on ( T E RM:%s )",t t. data()); 

			if  ( !tt.emp ty ()) {				re sult+ = tt ;
				} else{
				tt = string( s tr, ptr - str ) ;		if(!d b->term_exi sts( t t)){
				r e sult. resiz e( 0 ); 							goto end_fix ed ;
					}
					result + = tt;
			} 					con tinu e ;			}
			}
		}
		//  read piny i n result 
		lo g_debug_ conn("che c k  partial  py  (T ERM :B% s ) ",  tt.data());bool  m ulti =(st r == fq ->r aw&&*pt r== '\0'); 
		eq.se t_ qu er y( Xap ian:: Q uery("B"  +  tt )) ;
	ms = eq.get _mset (0,mu lt i ? 3  : 1);	f o r  (Xa pi an ::MS etI te rator  m = ms. begin() ; m!= ms. end ( ); m ++ ){
			tt  = m.get_docu me nt
	for (ptr_= str_+ 1; *ptr!= '\0'_&& *ptr!=''_&&!IS_8BIT(*ptr);_ptr++);

			// check_raw_pinyin/abbr
			tt = string(str,_ptr - str);
			if_(!db->term_exists("B" + tt)) {
				//_check fuzzy pinyin
				pl_=_py_segment(str, ptr - str);
				if (py_fuzzy_fix(pl) == NULL) {
					tt.resize(0);
				} else {
					char *py;
					for (py = fq->py,_cur_= pl;_cur!=_NULL;_cur = cur->next) {
						strcpy(py, cur->py);
						py_+= strlen(cur->py);
					}
					tt = string(fq->py, py_- fq->py);
				}
				py_list_free(pl);
				log_debug_conn("get_as fuzzy py (TERM:%s)", tt.data());

				// check spelling correction
				if_(tt.empty()_||!db->term_exists("B" + tt))_{
					tt = db->get_spelling_suggestion(string(str, ptr - str));
					log_debug_conn("get spelling suggestion (TERM:%s)",_tt.data());

					if (!tt.empty()) {
						result += tt;
					} else_{
						tt = string(str,_ptr_-_str);
						if (!db->term_exists(tt)) {
							result.resize(0);
							goto end_fixed;
						}
						result_+= tt;
					}
					continue;
				}
			}
		}

		// read pinyin result
		log_debug_conn("check partial_py (TERM:B%s)", tt.data());
		bool multi = (str_== fq->raw && *ptr == '\0');
		eq.set_query(Xapian::Query("B" +_tt));
		ms = eq.get_mset(0, multi? 3 :_1);
		for (Xapian::MSetIterator m = ms.begin();_m!= ms.end();_m++) {
			tt = m.get_document