當前位置: 首頁>>代碼示例>>C#>>正文


C# WordLibrary.SetCode方法代碼示例

本文整理匯總了C#中Studyzy.IMEWLConverter.Entities.WordLibrary.SetCode方法的典型用法代碼示例。如果您正苦於以下問題:C# WordLibrary.SetCode方法的具體用法?C# WordLibrary.SetCode怎麽用?C# WordLibrary.SetCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Studyzy.IMEWLConverter.Entities.WordLibrary的用法示例。


在下文中一共展示了WordLibrary.SetCode方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetCodeOfWordLibrary

 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]);
 }
開發者ID:XXpanda,項目名稱:imewlconverter,代碼行數:9,代碼來源:PhraseGenerater.cs

示例2: GetCodeOfWordLibrary

 public void GetCodeOfWordLibrary(WordLibrary wl)
 {
     if (wl.CodeType == CodeType.Pinyin)
     {
         var code = ChaoyinHelper.GetChaoyin(wl.PinYin);
         wl.SetCode(CodeType.Chaoyin, code);
     }
     else
     {
         wl.SetCode(CodeType.Chaoyin, GetCodeOfString(wl.Word));
     }
 }
開發者ID:XXpanda,項目名稱:imewlconverter,代碼行數:12,代碼來源:ChaoyinGenerater.cs

示例3: ImportLine

 public WordLibraryList ImportLine(string line)
 {
     string[] c = line.Split(' ');
     var wl = new WordLibrary();
     string code = c[0];
     wl.Word = c[1];
     wl.Rank = DefaultRank;
     wl.SetCode(CodeType.Cangjie, pyGenerater.GetCodeOfString(wl.Word));
     wl.SetCode(CodeType, code);
     var wll = new WordLibraryList();
     wll.Add(wl);
     return wll;
 }
開發者ID:studyzy,項目名稱:imewlconverter,代碼行數:13,代碼來源:CangjiePlatform.cs

示例4: ImportLine

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

            for (int i = 1; i < strs.Length; i++)
            {
                var 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(this.CodeType,strs[0]);
                wlList.Add(wl);
                //}
            }
            return wlList;
        }
開發者ID:hahadalin,項目名稱:imewlconverter,代碼行數:25,代碼來源:Jidian.cs

示例5: ImportLine

 public WordLibraryList ImportLine(string line)
 {
     string code = line.Split(' ')[0];
     string word = line.Split(' ')[1];
     var wl = new WordLibrary();
     wl.Word = word;
     wl.Rank = DefaultRank;
     wl.SetCode(CodeType.Wubi, code);
     //wl.PinYin = CollectionHelper.ToArray(pinyinFactory.GetCodeOfString(word));
     var wll = new WordLibraryList();
     if (wl.PinYin.Length > 0)
     {
         wll.Add(wl);
     }
     return wll;
 }
開發者ID:studyzy,項目名稱:imewlconverter,代碼行數:16,代碼來源:Wubi86.cs

示例6: BuildWordLibrary

        /// <summary>
        /// 根據Pattern設置的格式,對輸入的一行該格式的字符串轉換成WordLibrary
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public WordLibrary BuildWordLibrary(string line)
        {
            var wl = new WordLibrary();
            string[] strlist = line.Split(new[] { SplitString }, StringSplitOptions.RemoveEmptyEntries);
            var newSort = new List<int>(Sort);
            newSort.Sort();
            if (isPinyin)
            {
                int index1 = Sort.FindIndex(i => i == newSort[0]); //最小的一個
                if (index1 == 0 && ContainCode) //第一個是編碼
                {
                    wl.PinYinString = strlist[0];
                }
                if (index1 == 1)//第一個是漢字
                {
                    wl.Word = strlist[0];
                }
                if (index1 == 2 && ContainRank)//第一個是詞頻
                {
                    wl.Count = Convert.ToInt32(strlist[0]);
                }
                if (strlist.Length > 1)
                {
                    int index2 = Sort.FindIndex(i => i == newSort[1]); //中間的一個
                    if (index2 == 0 && ContainCode) //一個是Code
                    {
                        wl.PinYinString = strlist[1];
                    }
                    if (index2 == 1)
                    {
                        wl.Word = strlist[1];
                    }
                    if (index2 == 2 && ContainRank)
                    {
                        wl.Count = Convert.ToInt32(strlist[1]);
                    }
                }
                if (strlist.Length > 2)
                {
                    int index2 = Sort.FindIndex(i => i == newSort[2]); //最大的一個
                    if (index2 == 0 && ContainCode) //第一個是拚音
                    {
                        wl.PinYinString = strlist[2];
                    }
                    if (index2 == 1)
                    {
                        wl.Word = strlist[2];
                    }
                    if (index2 == 2 && ContainRank)
                    {
                        wl.Count = Convert.ToInt32(strlist[2]);
                    }
                }

                wl.PinYin = wl.PinYinString.Split(new[] { CodeSplitString }, StringSplitOptions.RemoveEmptyEntries);

            }
            else//不是拚音,那麽就拋棄直接加入Unknown Code。
            {
                int index1 = Sort.FindIndex(i => i == newSort[0]); //最小的一個
                if (index1 == 0 && ContainCode) //第一個是Code
                {
                    wl.SetCode(CodeType.Unknown, strlist[0]);
                }
                if (index1 == 1)
                {
                    wl.Word = strlist[0];
                }
                if (index1 == 2 && ContainRank)
                {
                    wl.Count = Convert.ToInt32(strlist[0]);
                }
                if (strlist.Length > 1)
                {
                    int index2 = Sort.FindIndex(i => i == newSort[1]); //中間的一個
                    if (index2 == 0 && ContainCode) //第一個是Code
                    {
                        wl.SetCode(CodeType.Unknown, strlist[1]);
                    }
                    if (index2 == 1)
                    {
                        wl.Word = strlist[1];
                    }
                    if (index2 == 2 && ContainRank)
                    {
                        wl.Count = Convert.ToInt32(strlist[1]);
                    }
                }
                if (strlist.Length > 2)
                {
                    int index2 = Sort.FindIndex(i => i == newSort[2]); //最大的一個
                    if (index2 == 0 && ContainCode) //第一個是拚音
                    {
                        wl.SetCode(CodeType.Unknown, strlist[2]);
                    }
//.........這裏部分代碼省略.........
開發者ID:kansifang,項目名稱:imewlconverter,代碼行數:101,代碼來源:ParsePattern.cs

示例7: ImportLine

 //private IWordCodeGenerater pyGenerater = new PinyinGenerater();
 public WordLibraryList ImportLine(string str)
 {
     var list = new WordLibraryList();
     string[] words = str.Split(' ');
     for (int i = 1; i < words.Length; i++)
     {
         string word = words[i];
         var wl = new WordLibrary();
         wl.Word = word;
         wl.Rank = DefaultRank;
         wl.SetCode(CodeType, words[0]);
         //wl.PinYin = CollectionHelper.ToArray(pyGenerater.GetCodeOfString(word));
         list.Add(wl);
     }
     return list;
 }
開發者ID:XXpanda,項目名稱:imewlconverter,代碼行數:17,代碼來源:Xiaoxiao.cs

示例8: GenerateCode

 private void GenerateCode( WordLibrary wl)
 {
     var word = wl.Word;
     if (SelectedParsePattern.IsPinyin&&SelectedParsePattern.IsPinyinFormat)
     {
         var py = pyFactory.GetCodeOfString(word, SelectedParsePattern.CodeSplitString);
         wl.PinYin = CollectionHelper.ToArray(py);
     }
     else
     {
         if (!string.IsNullOrEmpty(SelectedParsePattern.MappingTablePath))
         {
             SelectedParsePattern.MappingTable = UserCodingHelper.GetCodingDict(SelectedParsePattern.MappingTablePath);
         }
         selfFactory.MappingDictionary = SelectedParsePattern.MappingTable;
         selfFactory.Is1Char1Code = SelectedParsePattern.IsPinyinFormat;
         selfFactory.MutiWordCodeFormat = SelectedParsePattern.MutiWordCodeFormat;
         wl.SetCode(CodeType.UserDefine, selfFactory.GetCodeOfString(word, SelectedParsePattern.CodeSplitString));
     }
 }
開發者ID:kansifang,項目名稱:imewlconverter,代碼行數:20,代碼來源:SelfDefiningConfigForm.cs

示例9: ImportLine

        //private IWordCodeGenerater pyGenerater=new PinyinGenerater();
        public WordLibraryList ImportLine(string line)
        {
            string[] lineArray = line.Split('\t');

            string word = lineArray[0];
            string code = lineArray[1];
            var wl = new WordLibrary();
            wl.Word = word;
            wl.Count = Convert.ToInt32(lineArray[2]);
            if (CodeType == CodeType.Pinyin)
            {
                wl.PinYin = code.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            }
            else
            {
                //wl.PinYin = CollectionHelper.ToArray(pyGenerater.GetCodeOfString(wl.Word));
                wl.SetCode(CodeType, code);
            }

            var wll = new WordLibraryList();
            wll.Add(wl);
            return wll;
        }
開發者ID:kansifang,項目名稱:imewlconverter,代碼行數:24,代碼來源:Rime.cs

示例10: ImportLine

 public WordLibraryList ImportLine(string line)
 {
     string[] c = line.Split(' ');
     var wl = new WordLibrary();
     string code = c[0];
     wl.Word = c[1];
     wl.Count = DefaultRank;
     wl.PinYin = CollectionHelper.ToArray(pyGenerater.GetCodeOfString(wl.Word));
     wl.SetCode(CodeType, code);
     var wll = new WordLibraryList();
     wll.Add(wl);
     return wll;
 }
開發者ID:hahadalin,項目名稱:imewlconverter,代碼行數:13,代碼來源:CangjiePlatform.cs

示例11: BuildWlString

 /// <summary>
 /// 隻有單詞的情況下,根據規則生成目標格式的編碼
 /// </summary>
 /// <param name="word"></param>
 /// <returns></returns>
 public string BuildWlString(string word)
 {
     WordLibrary wl=new WordLibrary(){Word = word};
     if (IsPinyin)
     {
         var py = pyFactory.GetCodeOfString(word, CodeSplitString);
         wl.PinYin = CollectionHelper.ToArray(py);
     }
     else
     {
         wl.SetCode(CodeType.UserDefine, selfFactory.GetCodeOfString(word, CodeSplitString));
     }
     //todo
     return word;
 }
開發者ID:startewho,項目名稱:imewlconverter,代碼行數:20,代碼來源:ParsePattern.cs

示例12: BuildWordLibrary

        /// <summary>
        /// 根據Pattern設置的格式,對輸入的一行該格式的字符串轉換成WordLibrary
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public WordLibrary BuildWordLibrary(string line)
        {
            var wl = new WordLibrary();
            wl.CodeType = UserDefiningPattern.CodeType;
            string[] strlist = line.Split(new[] {UserDefiningPattern.SplitString}, StringSplitOptions.RemoveEmptyEntries);
            var newSort = new List<int>(UserDefiningPattern.Sort);
            newSort.Sort();
            string code = "", word = "";
            int rank = 0;

            int index1 = UserDefiningPattern.Sort.FindIndex(i => i == newSort[0]); //最小的一個
            if (index1 == 0 && UserDefiningPattern.ContainCode) //第一個是編碼
            {
                code = strlist[0];
            }
            if (index1 == 1) //第一個是漢字
            {
                word = strlist[0];
            }
            if (index1 == 2 && UserDefiningPattern.ContainRank) //第一個是詞頻
            {
                rank = Convert.ToInt32(strlist[0]);
            }
            if (strlist.Length > 1)
            {
                int index2 = UserDefiningPattern.Sort.FindIndex(i => i == newSort[1]); //中間的一個
                if (index2 == 0 && UserDefiningPattern.ContainCode) //一個是Code
                {
                    code = strlist[1];
                }
                if (index2 == 1)
                {
                    word = strlist[1];
                }
                if (index2 == 2 && UserDefiningPattern.ContainRank)
                {
                    rank = Convert.ToInt32(strlist[1]);
                }
            }
            if (strlist.Length > 2)
            {
                int index2 = UserDefiningPattern.Sort.FindIndex(i => i == newSort[2]); //最大的一個
                if (index2 == 0 && UserDefiningPattern.ContainCode) //第一個是拚音
                {
                    code = strlist[2];
                }
                if (index2 == 1)
                {
                    word = strlist[2];
                }
                if (index2 == 2 && UserDefiningPattern.ContainRank)
                {
                    rank = Convert.ToInt32(strlist[2]);
                }
            }
            wl.Word = word;
            wl.Rank = rank;
            if (code != "")
            {
                if (UserDefiningPattern.IsPinyinFormat)
                {
                    string[] codes = code.Split(new[] {UserDefiningPattern.CodeSplitString},
                        StringSplitOptions.RemoveEmptyEntries);
                    wl.SetCode(UserDefiningPattern.CodeType, new List<string>(codes),UserDefiningPattern.IsPinyinFormat);
                }
                else
                {
                    wl.SetCode(UserDefiningPattern.CodeType, code);
                }
            }

            return wl;
        }
開發者ID:studyzy,項目名稱:imewlconverter,代碼行數:78,代碼來源:SelfDefining.cs


注:本文中的Studyzy.IMEWLConverter.Entities.WordLibrary.SetCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。