Ejemplo n.º 1
0
        static String2Pinyin()
        {
            _trie = new Trie()
            {
                RemainLongest = true
            };                                              // todo: 可以改成双数组
            _map = new SortedDictionary <string, Pinyin>(StrComparer.Default);
            int end = (int)PYName.none5;

            for (int i = 0; i < end; i++)
            {
                var py            = Pinyin.PinyinTable[i];
                var pyWithoutTone = py.Pinyin_;
                var fstChar       = py.FirstChar.ToString();

                _trie.AddKeyword(pyWithoutTone);
                _trie.AddKeyword(fstChar);
                _map[pyWithoutTone] = py;
                _map[fstChar]       = py;
                _map[py.ToString()] = py;
            }
        }