List <myKanji> mixSearch(string txt) { List <myKanji> ret = new List <myKanji>(); Regex reg = new Regex(@"[^\w\s]+"); txt = reg.Replace(txt, " "); char[] buff = new char[txt.Length]; string zKanji = ""; int i; for (i = 0; i < txt.Length; i++) { char ch = txt[i]; if (mDict.m_kanjis.ContainsKey(ch)) { zKanji += ch; ch = ' '; } else if ((0x3040 < ch && ch < 0x3097) || (0x30A0 < ch && ch < 0x31FF)) { ch = ' '; } buff[i] = char.ToLower(ch); } if (zKanji.Length > 0) { ret.AddRange(mDict.Search(zKanji)); } ret.AddRange(mDict.SearchHn(new string(buff))); return(ret); }
static void Main(string[] args) { //byte[] sample = new byte[4] { 0xF0, 0xA9, 0xA0, 0x8C }; //string str = UTF8Encoding.UTF8.GetString(sample); //return; //test //test parser //csvParser csv = new csvParser(); //csv.uri = new Uri(@"ms-appx://Assets/hv_org.csv", UriKind.Absolute); //csv.start(); //return; //test dict Console.WriteLine("load dict start"); int tickcount = Environment.TickCount; myDict dict = myDict.Load(); tickcount = (Environment.TickCount - tickcount); Console.WriteLine("load dict completed {0}", tickcount); return; string w = "言葉"; for (;;) { w = "突っ込む"; var ret = dict.Search(w); } }
void search(srchCallback callback, string txt) { //= m_preTxt; var ret = dict.Search(txt); List <myWord> words = new List <myWord>(); List <myWord> verbs = new List <myWord>(); //Span s = new Span(); foreach (var kanji in ret) { //display kanji with link callback(myFgTask.qryType.hyperlink, kanji.val); if (kanji.decomposite != "") { callback(myFgTask.qryType.run, kanji.decomposite); callback(myFgTask.qryType.linebreak, null); } //display japanese define callback(myFgTask.qryType.define, kanji.definitions[0]); kanji.definitions.RemoveAt(0); //find kanji define - formated txt var foundKanji = kanji.relatedWords.Find((w) => { return(w.term == kanji.val.ToString()); }); if (foundKanji != null) { //display kanji define (in formated txt) callback(myFgTask.qryType.define, (foundKanji.definitions[0])); } else { //display radical info var rdInfo = dict.Search(kanji.radical.zRadical.ToString()); string zRad = string.Format("Bộ {0} {1} {2} [{3}, {4}] {5}", kanji.radical.iRadical, kanji.radical.zRadical, kanji.radical.hn, kanji.radical.nStrokes, kanji.totalStrokes, kanji.val); { if (kanji.hn != null) { zRad += string.Format(" ({0})", kanji.hn); } if (kanji.simple != '\0') { zRad += string.Format(" simple {0}", kanji.simple); } } callback(myFgTask.qryType.run, zRad); //display other kanji define foreach (var def in kanji.definitions) { callback(myFgTask.qryType.define, (def)); break; } callback(myFgTask.qryType.linebreak, null); } words.AddRange(kanji.relatedWords); verbs.AddRange(kanji.relateVerbs); callback(myFgTask.qryType.linebreak, null); } callback(myFgTask.qryType.linebreak, null); //found word myWord found = null; if (ret.Count > 1) { found = words.Find((w) => { return(w.term == txt); }); } //var sFound = new Span(); if (found != null) { callback(myFgTask.qryType.word, found); callback(myFgTask.qryType.linebreak, null); //remove from list words.Remove(found); } //related word //if (found != null) bg_qryDisplay(sFound); //bg_qryDisplay(new Run { Text = "related word:" }); //bg_qryDisplay(new LineBreak()); int count = 0; foreach (var rWd in words) { if (txt.Contains(rWd.term)) { continue; } #if !show_brift //m_limitContentCnt // (-1) no limit if ((count++) == m_limitContentCnt) { break; } #else { bg_qryDisplay(crtWdBlck(rWd, true)); }