/// <summary> /// 转换多个文件成一个文件 /// </summary> /// <param name="filePathes"></param> /// <returns></returns> public string Convert(IList <string> filePathes) { ExportContents = new List <string>(); allWlList.Clear(); isImportProgress = true; filePathes = GetRealPath(filePathes); foreach (string file in filePathes) { WordLibraryList wlList = import.Import(file); wlList = Filter(wlList); allWlList.AddRange(wlList); } isImportProgress = false; if (selectedTranslate != ChineseTranslate.NotTrans) { allWlList = ConvertChinese(allWlList); } GenerateWordRank(allWlList); if (import.CodeType != export.CodeType) { GenerateDestinationCode(allWlList, export.CodeType); } count = allWlList.Count; if (export.CodeType != CodeType.NoCode) { allWlList = RemoveEmptyCodeData(allWlList); } ExportContents = export.Export(allWlList); return(string.Join("\r\n", ExportContents.ToArray())); }
//public List<string> GetRealPath(IList<string> filePathes) //{ // var list = new List<string>(); // filePathes.ToList().ForEach(x => // { // var dic = Path.GetDirectoryName(x); // var filen = Path.GetFileName(x); // if (filen.Contains("*")) // { // var files = Directory.GetFiles(dic, filen, SearchOption.AllDirectories); // list.AddRange(files); // } // else // { // list.Add(x); // } // }); // return list; //} /// <summary> /// 转换多个文件成一个文件 /// </summary> /// <param name="filePathes"></param> /// <returns></returns> public string Convert(IList <string> filePathes) { this.timer.Start(); ExportContents = new List <string>(); allWlList.Clear(); isImportProgress = true; //filePathes = GetRealPath(filePathes); foreach (string file in filePathes) { WordLibraryList wlList = import.Import(file); wlList = Filter(wlList); allWlList.AddRange(wlList); } isImportProgress = false; if (selectedTranslate != ChineseTranslate.NotTrans) { ProcessNotice("开始繁简转换..."); allWlList = ConvertChinese(allWlList); } if (export.CodeType != CodeType.NoCode) { ProcessNotice("开始生成词频..."); GenerateWordRank(allWlList); } if (import.CodeType != export.CodeType) { ProcessNotice("开始生成目标编码..."); GenerateDestinationCode(allWlList, export.CodeType); } if (export.CodeType != CodeType.NoCode) { allWlList = RemoveEmptyCodeData(allWlList); } count = allWlList.Count; ReplaceAfterCode(allWlList); //Sort //var wlDict = new Dictionary<string, WordLibrary>(); //var sorted = allWlList.Distinct().OrderBy(w => w.PinYinString).ToList(); //allWlList = new WordLibraryList(); //foreach (var wl in sorted) //{ // if (!wlDict.ContainsKey(wl.Word)) // { // wlDict.Add(wl.Word, wl); // allWlList.Add(wl); // } //} ExportContents = export.Export(allWlList); this.timer.Stop(); return(string.Join("\r\n", ExportContents.ToArray())); }
//public List<string> GetRealPath(IList<string> filePathes) //{ // var list = new List<string>(); // filePathes.ToList().ForEach(x => // { // var dic = Path.GetDirectoryName(x); // var filen = Path.GetFileName(x); // if (filen.Contains("*")) // { // var files = Directory.GetFiles(dic, filen, SearchOption.AllDirectories); // list.AddRange(files); // } // else // { // list.Add(x); // } // }); // return list; //} /// <summary> /// 转换多个文件成一个文件 /// </summary> /// <param name="filePathes"></param> /// <returns></returns> public string Convert(IList <string> filePathes) { this.timer.Start(); ExportContents = new List <string>(); allWlList.Clear(); isImportProgress = true; //filePathes = GetRealPath(filePathes); foreach (string file in filePathes) { WordLibraryList wlList = import.Import(file); wlList = Filter(wlList); allWlList.AddRange(wlList); } isImportProgress = false; if (selectedTranslate != ChineseTranslate.NotTrans) { ProcessNotice("开始繁简转换..."); allWlList = ConvertChinese(allWlList); } if (export.CodeType != CodeType.NoCode) { ProcessNotice("开始生成词频..."); GenerateWordRank(allWlList); } if (import.CodeType != export.CodeType) { ProcessNotice("开始生成目标编码..."); GenerateDestinationCode(allWlList, export.CodeType); } if (export.CodeType != CodeType.NoCode) { allWlList = RemoveEmptyCodeData(allWlList); } count = allWlList.Count; ReplaceAfterCode(allWlList); ExportContents = export.Export(allWlList); this.timer.Stop(); return(string.Join("\r\n", ExportContents.ToArray())); }
/// <summary> /// 转换多个文件成一个文件 /// </summary> /// <param name="filePathes"></param> /// <returns></returns> public string Convert(IList <string> filePathes) { allWlList.Clear(); isImportProgress = true; foreach (string file in filePathes) { WordLibraryList wlList = import.Import(file); wlList = Filter(wlList); allWlList.AddRange(wlList); } isImportProgress = false; if (selectedTranslate != ChineseTranslate.NotTrans) { allWlList = ConvertChinese(allWlList); } GenerateWordRank(allWlList); if (import.CodeType != export.CodeType) { GenerateDestinationCode(allWlList, export.CodeType); } count = allWlList.Count; return(export.Export(RemoveEmptyCodeData(allWlList))); }