如何在SQL里求得某两行的同一列内容的相关性?

My65sky 2006-07-26 03:54:43
在某个库中有一列,类型是nvarchar(20),请问,如何在SQL里求得其中某两行之间此列内容的相关性?从而返回一个数字(整型或浮点型).
...全文
80 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Seaoh 2006-07-26
  • 打赏
  • 举报
回复
Dim Title, Content, Keyword, Lengths, i, Titlex
Title = "把教学计划交给院长去查看"
Content = "将下月的教学计划和相应的交交资料给院长查看将下月的教学计划和相应的交交资料给院长查看"
Titlex = "把教学计划交给院长去查看"
Set Keyword = Server.CreateObject("Scripting.Dictionary")
Set Lengths = Server.CreateObject("Scripting.Dictionary")
i = 0
while i < Len(Title)
Dim tmpCon, tmpKey, tmpLen
i = i + 1
tmpKey = Mid(Title,i,1)
tmpCon = Replace(Content,tmpKey,"")
tmpLen = (Len(Content) - Len(tmpCon)) / Len(tmpKey)

If CStr(tmpLen) = CStr(Lengths(Lengths.Count - 1)) and Keyword.Count > 0 Then
Keyword(Keyword.Count - 1) = Keyword(Keyword.Count - 1) & tmpKey
Else
If Keyword.Count > 0 Then
Lengths(Lengths.Count - 1) = tmpLen / Len(Content)
End If
Lengths.Add Lengths.Count, tmpLen
Keyword.Add Keyword.Count, tmpKey
End If
wend
for i = 0 to Keyword.Count - 1
Response.Write Keyword(i) & ","
next
Response.Write "<br />"
Dim e
for i = 0 to Keyword.Count - 1
tmpKey = Keyword(i)
tmpCon = Replace(Titlex,tmpKey,"")
tmpLen = (Len(Titlex) - Len(tmpCon)) / Len(tmpKey)
e = e + tmpLen / Len(Titlex) * Lengths(i)
next
Response.Write e * 100

遇到了点小问题,两个句子一样时,得到的不是100.
Seaoh 2006-07-26
  • 打赏
  • 举报
回复
用ASP到是可以.利用统计的方法.
My65sky 2006-07-26
  • 打赏
  • 举报
回复
主要是为了排序,返回什么类型都行只要能排序就行.越相近的越排在前面.

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧