关于相似度的计算,自己目前用的方法很简单,就是将经过人工取得到的主题词经过人工的给分之后,程序读到内存中,然后在需要分析的给定字符串中去查找是否有相关的词,如果有就加上相关的分值,,程序如下:
1
计算链接文本的分值 判断相关性
#region 计算链接文本的分值 判断相关性 2 /**//// <summary> 3 /// 计算文本的分值 判断相关性 4 /// </summary> 5 /// <param name="str">要计算的文本串</param> 6 /// <returns>分值</returns> 7 public static float CalCulateScore(string str,ArrayList topicWords) 8 { 9 float score = 0.0f;10 int count = 0, index=0,indexCount=0;1112 //计算链接文本的分值13 foreach (object obj in topicWords)14 {15 Aibo.Model.TopicLib tl = (Aibo.Model.TopicLib)obj;16 index = 0;17 indexCount = 0;1819 if (str.IndexOf(tl.word) > -1)20 {21 //统计tl.word 在 str出现的次数 22 do23 {24 index = str.IndexOf(tl.word, index)+1;25 indexCount += 1;26 }27 while (str.IndexOf(tl.word, index) > -1);2829 count += indexCount;30 score += tl.score * indexCount;31 }32 }33 if (count != 0)34 {35 score = score / (float)count;36 }37 return score;38 }39 #endregion
这样写也有不足,就是只有数据库中有相关的主题词时,才会计算到,如果有一些相关的主题词不在数据库中时,就计算不正确了,也希望高人能给些意见或代码.
作者:江南的俊马
http://www.21zhu.com
转载于:https://www.cnblogs.com/aibosoft/archive/2007/10/14/923931.html
相关资源:各显卡算力对照表!