On Thu, 12 May 2005 02:01:54 GMT, MnMs@. wrote:
I've got a catalog (table) of products (records), which will
undoubtedly grow to over 5000 records in months. This is in an Access
2000 mdb file behind an ASP page, and the products have full text
descriptions. I want my customer to easily "search" the database
table with a simple SQL query. I guess I'll use a LIKE operator to
search the field with the product's long description.
Problem: Noise words. i.e. - and, but, it, its, or, the... will
return thousands of records and slow down browsing efficiency.
Has anyone got a good solution to easily eliminate noise words from
submitted text entered into the asp page "search" field?
I was able to find the file noise.enu from the Microsoft Index server
installation. It has about 50 words or so. Would I use a replace()
function to eliminate the words from my sql statement?
I'm sure someone else has come across this.
What would be the BEST and most logical way of using VBscript and ASP
to accept the query string typed and then condition it for
introduction into a "LIKE" statement in an ADO query?
Any better ideas?
Any response would be appreciated.
Just for a reference, in case anyone else searches archives... I found
this ... seems to work!
' ################################################## ############
' ## ClearNoiseWords ##
' ## Author : Andy Sheel ##
' ## Date : 27/04/04 ##
' ## Licence: Free (GNU) ##
' ## ##
' ################################################## ############
Function ClearNoiseWords(SearchString)
Dim CleanedString ' String to hold cleaned search terms
Dim searchArray ' Array to hold Search Terms
Dim NoiseArray() ' Array to hold Noise Words
Dim objFSO ' FileSystemObject
Dim TS ' TextStreamObject
Dim strLine ' local variable to store Line
Dim strFileName ' local variable to store fileName
Dim ArrayPointer, i, j ' int's to hold array pointers
Dim CurRecords
Const ForReading = 1
Const Create = False
ArrayPointer = 0
' Noise Word File
' Change this to where your noise file is.
strFileName = Server.Mappath("\noise.txt")
' tokenise search string into array
searchArray = split(SearchString, " ")
' Open Noise Word File
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' use Opentextfile Method to Open the text File
Set TS = objFSO.OpenTextFile(strFileName, ForReading, Create)
If Not TS.AtEndOfStream Then
ReDim NoiseArray(0)
Do While Not TS.AtendOfStream
strLine = TS.ReadLine
' Read words into an array
CurRecords = uBound(NoiseArray)
REDIM PRESERVE NoiseArray(CurRecords + 1)
NoiseArray(ArrayPointer) = Trim(strLine)
ArrayPointer = ArrayPointer + 1
Loop
End If
' for each search word, compare it with the noise list
' then delete any noise words
For i = 0 to UBound(searchArray)
For j = 0 to UBound(NoiseArray)
If lcase(searchArray(i)) =
lcase(NoiseArray(j)) Then
searchArray(i) = ""
End If
Next
Next
' make new string without noicse words
For i = 0 to UBound(searchArray)
CleanedString = CleanedString & searchArray(i) & " "
Next
' Return Clean String
ClearNoiseWords = Trim(CleanedString)
End Function