Thanks -- my vb6 recognizes wordctl.document -- but there is no word.document or word.application.
Printable View
Thanks -- my vb6 recognizes wordctl.document -- but there is no word.document or word.application.
sorry. you need to add a reference to the Microsoft Word x.0 Object Library
Wow, Pretty incredible static. I found the word reference shortly after I posted my false alarm. I think I'm almost done, my next task is to take the questions and answers and dump them to a *.aiml file in the format :
<aiml>
<category>
<pattern>WHAT ARE YOU</pattern>
<template>
I am the latest result in artificial intelligence,
which can reproduce the capabilities of the human brain
with greater speed and accuracy.
</template>
</category>
.
.
.
<aiml>
I appreciate any inputs. Many thanks again.
Static, Rory, everyone thanks for your suggestions. The word suggestion was the turning point.
This code works for the last faq page I suggested and maybe similar formats. Unfortunately my chatbot is having trouble learning the output but I dont think that's a vb6 problem. Hopefully I'll find a way to make the code work for other faq pages. My ultimate goal is to teach a chatbot info from any kind of page but again that might be a more of an aiml research project.
Private Sub Crawl_Click()
WebBrowser1.Navigate Url.Text
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate Url.Text
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, Url As Variant)
Dim hText As String, terms() As String, x As Integer, i As Integer, question1 As IntegerEnd Sub
i = 0
If (pDisp Is WebBrowser1.Application) Then
'Debug.Print WebBrowser1.Document.documentElement.innerText
hText = WebBrowser1.Document.documentElement.innerText
'terms() = Split(webpage, ".")
Dim tmp As String
'Start new word app
Dim wrd As New Word.Application
Dim Doc As Word.Document
'New Document
Set Doc = wrd.Documents.Add
Dim dSentences() As String
Dim questions() As String, answesrs() As String
'just so we can see it....
'wrd.Visible = True
'type the "text" into the doc
wrd.selection.TypeText Text:=hText
'set each sentence to an element in the array dSentences
ReDim dSentences(Doc.Sentences.Count - 1)
For x = 1 To Doc.Sentences.Count
dSentences(x - 1) = Doc.Sentences(x).Text
If InStr(Doc.Sentences(x).Text, "?") Then
i = i + 1
End If
Next
ReDim questions(i - 1)
ReDim answers(i - 1)
Dim j As Integer
j = 0
Dim response As String
i = 0
'loop through populate the arrays
For x = 0 To UBound(dSentences)
Debug.Print dSentences(x)
If InStr(dSentences(x), "?") Then
'questions array
questions(i) = dSentences(x)
i = i + 1
'populate answer array
response = Empty
x = x + 1
Do While InStr(dSentences(x), "?") = False And x <> UBound(dSentences)
If dSentences(x) <> Empty Then
response = response & dSentences(x)
End If
If x <> UBound(dSentences) Then
x = x + 1
End If
Loop
x = x - 1
If dSentences(x) <> Empty Then
answers(j) = response
j = j + 1
End If ' populate answer array
End If
Next
'write aiml file
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("C:\Documents and Settings\Administrator\Desktop\testfile.aiml", True)
a.Write "<aiml>"
For x = 0 To UBound(questions)
a.Writeline
a.Writeline
a.Write "<category>"
a.Writeline
a.Write "<pattern>" & questions(x) & "</pattern>"
a.Writeline
a.Write "<template>" & answers(x) & "</template>"
a.Writeline
a.Write "</category>"
Next
a.Writeline
a.Writeline
a.Write "</aiml>" ' aiml file written
Doc.Close False
wrd.Quit False
Set Doc = Nothing
Set wrd = Nothing
a.Close 'close aiml file
End If
tyademosu - if you are all set with this post.. could you mark it resolved?
(Click thread tools - Mark thread resolved)
THANKS! :wave:
The job is actually only about half done for me. I'm hoping I can leave this open for a while longer.
Quick question can anyone recommened a fast way to remove the "?" at the end of each question. Thanks again.
format ...john? ....jane? etc
False alarm. Replace() seems work great.