public string Export(WordLibraryList wlList) { if (wlList.Count == 0) { return(""); } var sb = new StringBuilder(); for (int i = 0; i < wlList.Count - 1; i++) { string line = ExportLine(wlList[i]); if (line != "") { sb.Append(line); sb.Append("\r\n"); } } WordLibrary last = wlList[wlList.Count - 1]; sb.Append(ExportLine(last)); sb.Append(", "); sb.Append(last.GetPinYinString("'", BuildType.None)); sb.Append(" "); sb.Append(last.Count); sb.Append("\r\n"); return(sb.ToString()); }
public string ExportLine(WordLibrary wl) { //StringBuilder sb = new StringBuilder(); string str = wl.GetPinYinString("'", BuildType.LeftContain) + " " + wl.Word; return(str); }
public string ExportLine(WordLibrary wl) { var sb = new StringBuilder(); sb.Append(wl.GetPinYinString("", BuildType.None)); sb.Append(" "); sb.Append(wl.Word); return sb.ToString(); }
public string ExportLine(WordLibrary wl) { //StringBuilder sb = new StringBuilder(); string str = wl.GetPinYinString("'", BuildType.None) + "," + wl.Word; return str; }
public string ExportLine(WordLibrary wl) { var sb = new StringBuilder(); sb.Append(wl.GetPinYinString("'", BuildType.None)); sb.Append("\t"); sb.Append(wl.Word); return(sb.ToString()); }
//public Form ExportConfigForm { get { return form; } } public IList <string> Export(WordLibraryList wlList) { var sb = new StringBuilder(); //sb.Append(GetFileHeader()); IDictionary <string, string> xiaoxiaoDic = new Dictionary <string, string>(); for (int i = 0; i < wlList.Count; i++) { string key = ""; WordLibrary wl = wlList[i]; string value = wl.Word; if (CodeType == CodeType.Pinyin) { key = (wl.GetPinYinString("", BuildType.None)); } else if (CodeType == wl.CodeType) { key = (wl.Codes[0][0]); } else { var codes = CodeGenerater.GetCodeOfString(wl.Word); var list = codes.ToCodeString(); foreach (var code in list) { if (xiaoxiaoDic.ContainsKey(code)) { xiaoxiaoDic[code] += " " + value; } else { xiaoxiaoDic.Add(code, value); } } } if (xiaoxiaoDic.ContainsKey(key)) { xiaoxiaoDic[key] += " " + value; } else { xiaoxiaoDic.Add(key, value); } } foreach (var keyValuePair in xiaoxiaoDic) { sb.Append(keyValuePair.Key + " " + keyValuePair.Value + "\n"); } return(new List <string>() { sb.ToString() }); }
public override void GetCodeOfWordLibrary(WordLibrary wl) { if (wl.CodeType == CodeType.Pinyin) { wl.SetCode(CodeType.UserDefinePhrase, wl.GetPinYinString("", BuildType.None)); } var codes = CollectionHelper.Descartes(wl.Codes); wl.SetCode(CodeType.UserDefinePhrase, codes[0]); }
public string ExportLine(WordLibrary wl) { var sb = new StringBuilder(); if (codeGenerater == null) { codeGenerater = CodeTypeHelper.GetGenerater(CodeType); } if (codeGenerater.Is1CharMutiCode) { IList <string> codes = codeGenerater.GetCodeOfString(wl.Word); int i = 0; foreach (string code in codes) { sb.Append(wl.Word); sb.Append("\t"); sb.Append(code); sb.Append("\t"); sb.Append(wl.Count); i++; if (i != codes.Count) { sb.Append("\r\n"); } } } else { sb.Append(wl.Word); sb.Append("\t"); if (CodeType == CodeType.Pinyin || CodeType == CodeType.TerraPinyin) { sb.Append(wl.GetPinYinString(" ", BuildType.None)); } else if (CodeType == wl.CodeType) { sb.Append(wl.Codes[0][0]); } else { if (codeGenerater.Is1Char1Code) { sb.Append(CollectionHelper.ListToString(codeGenerater.GetCodeOfString(wl.Word), " ")); } else { sb.Append(CollectionHelper.ListToString(codeGenerater.GetCodeOfString(wl.Word))); } } sb.Append("\t"); sb.Append(wl.Count); } return(sb.ToString()); }
public IList <string> GetCodeOfWordLibrary(WordLibrary str, string charCodeSplit = "") { if (str.CodeType == CodeType.Pinyin) { return(new List <string>() { str.GetPinYinString("", BuildType.None) }); } else { return(CollectionHelper.Descartes(str.Codes)); } }
public string ExportLine(WordLibrary wl) { var sb = new StringBuilder(); sb.Append(wl.Word); sb.Append("\t"); if (!wl.IsEnglish) { sb.Append(wl.GetPinYinString("'", BuildType.RightContain)); sb.Append("\t"); } sb.Append(wl.Count); return(sb.ToString()); }
public string ExportLine(WordLibrary wl) { var sb = new StringBuilder(); sb.Append(wl.Word); sb.Append("\t"); if (!wl.IsEnglish) { sb.Append(wl.GetPinYinString("'", BuildType.RightContain)); sb.Append("\t"); } sb.Append(wl.Count); return sb.ToString(); }
public string ExportLine(WordLibrary wl) { var format = "<dict><key>phrase</key><string>{0}</string><key>shortcut</key><string>{1}</string></dict>"; try { string py = wl.GetPinYinString("", BuildType.None); if (string.IsNullOrEmpty(py)) { return(""); } return(string.Format(format, wl.Word, py)); } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(""); }
public string ExportLine(WordLibrary wl) { var sb = new StringBuilder(); if (CodeType == CodeType.Pinyin) { sb.Append(wl.GetPinYinString("", BuildType.None)); } else if (CodeType == wl.CodeType) { sb.Append(wl.Codes); } else { sb.Append(CollectionHelper.ListToString(CodeGenerater.GetCodeOfString(wl.Word))); } sb.Append(" "); sb.Append(wl.Word); return(sb.ToString()); }
public string ExportLine(WordLibrary wl) { var sb = new StringBuilder(); if (CodeType == CodeType.Pinyin) { sb.Append(wl.GetPinYinString("", BuildType.None)); } else if (CodeType == wl.CodeType) { sb.Append(wl.Codes[0][0]); } else { var code = CodeGenerater.GetCodeOfString(wl.Word); sb.Append(code.ToCodeString()); } sb.Append(" "); sb.Append(wl.Word); return(sb.ToString()); }
public string ExportLine(WordLibrary wl) { var sb = new StringBuilder(); sb.Append(wl.Word); sb.Append(" "); try { string py = wl.GetPinYinString("'", BuildType.None); if (string.IsNullOrEmpty(py)) { return(""); } sb.Append(py); } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(sb.ToString()); }
public string ExportLine(WordLibrary wl) { var sb = new StringBuilder(); sb.Append(wl.Word); sb.Append("\t"); //IList<string> zhuyins = null; //if (wl.CodeType == CodeType.Pinyin) //如果本来就是拼音输入法导入的,那么就用其拼音,不过得加上音调 //{ // IList<string> pinyin = new List<string>(); // for (int i = 0; i < wl.PinYin.Length; i++) // { // if (regex.IsMatch(wl.PinYin[i])) // { // pinyin.Add(wl.PinYin[i]); // } // else // { // pinyin.Add(PinyinHelper.AddToneToPinyin(wl.Word[i], wl.PinYin[i])); // } // } // zhuyins = ZhuyinHelper.GetZhuyin(pinyin); //} //else //{ // //zhuyins = generater.GetCodeOfString(wl.Word); //} //sb.Append(CollectionHelper.ListToString(zhuyins, ",")); sb.Append(wl.GetPinYinString(",", BuildType.None)); sb.Append("\t"); sb.Append("-1.0"); sb.Append("\t"); sb.Append("0.0"); return(sb.ToString()); }
//private RimeConfigForm form; public string ExportLine(WordLibrary wl) { var sb = new StringBuilder(); if (this.CodeType == wl.CodeType && this.CodeType != CodeType.Pinyin && CodeType != CodeType.TerraPinyin) { return(wl.Word + "\t" + wl.Codes[0][0] + "\t" + wl.Rank); } if (codeGenerater == null) { codeGenerater = CodeTypeHelper.GetGenerater(CodeType); } try { codeGenerater.GetCodeOfWordLibrary(wl); } catch (Exception ex) { Debug.Fail(ex.Message); return(null); } if (codeGenerater.Is1CharMutiCode) { IList <string> codes = codeGenerater.GetCodeOfString(wl.Word).ToCodeString(" "); int i = 0; foreach (string code in codes) { sb.Append(wl.Word); sb.Append("\t"); sb.Append(code); sb.Append("\t"); sb.Append(wl.Rank); i++; if (i != codes.Count) { sb.Append(lineSplitString); } } } else { sb.Append(wl.Word); sb.Append("\t"); if (CodeType == CodeType.Pinyin || CodeType == CodeType.TerraPinyin) { sb.Append(wl.GetPinYinString(" ", BuildType.None)); } else if (CodeType == wl.CodeType) { sb.Append(wl.Codes[0][0]); } else { sb.Append(wl.Codes.ToCodeString(" ")[0]); } sb.Append("\t"); sb.Append(wl.Rank); } return(sb.ToString()); }