asp中利用CSW中文分片語件來實現自己網站的內容關鍵詞自動提取_應用技巧

來源:互聯網
上載者:User
比如標題是:騰訊QQ 2006 珊瑚蟲整合版 v4.5b
分詞後:[此資源關鍵詞:騰訊 QQ 珊瑚蟲 整合 ]
並且把關鍵詞做成專題,可以為每個內容頁面產生相關串連了
用CSW中文分片語件
下載:http://www.vgoogle.net/Product_CSW.asp
下面是我的ASP代碼,比較粗淺,但實用

codecsw 得到輸出的所有分詞結果,用它的組建裡面有個ASP檔案,你一看就知道怎麼得到分詞結果了,這個不詳細說了。
複製代碼 代碼如下:

fcon=split(htm," ")
fcs=ubound(fcon)
for fci=0 to fcs
if fci mod 2=0 then
fcn=fcn&fcon(fci)&"$fc^#$"  '我這裡用$fc^#$來分割每個分詞
else
fcw=fcw&fcon(fci)&"$fc^#$"
end if

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)
for doi=0 to dos
fcname=don(doi)  '得到分詞
fcsx=donn(doi)   '得到分詞屬性
'下面是判斷分詞符合我所提出的屬性,比如名詞、名動詞、動詞等,排除了數詞、狀詞和串連詞等。
if fcsx="/b" or fcsx="/nz" or fcsx="/n" or fcsx="/an" or fcsx="/nx" or fcsx="/f" or fcsx="/i" or fcsx="/l" or fcsx="/ng" or fcsx="/nr" or fcsx="/ns" or fcsx="/nt" or fcsx="/nz" or fcsx="/v" or fcsx="/vn" or fcsx="/s" or fcsx="/g" then
if len(fcname)>1 then
if instr(fcname1,fcname&"$") then
else
if fcname<>" " and fcname<>"" then
fcname=replace(replace(replace(trim(fcname),chr(10),""),chr(13),""),chr(10)&chr(13),"") '去除分詞的換行和斷行符號鍵
if len(fcname)>1 then
'這裡是分詞入庫,我的分詞庫只有三個欄位,自動ID、分詞名稱和分詞所屬的內容ID
Set Rs = CreateObject("ADODB.Recordset")
sql="select top 1 * from fc where fcname='"&fcname&"'"
rs.open sql,conn,1,3
if rs.eof then
rs.addnew
end if
rs("fcname")=fcname
if instr(rs("mid"),","&id&",") then
else
rs("mid")=rs("mid")&","&id&","
end if
rs.update
rs.close
set rs=nothing
'分詞入庫結束
end if
end if
response.write fcname&"("&fcsx&")<br>"
mfc=mfc&fcname&","
end if
fcname1=fcname1&fcname&"$"
end if
end if
next
'這裡是將分詞添加到內容表,在內容表我只多加了一個分詞欄位mfc
if right(mfc,1)="$" then mfc=left(mfc,len(mfc)-1)
Set Rs = CreateObject("ADODB.Recordset")
sql="select top 1 mfc from m where mid="&id
rs.open sql,conn,1,3
rs("mfc")=mfc
rs.update
rs.close
set rs=nothing
end if

就這樣實現了,呵呵,在分詞表的內容ID都是用,來分割的,讀取的時候自己研究下就可以
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.