ASP. NET implements fuzzy query by pinyin code, and asp.net fuzzy query
The entire process is divided into two parts: generate the pinyin code segment and perform fuzzy query by the pinyin code segment.
Batch generation of Pinyin code segments:
Protected void Button1_Click1 (object sender, EventArgs e) {string strSQL; strSQL = "select mc from TEST001"; IDataReader dr = dac. dataReaderQuery (strSQL); while (dr. read () {string mc = dr ["mc"]. toString (); string pym = StrToPinyin. getChineseSpell (mc); if (pym. length> 6) {pym = pym. substring (0, 6); // I only went to 6 places here. You can check your hobbies!} String updateSql = "update TEST001 set pym = '" + pym + "'where mc ='" + mc + "'"; dac. update (updateSql);} dr. close (); Response. write ("<script> alert ('Operation successful! '); </Script> ");} The GetChineseSpell method of the StrToPinyin class (using Chinese characters and Pinyin letters): public static string GetChineseSpell (string strText) {if (strText = null | strText. length = 0) return strText; System. text. stringBuilder myStr = new System. text. stringBuilder (); foreach (char vChar in strText) {// if it is not a Chinese character, if (int) vChar <19968 | (int) vChar> 40869) {myStr. append (char. toUpper (vChar);} else if (int) vChar >=19968 & (int) vChar <= 40869) {// if the character Unicode encoding is within the encoding range, query the Chinese Character List and convert the output foreach (string strList in strChineseCharList) {if (strList. indexOf (vChar)> 0) {myStr. append (strList [0]); break ;}}} return myStr. toString ();}
Fuzzy search by pinyin code:
This is simple. You can use select to query and the where condition to use LIKE. I believe everyone will perform the operation.
I believe that in the future, we will be able to use ASP. NET, which we have learned today, to perform fuzzy queries based on pinyin codes when we implement the fuzzy query function of data by user input pinyin codes.