当前位置: 首页>>代码示例>>C#>>正文


C# WordLibraryList类代码示例

本文整理汇总了C#中WordLibraryList的典型用法代码示例。如果您正苦于以下问题:C# WordLibraryList类的具体用法?C# WordLibraryList怎么用?C# WordLibraryList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WordLibraryList类属于命名空间,在下文中一共展示了WordLibraryList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ImportLine

 public WordLibraryList ImportLine(string line)
 {
     var wlList = new WordLibraryList();
     WordLibrary wl = UserDefiningPattern.BuildWordLibrary(line);
     wlList.Add(wl);
     return wlList;
 }
开发者ID:ivlucks,项目名称:imewlconverter,代码行数:7,代码来源:SelfDefining.cs

示例2: ImportText

        public virtual WordLibraryList ImportText(string str)
        {
            //pinyinFactory = new PinyinGenerater();

            var wlList = new WordLibraryList();
            string[] words = str.Split(new[] {'\r', '\n'}, StringSplitOptions.RemoveEmptyEntries);
            CountWord = words.Length;
            CurrentStatus = 0;
            for (int i = 0; i < words.Length; i++)
            {
                try
                {
                    string word = words[i].Trim();
                    if (word != string.Empty)
                    {
                        wlList.AddWordLibraryList(ImportLine(word));
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
                CurrentStatus++;
            }
            return wlList;
        }
开发者ID:studyzy,项目名称:imewlconverter,代码行数:26,代码来源:NoPinyinWordOnly.cs

示例3: ImportLine

        public virtual WordLibraryList ImportLine(string line)
        {
            var wlList = new WordLibraryList();
            string[] strs = line.Split(' ');

            for (int i = 1; i < strs.Length; i++)
            {
                string oriWord = strs[i];
                string word = oriWord.Replace(",", ""); //把汉字中带有逗号的都去掉逗号
                //var list = pinyinFactory.GetCodeOfString(word);
                //for (int j = 0; j < list.Count; j++)
                //{
                var wl = new WordLibrary();
                wl.Word = oriWord;
                //if (IsWubi)
                //{
                //    wl.SetCode(CodeType.Wubi, strs[0]);
                //}
                //wl.PinYin = CollectionHelper.ToArray(list);
                wl.SetCode(CodeType, strs[0]);
                wlList.Add(wl);
                //}
            }
            return wlList;
        }
开发者ID:wadexiao,项目名称:imewlconverter,代码行数:25,代码来源:Jidian.cs

示例4: Export

 /// <summary>
 /// 导出词库为自定义格式。
 /// 如果没有指定自定义编码文件,而且词库是包含拼音编码的,那么就按拼音编码作为每个字的码。
 /// 如果导出指定了自定义编码文件,那么就忽略词库的已有编码,使用自定义编码文件重新生成编码。
 /// 如果词库没有包含拼音编码,而且导出也没有指定编码文件,那就抛错吧~~~~
 /// </summary>
 /// <param name="wlList"></param>
 /// <returns></returns>
 public string Export(WordLibraryList wlList)
 {
     if (string.IsNullOrEmpty(UserDefiningPattern.MappingTablePath)&& !UserDefiningPattern.IsPinyin)
     {
         if (wlList.Count ==0 || wlList[0].CodeType != CodeType.Pinyin)
         {
             throw new Exception("未指定字符编码映射文件,无法对词库进行自定义编码的生成");
         }
     }
     else
     {
         //var dict = UserCodingHelper.GetCodingDict(UserDefiningPattern.MappingTablePath);
         //codeGenerater.MappingDictionary = dict;
         //codeGenerater.MutiWordCodeFormat = UserDefiningPattern.MutiWordCodeFormat;
     }
     var sb = new StringBuilder();
     foreach (WordLibrary wordLibrary in wlList)
     {
         try
         {
             sb.Append(ExportLine(wordLibrary));
             sb.Append("\r\n");
         }
         catch(Exception ex)
         {
             Debug.WriteLine(ex.Message);
         }
     }
     return sb.ToString();
 }
开发者ID:startewho,项目名称:imewlconverter,代码行数:38,代码来源:SelfDefining.cs

示例5: Import

        public WordLibraryList Import(string path)
        {
            var pyAndWord = new WordLibraryList();
            var fs = new FileStream(path, FileMode.Open, FileAccess.Read);
            fs.Position = 0x44;
            CountWord = BinFileHelper.ReadInt32(fs);
            int segmentCount = BinFileHelper.ReadInt32(fs); //分为几段
            CurrentStatus = 0;
            for (int i = 0; i < segmentCount; i++)
            {
                try
                {
                    fs.Position = 0xC00 + 1024*i;
                    var segment = new Segment(fs);
                    pyAndWord.AddWordLibraryList(segment.WordLibraryList);
                    CurrentStatus += segment.WordLibraryList.Count;
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }
            }


            return pyAndWord;
        }
开发者ID:hahadalin,项目名称:imewlconverter,代码行数:26,代码来源:ZiGuangPinyinUwl.cs

示例6: BuildTree

        /// <summary>
        /// 构造一棵词库的树
        /// </summary>
        /// <param name="wlList"></param>
        /// <returns></returns>
        private TouchPalChar BuildTree(WordLibraryList wlList)
        {
            //先对词库进行排序再生成词库树
            wlList.Sort((a, b) => a.Word.CompareTo(b.Word));
            WordLibrary rootWL = wlList[0];
            var rootChar = new TouchPalChar(); //这个只是一个根Char,没有实际的字
            TouchPalChar lastChar = AddWordLink2Char(rootChar, rootWL, 0);


            for (int i = 1; i < wlList.Count; i++)
            {
                WordLibrary wl = wlList[i];
                wl.Count = 96; //默认是96的词频
                string a = lastChar.Word.ChineseWord;
                string b = wl.Word;
                int len = FindSameWordLen(a, b);
                if (len == 0)
                {
                    lastChar = AddWordLink2Char(rootChar, wl, 0);
                }
                else
                {
                    lastChar = AddWordLink2Char(lastChar, wl, len);
                }
            }
            return rootChar;
        }
开发者ID:hahadalin,项目名称:imewlconverter,代码行数:32,代码来源:TouchPal.cs

示例7: Export

        public 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 = "";
                var 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
                {
                    IList<string> codes = CodeGenerater.GetCodeOfString(wl.Word);
                    if (CodeGenerater.Is1CharMutiCode)
                    {
                        foreach (string code in codes)
                        {
                            if (xiaoxiaoDic.ContainsKey(code))
                            {
                                xiaoxiaoDic[code] += " " + value;
                            }
                            else
                            {
                                xiaoxiaoDic.Add(code, value);
                            }
                        }
                        continue;
                    }
                    else
                    {
                        key = (CollectionHelper.ListToString(codes));
                    }
                }


                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 sb.ToString();
        }
开发者ID:hahadalin,项目名称:imewlconverter,代码行数:60,代码来源:Xiaoxiao.cs

示例8: Export

        /// <summary>
        /// 将词库写入一个二进制文件,然后返回二进制文件的路径
        /// </summary>
        /// <param name="wlList"></param>
        /// <returns></returns>
        public string Export(WordLibraryList wlList)
        {
            TouchPalChar rootChar = BuildTree(wlList);
            int endPositon = InitTreeNodePosition(rootChar, 4);

            //创建一个临时文件
            string tempPath = Application.StartupPath + "\\temp" +
                              DateTime.Now.ToString("yyyyMMddHHmmss") + ".bak";
            var fs = new FileStream(tempPath, FileMode.OpenOrCreate, FileAccess.Write);
            fs.Write(BitConverter.GetBytes(endPositon), 0, 4);
            WriteBinaryTree(rootChar, fs);
            fs.Close();
            //int totalLength = 30;
            //foreach (WordLibrary wl in wlList)
            //{
            //    totalLength += wl.Word.Length * 28 + 5;
            //}
            //fs.Write(BitConverter.GetBytes(totalLength), 0, 4);
            //byte[] head = new byte[] { 0, 0, 0, 0, 0, 0, 0x1E, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            //fs.Write(head, 0, 26);
            //int from = 4;
            //GlobalCache.JumpChar = new TouchPalChar() {BeginPosition = 4};
            //for (int i = 0; i < wlList.Count; i++)
            //{
            //    WordLibrary wl = wlList[i];
            //    from = WriteWord(fs, wl, i == wlList.Count - 1);
            //}
            fs.Close();
            return tempPath;
        }
开发者ID:hahadalin,项目名称:imewlconverter,代码行数:35,代码来源:TouchPal.cs

示例9: Export

        public string Export(WordLibraryList wlList)
        {
            var sb = new StringBuilder();

            IDictionary<string, string> xiaoxiaoDic = new Dictionary<string, string>();

            for (int i = 0; i < wlList.Count; i++)
            {
                string key = "";
                var wl = wlList[i];
                string value = wl.Word;
                key = wl.SingleCode;
                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 sb.ToString();
        }
开发者ID:starkingpku,项目名称:imewlconverter,代码行数:28,代码来源:XiaoxiaoErbi.cs

示例10: Export

 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();
 }
开发者ID:Roottan,项目名称:imewlconverter,代码行数:25,代码来源:QQPinyin.cs

示例11: Export

 public IList<string> Export(WordLibraryList wlList)
 {
     var sb = new StringBuilder();
     foreach (WordLibrary wordLibrary in wlList)
     {
         sb.Append(ExportLine(wordLibrary));
         sb.Append("\r\n");
     }
     return new List<string>() { sb.ToString() };
 }
开发者ID:studyzy,项目名称:imewlconverter,代码行数:10,代码来源:UserDefinePhrase.cs

示例12: ImportLine

 /// <summary>
 /// 将一行纯文本转换为对象
 /// </summary>
 /// <param name="line"></param>
 /// <returns></returns>
 public virtual WordLibraryList ImportLine(string line)
 {
     var py = pinyinFactory.GetCodeOfString(line);
     var wl = new WordLibrary();
     wl.Word = line;
     wl.PinYin = ToArray(py);
     var wll = new WordLibraryList();
     wll.Add(wl);
     return wll;
 }
开发者ID:ivlucks,项目名称:imewlconverter,代码行数:15,代码来源:NoPinyinWordOnly.cs

示例13: Export

 public string Export(WordLibraryList wlList)
 {
     var sb = new StringBuilder();
     for (int i = 0; i < wlList.Count; i++)
     {
         sb.Append(ExportLine(wlList[i]));
         sb.Append("\r\n");
     }
     return sb.ToString();
 }
开发者ID:yongsun,项目名称:imewlconverter,代码行数:10,代码来源:BaiduShoujiEng.cs

示例14: Export

 public IList<string> Export(WordLibraryList wlList)
 {
     codeGenerater = CodeTypeHelper.GetGenerater(CodeType);
     var sb = new StringBuilder();
     for (int i = 0; i < wlList.Count; i++)
     {
         sb.Append(ExportLine(wlList[i]));
         sb.Append(lineSplitString);
     }
     return new List<string>() { sb.ToString() };
 }
开发者ID:studyzy,项目名称:imewlconverter,代码行数:11,代码来源:Rime.cs

示例15: ImportLine

 /// <summary>
 ///     将一行纯文本转换为对象
 /// </summary>
 /// <param name="line"></param>
 /// <returns></returns>
 public virtual WordLibraryList ImportLine(string line)
 {
     //IList<string> py = pinyinFactory.GetCodeOfString(line);
     var wl = new WordLibrary();
     wl.Word = line;
     wl.CodeType = CodeType;
     //wl.PinYin = CollectionHelper.ToArray(py);
     var wll = new WordLibraryList();
     wll.Add(wl);
     return wll;
 }
开发者ID:studyzy,项目名称:imewlconverter,代码行数:16,代码来源:NoPinyinWordOnly.cs


注:本文中的WordLibraryList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。