private Dictionary<string, string> substitutions { get; set; } = new Dictionary<string, string>();//多音字替换 //多音字转换 var pattern = string.Join("|", substitutions.Keys.Select(Regex.Escape)); var result = Regex.Replace(str, pattern, match => substitutions[match.Value]);
"Polyphone": { "text": "翟查郇盖曾乐华单仇重朴相解应繁要覃员都能瞿", "pronunciation": "宅渣环葛增月话善求虫瓢像谢硬婆腰勤云督耐劬" }
var polyphonetext = configuration["Polyphone:text"].ToString().ToArray(); var polyphonepronunciation = configuration["Polyphone:pronunciation"].ToString().ToArray(); for(var i = 0; i < polyphonetext.Length; i++) { substitutions.Add(polyphonetext[i].ToString(), polyphonepronunciation[i].ToString()); }
标签:字符,多音字,c#,substitutions,polyphonetext,Polyphone,ToString,var From: https://www.cnblogs.com/huanyun/p/17313706.html