hubbledotnet 分词方法
时间:2011-06-07 来源:freexiaoyu
public string GetKeywordAnalyzerStringFromServer(string tableName, string fieldName, string keywords, int cacheTimeout, out string bySpace) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("exec SP_FieldAnalyze '{0}', '{1}', '{2}', 'sqlclient' ", tableName.Replace("'", "''"), fieldName.Replace("'", "''"), keywords.Replace("'", "''")); System.Data.DataSet dssp = new Maticsoft.BLL.job_job().JobList(sb.ToString()); StringBuilder result = new StringBuilder(); StringBuilder bySpaceSb = new StringBuilder(); foreach (System.Data.DataRow row in dssp.Tables[0].Rows) { string word = row["Word"].ToString().Replace("'", "''"); bySpaceSb.AppendFormat("{0} ", word); result.AppendFormat("{0}^{1}^{2} ", word, row["Rank"], row["Position"]); } bySpace = bySpaceSb.ToString().Trim(); return result.ToString().Trim(); }
strkeyword = GetKeywordAnalyzerStringFromServer("job_job_select", "jobTitle", keyword, int.MaxValue, out wordssplitbyspace);
分词 表名,字段(比如 title 用的 pangu ,content 用的 English ,那么如果你输入 title 就按盘古分,输入 content 就按 English 分,因为不同字段可能分词器不一样
) 要分词的关键字
相关阅读 更多 +