private ParsePattern InitPattern() { ParsePattern pp=new ParsePattern(); pp.MutiWordCodeFormat = @"code_e2=p11+p12+p21+p22 code_e3=p11+p21+p31+p32 code_a4=p11+p21+p31+n11"; pp.IsPinyinFormat = false; pp.ContainRank = false; pp.SplitString = " "; pp.ContainCode = true; return pp; }
public void TestPinyinString2WL() { ParsePattern parser = new ParsePattern() { IsPinyin = true, CodeSplitType = BuildType.FullContain, CodeSplitString = ",", ContainCode = true, ContainRank = true, SplitString = " ", Sort = new List<int>() {2, 1, 3} }; var wl = parser.BuildWordLibrary("深蓝 ,shen,lan, 1"); Assert.AreEqual(wl.PinYin[0], "shen"); Assert.AreEqual(wl.PinYin[1], "lan"); Assert.AreEqual(wl.Count, 1); }
public void TestPinyinString2WL() { ParsePattern parser = new ParsePattern() { IsPinyinFormat = true, CodeSplitType = BuildType.FullContain, CodeSplitString = ",", ContainCode = true, ContainRank = true, SplitString = " ", Sort = new List<int>() { 2, 1, 3 } }; var str = "深蓝 ,shen,lan, 1"; selfDefining.UserDefiningPattern = parser; var wl = selfDefining.ImportLine(str)[0]; Assert.AreEqual(wl.Codes[0][0], "shen"); Assert.AreEqual(wl.Codes[1][0], "lan"); Assert.AreEqual(wl.Rank, 1); }
public void TestWordLibrary2String() { ParsePattern parser = new ParsePattern() { IsPinyinFormat = true, CodeSplitType = BuildType.FullContain, CodeSplitString = ",", ContainCode = true, ContainRank = true, SplitString = "|", CodeType = CodeType.Pinyin, Sort = new List<int>() { 2, 1, 3 } }; WordLibrary wl = new WordLibrary() { Word = "深蓝", Rank = 123, CodeType = CodeType.Pinyin }; wl.Codes = new Code(); wl.Codes.Add( new[] { "shen" }); wl.Codes.Add( new[] { "lan" }); selfDefining.UserDefiningPattern = parser; var str = selfDefining.ExportLine(wl); Assert.AreEqual(str, "深蓝|,shen,lan,|123"); }
public void TestGeneratePinyinThen2String() { ParsePattern parser = new ParsePattern() { IsPinyinFormat = true, CodeSplitType = BuildType.FullContain, CodeSplitString = "~", ContainCode = true, ContainRank = true, SplitString = "|", CodeType = CodeType.Pinyin, LineSplitString = "\r", Sort = new List<int>() { 2, 1, 3 } }; WordLibraryList wll = new WordLibraryList(); WordLibrary wl = new WordLibrary() { Word = "深蓝", Rank = 123, CodeType = CodeType.UserDefine }; wl.Codes = new Code(); wl.Codes.Add(new[] { "sn" }); wl.Codes.Add( new[] { "ln" }); wll.Add(wl); selfDefining.UserDefiningPattern = parser; var str = selfDefining.Export(wll); Assert.AreEqual(str, "深蓝|~shen~lan~|123\r"); }
void importForm_Closed(object sender, EventArgs e) { Global.ImportSelfDefiningPattern = importForm.SelectedParsePattern; this.UserDefiningPattern = importForm.SelectedParsePattern; }
void exportForm_Closed(object sender, EventArgs e) { this.UserDefiningPattern = exportForm.SelectedParsePattern; }
public void TestImportTxt() { string txt = "深藍 shen,lan 12345"; var pp = new ParsePattern(); pp.Sort=new List<int>(){2,1,3}; pp.IsPinyinFormat = true; pp.CodeType = CodeType.Pinyin; pp.CodeSplitString = ","; pp.SplitString = " "; pp.CodeSplitType= BuildType.None; selfDefining.UserDefiningPattern = pp; var x = selfDefining.ImportLine(txt); Debug.WriteLine(x[0].ToString()); Assert.IsNotNullOrEmpty(x[0].Word,"深藍"); }