比如標題是:騰訊QQ2006珊瑚蟲集成版v4.5b
分詞後:[此資源關鍵詞:騰訊QQ珊瑚蟲集成]
並且把關鍵詞做成專題,可以為每個內容頁面生成相關連接了
用CSW中文分詞組件
下載:http://www.vgoogle.net/Product_CSW.asp
下面是我的ASP代碼,比較粗淺,但實用
codecsw得到輸出的所有分詞結果,用它的組建裡面有個ASP文件,你一看就知道怎麼得到分詞結果了,這個不詳細說了。
複製代碼代碼如下:
fcon=split(htm,"")
fcs=ubound(fcon)
forfci=0tofcs
iffcimod2=0then
fcn=fcn&fcon(fci)&"$fc^#$"'我這裡用$fc^#$來分割每個分詞
else
fcw=fcw&fcon(fci)&"$fc^#$"
endif
next
fcn=left(fcn,len(fcn)-12)'去掉最前面的$fc^#$
fcw=left(fcw,len(fcw)-6)去掉最後面的$fc^#$
don=split(fcn,"$fc^#$")
donn=split(fcw,"$fc^#$")
dos=ubound(don)
fordoi=0todos
fcname=don(doi)'得到分詞
fcsx=donn(doi)'得到分詞屬性
'下面是判斷分詞符合我所提出的屬性,比如名詞、名動詞、動詞等,排除了數詞、狀詞和連接詞等。
iffcsx="/b"orfcsx="/nz"orfcsx="/n"orfcsx="/an"orfcsx="/nx"orfcsx="/f"orfcsx="/i"orfcsx="/l"orfcsx="/ng"orfcsx="/nr"orfcsx="/ns"orfcsx="/nt"orfcsx="/nz"orfcsx="/v"orfcsx="/vn"orfcsx="/s"orfcsx="/g"then
iflen(fcname)>1then
ifinstr(fcname1,fcname&"$")then
else
iffcname<>""andfcname<>""then
fcname=replace(replace(replace(trim(fcname),chr(10),""),chr(13),""),chr(10)&chr(13),"")'去除分詞的換行和回車鍵
iflen(fcname)>1then
'這裡是分詞入庫,我的分詞庫只有三個字段,自動ID、分詞名稱和分詞所屬的內容ID
SetRs=CreateObject("ADODB.Recordset")
sql="selecttop1*fromfcwherefcname='"&fcname&"'"
rs.opensql,conn,1,3
ifrs.eofthen
rs.addnew
endif
rs("fcname")=fcname
ifinstr(rs("mid"),","&id&",")then
else
rs("mid")=rs("mid")&","&id&","
endif
rs.update
rs.close
setrs=nothing
'分詞入庫結束
endif
endif
response.writefcname&"("&fcsx&")<br>"
mfc=mfc&fcname&","
endif
fcname1=fcname1&fcname&"$"
endif
endif
next
'這裡是將分詞添加到內容表,在內容表我只多加了一個分詞字段mfc
ifright(mfc,1)="$"thenmfc=left(mfc,len(mfc)-1)
SetRs=CreateObject("ADODB.Recordset")