- 方案1: 使用 舊版的斷詞DLL (CHTBRKR.DLL)
- 方案2: 使用詞庫來解決: tcainlex.txt
如果使用了方案1之後, 就會造成同義詞功能無法使用(tsCHT.XML)
目前暫時無解, 用最兩光的自己動手寫來解決:
dim checkKeywordExpansion
checkKeywordExpansion = ap_THESAURUS_expansion(myKeywordItem)
if myFieldName = "*" then
'// 查多個欄位, 全查.
searchFields = "*"
if checkKeywordExpansion = "" then
'// 一般查詢
myKeywordSQL = myKeywordSQL & dbQueryMethod &"("& searchFields &" ,N'" & myKeywordItem & "')"
else
'// expansion
myKeywordSQL = myKeywordSQL & "("
myKeywordSQL = myKeywordSQL & dbQueryMethod &"("& searchFields &" ,N'" & myKeywordItem & "')"
myKeywordSQL = myKeywordSQL & " OR " & dbQueryMethod &"("& searchFields &" ,N'" & checkKeywordExpansion & "')"
myKeywordSQL = myKeywordSQL & ")"
end if
else
'// 只查某個欄位.
searchFields = myFieldName
if checkKeywordExpansion = "" then
'// 一般查詢
myKeywordSQL = myKeywordSQL & dbQueryMethod &"("& searchFields &" ,N'" & myKeywordItem & "')"
else
'// expansion
myKeywordSQL = myKeywordSQL & "("
myKeywordSQL = myKeywordSQL & dbQueryMethod &"("& searchFields &" ,N'" & myKeywordItem & "')"
myKeywordSQL = myKeywordSQL & " OR " & dbQueryMethod &"("& searchFields &" ,N'" & checkKeywordExpansion & "')"
myKeywordSQL = myKeywordSQL & ")"
end if
end if
'// purpose: 是否符合 THESAURUS_expansion rule.
'// return: 傳回 keyword expansion 後結果.
'// ps: 這個不是 "最佳解法", 只是為了立刻解掉這個問題.
'// 由於換掉斷詞工具. 無法使用 THESAURUS
function ap_THESAURUS_expansion(byval keywordItem)
dim returnValue
returnValue = ""
dim isMatchExpansion
isMatchExpansion = not True
dim currentPat
currentPat = ""
if not isMatchExpansion then
currentPat = "台"
currentSub = "臺"
if instr(keywordItem, currentPat) > 0 then
isMatchExpansion = true
returnValue = replace(keywordItem, currentPat, currentSub)
end if
end if
if not isMatchExpansion then
currentPat = "臺"
currentSub = "台"
if instr(keywordItem, currentPat) > 0 then
isMatchExpansion = true
returnValue = replace(keywordItem, currentPat, currentSub)
end if
end if
ap_THESAURUS_expansion = returnValue
end function
相關文章:
[SQL]使用SQL2005全文檢索功能
http://www.dotblogs.com.tw/dotjum/archive/2009/08/01/9796.aspx
SQL Server 2005/2008 斷字詞 DLL
http://byronhu.wordpress.com/2009/03/13/sql-server-20052008-%E6%96%B7%E5%AD%97%E8%A9%9E-dll/
沒有留言:
張貼留言