Esempio n. 1
0
        private static Pinyin CEdictpinyin2pinyin(String CEpinyin)
        {
            Pinyin pinyinout = new Pinyin();

            CEpinyin = CEpinyin.Trim();                          //clean off trailing space
            CEpinyin = CEpinyin.Trim(new char[] { '[', ']' });   // remove initial and final []

            string[] words = CEpinyin.Split(new char[] { ' ' }); // Split on spaces to get {"ni3", "hao3"}

            foreach (string s in words)
            {
                string tone = Regex.Match(s, @"\d+").Value; //Get tone number
                if (tone != "")
                {
                    pinyinout.Add(new PinyinChar(s.Replace(tone, ""), Int32.Parse(tone)));
                }
                else
                {
                    pinyinout.Add(null);
                }
            }

            return(pinyinout);
        }