#region 方法:对要搜索的词分词第一种方法
/// <summary>
/// 对要搜索的词分词第一种方法
/// </summary>
/// <param name="keywords">要分的关键词</param>
/// <param name="ktTokenizer"></param>
/// <returns></returns>
static public string GetKeyWordsSplitBySpace(string keywords, PanGuTokenizer ktTokenizer)
{
StringBuilder result = new StringBuilder();
ICollection<WordInfo> words = ktTokenizer.SegmentToWordInfos(keywords);
foreach (WordInfo word in words)
{
if (word == null)
{
continue;
}
result.AppendFormat("{0}^{1}.0 ", word.Word, (int)Math.Pow(3, word.Rank));
}
return result.ToString().Trim();
}
#endregion
调用 string strkey = GetKeyWordsSplitBySpace(txtkey, new PanGuTokenizer());