日期:2014-05-17 浏览次数:20584 次
private static string Preview(string body, string keyword)
{
//创建HTMLFormatter,参数为高亮单词的前后缀
var simpleHTMLFormatter =
new SimpleHTMLFormatter("<font color=\"red\">", "</font>");
//创建 Highlighter ,输入HTMLFormatter 和 盘古分词对象Semgent
var highlighter =
new Highlighter(simpleHTMLFormatter,
new Segment());
//设置每个摘要段的字符数
highlighter.FragmentSize = 100;
//获取最匹配的摘要段
String bodyPreview = highlighter.GetBestFragment(keyword, body);
if (bodyPreview == null
------解决方案--------------------
bodyPreview == "")
return body;
return bodyPreview;
}
//TextBox1为高亮,intor为内容,n.Intor为返回值
n.Intor = Preview(intor, TextBox1.Text);