Example #1
0
        /// <summary>
        /// 更新标记
        /// </summary>
        /// <param name="smartMark">标记名称</param>
        /// <param name="textString">需更新的字符串</param>
        private static void UpdateMark(string smartMark, string textString)
        {
            //载入对应标记
            XElement markXE = smartXE.Element(smartMark);

            //标记不存在->创建>>添加至smartXE>>继续
            if (markXE == null)
            {
                markXE = new XElement(smartMark);
                smartXE.Add(markXE);
            }

            //获取文本对应标签
            XElement textXE = markXE.Elements().FirstOrDefault(_func => _func.Attribute("t").Value == textString);

            //文本标签不存在->创建>>继续
            if (null == textXE)
            {
                markXE.AddFirst(new XElement("m",
                                             new XAttribute("t", textString),
                                             new XAttribute("l", Chinese2Spell.Convert(textString, false, "[字母] [拼音]").ToLower()),
                                             new XAttribute("w", "1"),
                                             new XAttribute("u", DateTime.Now.ToShortDateString())));
            }
            else//存在->权重+1>>更新时间>>继续
            {
                textXE.Attribute("w").Value = (int.Parse(textXE.Attribute("w").Value) + 1).ToString();
                textXE.Attribute("u").Value = DateTime.Now.ToShortDateString();
            }
        }
Example #2
0
 public static string CompanyNameToSpell(string CompanyName)
 {
     return(Chinese2Spell.Convert(ShortCompanyName(CompanyName), false, "[字母] [拼音]").ToLower());
 }