public void Search() { GC.Collect(); PinYinSearchEx search = new PinYinSearchEx(PinYinSearchType.PinYin); search.LoadFile("keys1.dat"); Stopwatch watch = new Stopwatch(); watch.Start(); for (int i = 0; i < 1000; i++) { var ts = search.SearchTexts("程xy"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("程xuy"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("程xuyuan"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("程xyuan"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("cxy"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("chengxy"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("cxuy"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("cheng序y"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("c序y"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("c序yuan"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("cx员"); Assert.AreEqual(true, ts.Contains("程序员")); } watch.Stop(); Trace.Write(watch.ElapsedMilliseconds + "ms"); }
public void Test3() { PinYinSearchEx search = new PinYinSearchEx(); search.LoadFile("1.dat"); var t = search.SearchTexts("澳大利亚"); Assert.AreEqual("澳大利亚", t[0]); Assert.AreEqual(1, t.Count); t = search.SearchTexts("ad", true); Assert.AreEqual(3, t.Count); Assert.AreEqual("安道尔", t[0]); Assert.AreEqual("澳大利亚", t[1]); Assert.AreEqual("澳地利", t[2]); t = search.SearchTexts("ad", false); Assert.AreEqual(3, t.Count); Assert.AreEqual("澳大利亚", t[0]); Assert.AreEqual("澳地利", t[1]); Assert.AreEqual("安道尔", t[2]); var t2 = search.SearchTexts("bl"); Assert.AreEqual(8, t2.Count); t2 = search.SearchTexts("bls"); Assert.AreEqual(1, t2.Count); var t3 = search.SearchTexts("白e"); Assert.AreEqual("白俄罗斯", t3[0]); Assert.AreEqual(1, t3.Count); var t4 = search.SearchTexts("baie"); Assert.AreEqual("白俄罗斯", t4[0]); Assert.AreEqual(1, t4.Count); var t5 = search.SearchTexts("bai俄"); Assert.AreEqual("白俄罗斯", t5[0]); Assert.AreEqual(1, t5.Count); }
public void Search() { GC.Collect(); PinYinSearchEx search = new PinYinSearchEx(PinYinSearchType.PinYin); search.LoadFile("keys1.dat"); var ts = search.SearchTexts("程xy"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("程xuy"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("程xuyuan"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("程xyuan"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("cxy"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("chengxy"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("cxuy"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("cheng序y"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("c序y"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("c序yuan"); Assert.AreEqual(true, ts.Contains("程序员")); ts = search.SearchTexts("cx员"); Assert.AreEqual(true, ts.Contains("程序员")); }