<% Response.Buffer = TRUE %> Früvous Playground Ask Dave's Head

Früvous Playground - Ask Dave's Head

<% dim QuestionWords, IgnoreWords, QuoteWords adOpenStatic = 3 adOpenDynamic = 2 adOpenKeyset = 1 Set DaveQTable = CreateObject("ADODB.Recordset") DaveQTable.Open "Select * from QuestionsAsked", "DSN=daveshead;", adOpenStatic DaveQTable.Move 5 x = 1 Do While Not( DaveQTable.EOF) and x < 100 Question = DaveQTable.Fields("Question") If Not(IsNull(Question)) and Question <> "" Then If Question = PrevQuestion Then RepeatArray = Array("A bit repetitious", "Just when you'd say, that's when you'd say it again", "Didn't you like my answer?") Rnd(-1) Randomize() RandomNo = (CInt((3*Rnd) + 1)) Answer = RepeatArray(RandomNo) Else ReFormatQuestion = replace(Question,"?"," ") ReFormatQuestion = replace(ReFormatQuestion,"'","") ReFormatQuestion = replace(ReFormatQuestion,"!"," ") ReFormatQuestion = replace(ReFormatQuestion,"."," ") ReFormatQuestion = replace(ReFormatQuestion,""","") ReFormatQuestion = LCase(ReFormatQuestion) QuestionWords= split(ReFormatQuestion," ") IgnoreWords = Array("what","where", "when", "why","will","how","is","are","they", "them", "you","me","I","who","and","but","was","were","the","should","would","could", "does", "your", "with","there", "many", "have", "about", "like", "because", "ever") SearchWords = " " i = 0 For Each QWord in QuestionWords IgnoreIt = 0 For Each IWord in IgnoreWords If QWord = IWord Then IgnoreIt = 1 End If Next If Len(QWord) <= 3 Then IgnoreIt = 1 End If If IgnoreIt = 0 Then SearchWords = SearchWords & " or LCase(Quote) Like '% " & QWord & "%'" Else QuestionWords(i) = "" End If i = i + 1 Next Set DaveTable = CreateObject("ADODB.Recordset") QueryString = "Select * from Quotes WHERE 1=0 " & SearchWords & " ORDER BY ((Second(Time())+35)^2*[id]) Mod 1223" DaveTable.Open QueryString, "DSN=daveshead;" If Not(DaveTable.EOF) Then MaxScore = 0 Do Until DaveTable.EOF Score = 0 Quote = DaveTable.Fields("Quote") ReFormatQuote = replace(Quote,"?"," ") ReFormatQuote = replace(ReFormatQuote,"'","") ReFormatQuote = replace(ReFormatQuote,"!"," ") ReFormatQuote = replace(ReFormatQuote,"."," ") ReFormatQuote = replace(ReFormatQuote,""","") ReFormatQuote = LCase(ReFormatQuote) QuoteWords= split(ReFormatQuote," ") For Each QWord in QuestionWords For Each QuoteWord in QuoteWords if QWord = QuoteWord or QWord = QuoteWord & "s" or QWord = QuoteWord & "'s" or QWord = QuoteWord & "ed" or QWord = QuoteWord & "er" Then Score = Score + Len(QWord) end if Next Next If Score >= MaxScore Then Answer = DaveTable.Fields("Quote") AnswerID = DaveTable.Fields("ID") MaxScore = Score End If DaveTable.MoveNext Loop Else DaveTable.Close Set DaveTable = CreateObject("ADODB.Recordset") DaveTable.Open "Select * from Quotes ", "DSN=daveshead;", adOpenStatic If NOT(DaveTable.EOF) Then DaveTable.MoveLast NumOfRecords = DaveTable.RecordCount DaveTable.MoveFirst Rnd(-1) Randomize() RandomRecord = (CInt((NumOfRecords*Rnd) + 1)) DaveTable.Move RandomRecord-1 Answer = DaveTable.Fields("Quote") AnswerID = DaveTable.Fields("ID") End If DaveTable.Close End If End If Else Answer = "Enter your question." End If %> <% x = x +1 DaveQTable.MoveNext Loop PrevQuestion = Question DaveQTable.Close %>
<%=Question%><%=Answer%> <%=maxscore%>