예제 #1
0
 public static string GetShouZiMu(string strChinese)
 {
     return(ChinesePinyin.GetShouZiMu(strChinese, ""));
 }
예제 #2
0
        private void DoConvertToPinyin()
        {
            StringBuilder stringBuilder = new StringBuilder();
            List <char>   list          = new List <char>();
            List <string> list2         = new List <string>();

            this.ClearResult();
            for (int index = 0; index < this.m_chineseString.Length; index++)
            {
                char   index2 = this.m_chineseString[index];
                string str    = "";
                char   ch     = '\0';
                bool   flag   = false;
                bool   flag2  = false;
                list2.Clear();
                bool flag3 = ChinesePinyin.IsChineseLetter(index2);
                if (flag3)
                {
                    bool flag4 = index == 0;
                    if (flag4)
                    {
                        this.m_chineseCharacter = index2;
                    }
                    CharUnit charUnit = ChinesePinyin.charDictionary.GetCharUnit(index2);
                    bool     flag5    = charUnit != null;
                    if (flag5)
                    {
                        int        num = (int)charUnit.m_pinyinCount;
                        PinyinUnit pinYinUnitByIndex = ChinesePinyin.pinyinDictionary.GetPinYinUnitByIndex((int)charUnit.PinyinIndexList[0]);
                        bool       flag6             = pinYinUnitByIndex != null;
                        if (flag6)
                        {
                            str = pinYinUnitByIndex.Pinyin.Substring(0, pinYinUnitByIndex.Pinyin.Length - 1).ToLower();
                            ch  = pinYinUnitByIndex.Pinyin[0];
                            list2.Add(str);
                            bool flag7 = index == 0;
                            if (flag7)
                            {
                                this.m_strokeNumber  = (short)charUnit.m_strokeNumber;
                                this.m_pinyinCount   = (short)charUnit.m_pinyinCount;
                                this.m_isPolyphone   = (this.m_pinyinCount > 1);
                                this.m_pinyinList[0] = pinYinUnitByIndex.Pinyin.ToLower();
                            }
                        }
                        for (int index3 = 1; index3 < num; index3++)
                        {
                            PinyinUnit pinYinUnitByIndex2 = ChinesePinyin.pinyinDictionary.GetPinYinUnitByIndex((int)charUnit.PinyinIndexList[index3]);
                            bool       flag8 = pinYinUnitByIndex2 != null;
                            if (flag8)
                            {
                                string str2  = pinYinUnitByIndex2.Pinyin.ToLower();
                                bool   flag9 = index == 0;
                                if (flag9)
                                {
                                    this.m_pinyinList[index3] = str2;
                                }
                                string str3   = str2.Substring(0, str2.Length - 1);
                                bool   flag10 = !list2.Contains(str3);
                                if (flag10)
                                {
                                    list2.Add(str3);
                                    flag = true;
                                    bool flag11 = ch != pinYinUnitByIndex2.Pinyin[0];
                                    if (flag11)
                                    {
                                        flag2 = true;
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    str = index2.ToString();
                    ch  = index2;
                }
                bool flag12 = ChinesePinyin.pinyinCustom.ContainsKey(index2);
                if (flag12)
                {
                    string str4 = ChinesePinyin.pinyinCustom[index2];
                    str = str4.ToLower();
                    bool flag13 = str4.Length > 0;
                    if (flag13)
                    {
                        ch = str4[0];
                    }
                }
                bool flag14 = str != "";
                if (flag14)
                {
                    stringBuilder.Append(str);
                    this.m_strShouZiMu += ch.ToString();
                    bool flag15 = flag && !list.Contains(index2);
                    if (flag15)
                    {
                        list.Add(index2);
                        string str5 = "";
                        for (int index4 = 0; index4 < list2.Count; index4++)
                        {
                            bool flag16 = str5 != "";
                            if (flag16)
                            {
                                str5 += " ";
                            }
                            str5 += list2[index4];
                        }
                        this.m_strPolyphone1 = string.Concat(new string[]
                        {
                            this.m_strPolyphone1,
                            index2.ToString(),
                            "(",
                            str5,
                            ")"
                        });
                        bool flag17 = flag2;
                        if (flag17)
                        {
                            this.m_strPolyphone2 = string.Concat(new string[]
                            {
                                this.m_strPolyphone2,
                                index2.ToString(),
                                "(",
                                str5,
                                ")"
                            });
                        }
                    }
                }
                else
                {
                    this.m_unknownChars += index2.ToString();
                    bool flag18 = this.m_unknownFill != "";
                    if (flag18)
                    {
                        stringBuilder.Append(this.m_unknownFill);
                        this.m_strShouZiMu += this.m_unknownFill;
                    }
                    else
                    {
                        stringBuilder.Append(index2);
                        this.m_strShouZiMu += index2.ToString();
                    }
                }
            }
            this.m_strPinYin = stringBuilder.ToString();
        }
예제 #3
0
 public static string GetPinYin(string strChinese)
 {
     return(ChinesePinyin.GetPinYin(strChinese, ""));
 }
예제 #4
0
 static ChinesePinyin()
 {
     ChinesePinyin.LoadResource();
     ChinesePinyin.LoadCustomResource();
 }