/// <summary> /// 获取指定拼音的汉字集合 /// </summary> /// <param name="input">指定的拼音</param> /// <param name="sortByFreq">输入是否按使用频率进行排序</param> /// <returns></returns> public static char[] GetCharArrayOfPinyin(string input, bool sortByFreq = true) { var charArray = new List <char>(); for (int i = 1; i <= 5; i++) { char[] chars = ChineseChar.GetChars(string.Format("{0}{1}", input, i)); if (chars != null) { charArray.AddRange(chars); } } _logger.Trace(string.Format("拼音分割完成:{0},{1}", input, charArray.Count)); if (sortByFreq) { return(ListFrequencySort(charArray)); } return(charArray.ToArray()); }
public static string ConvertToHans(string pinyin) { //StringBuilder sb = new StringBuilder(); char[] str = ChineseChar.GetChars(pinyin); return(str.ToString()); }