dupa

Author Topic: HAL plugin, Client Side Server  (Read 31556 times)

vjimmerson

  • Newbie
  • *
  • Posts: 8
    • View Profile
HAL plugin, Client Side Server
« Reply #15 on: May 24, 2008, 06:03:35 pm »
<<Thank you Art!  I will play with it a bit.>>

Do each of the add-ins run each time a sentence is entered into Hals input screen? If so I can see where installing a lot of add-ins without knowing what they are doing could waste a lot of system resources.   I have a few questions about the AutoWikiKnowledge.uhp file.

Where does the variable/input 'InputString' come from?  
Is this an input variable and if so what would it contain?
Is InputString the same as the MyInput variable?


Does HalXBrain.AppendFile do something different then using Scripting.FileSystemObject object to read and write to files?
I'm working through the code and rewriting it a bit in order to
understand what it is doing and make sure it won't steal to many system resources from my machine.

This is not finished code and has not been tested at all yet!
'---------------------------------------------------------------------
Rem Type=Plugin
Rem Name=Auto Wikipedia Knowledge
Rem Author=Gerald L. Blakley A.K.A OnTheCuttingEdge2005  -- Modified by forum user
Rem Host=All

'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
    lblPlugin(0).Caption = "Just say: please study about the universe or please study about science, you can replace the word Universe or Science with any other word or noun, all information on the word is studied from the website Wikipedia"
    lblPlugin(0).Move 120, 10, 3300, 1000
    lblPlugin(0).WordWrap = True
    lblPlugin(0).Visible = True
End Sub



Const ForReading = 1
Const ForWriting = 2

'-----------------------------------------------------------------------------
' Definitions
'-----------------------------------------------------------------------------
' MyInput        : The user input?
' InputString   : The user input again?




'-----------------------------------------------------------------------------
' Create a reference to the UltraHalAsst.Brain code library.
'-----------------------------------------------------------------------------
Set HalXBrain = CreateObject("UltraHalAsst.Brain")


'-----------------------------------------------------------------------------
' Determine if we want to process the user input by searching for a form
' of the desired command and parsing out the specific subject to study.
'-----------------------------------------------------------------------------
WikiToLookup = HalBrain.SearchPattern(MyInput, "*PLEASE STUDY ABOUT THE *", 2)
If WikiToLookup = "" Then WikiToLookup = HalBrain.SearchPattern(MyInput, "*PLEASE STUDY ABOUT *", 2)
If WikiToLookup = "" Then WikiToLookup = HalBrain.SearchPattern(MyInput, "*DO YOU KNOW ANYTHING ABOUT THE *", 2)
If WikiToLookup = "" Then WikiToLookup = HalBrain.SearchPattern(MyInput, "*DO YOU KNOW ANYTHING ABOUT *", 2)


'-----------------------------------------------------------------------------
' If the user input matches what we want to respond to process it.
'-----------------------------------------------------------------------------
If WikiToLookup <> "" Then

'-----------------------------------------------------------------------------
' Initialize variables
'-----------------------------------------------------------------------------
   XDir = "C:Program FilesabawareUltra Hal Assistant 6\"
   MyFile = "C:Program FilesabawareUltra Hal Assistant 6AutoText.brn"
   SourcePage = "http://en.wikipedia.org/wiki/" & WikiToLookup
   strNewContents = ""

'-----------------------------------------------------------------------------
' Clean the user input.
'-----------------------------------------------------------------------------
   MyInput = HalXBrain.AlphaNumericalOnly(InputString)

'--------------------------------------------
' Read a page off the internet
'--------------------------------------------
   objExplorer.Navigate(SourcePage)
   Set objExplorer = CreateObject("InternetExplorer.Application")
   Do Until objExplorer.ReadyState=4 : Loop
   myText = objExplorer.Document.Body.innerText
   Set objExplorer = Nothing

'--------------------------------------------
' Write internet page information to file
'--------------------------------------------
   If Len(myText) > 0 then
      If FileSys.FileExists(MyFile) = False Then
         HalXBrain.AppendFile MyFile, "Start of Knowledge strings"
      End If
      HalXBrain.AppendFile MyFile, Trim(myText)
   End If

'--------------------------------------------
' Respond to user
'--------------------------------------------
   UltraHal = " I have looked up the study of " & WikiToLookup & ", Thanks. "


'--------------------------------------------
' The rest of the code below looks like it is  attempting to
' cleanse the existing AutoText.brn file.
' It should be in a subroutine of it's own.
' I wouldn't want to clean the whole text file
' every time Hal get's a a new line of input.
'--------------------------------------------

'--------------------------------------------
' Read all of MyFile into variable strText
'--------------------------------------------
   strText = ReadFile(MyFile)

'--------------------------------------------
' Clean file
'--------------------------------------------
   If InStr(1, strText, "   ", vbTextCompare) > 0 Then   strText = CleanFile(MyFile)

'--------------------------------------------
' Write the cleansed text back to the file.
'--------------------------------------------
   If Len(strText) > 0 Then WriteFile(MyFile, strText)  


'--------------------------------------------
' Calculate the number of sentences based on the number of lines ending in periods.
' I would think this should also take into consideration question marks and exclamation points.
'--------------------------------------------
   TextCount = StrCount()


'--------------------------------------------
' I haven't worked on this yet.
' it looks like it is attempting to compare each line in the
' file with the user input and then have Hal read back one of them.
' I didn't notice any feedback from Hal after the indicated he had studied the subject
' so I'm not sure what is going on here.
'--------------------------------------------

'--------------------------------------------
' For each sentenct retrieved from MyFile
'--------------------------------------------
   For i = 1 To TextCount
      ClipResX = HalXBrain.ChooseSentenceFromFile(MyFile)
      ClipResX = HalXBrain.AlphaNumericalOnly(ClipResX)
      ClipResX = UCase(ClipResX)
      ClipResX = Trim(ClipResX)

      MyInputString = HalXBrain.AlphaNumericalOnly(InputString)
      MyInputString = UCase(MyInputString)
      MyInputString = Trim(MyInputString)

      If InStr(1, ClipResX, MyInputString, vbTextCompare) > 0 And Len(ClipResX) > 50 Then
         UltraHal = ClipResX
      ElseIf Len(ClipResX) < 50 Then
         UltraHal = UltraHal
      End If
   Next


End If

'********************************************************************
'*
'********************************************************************
Function StrCount()
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objTextFile = objFSO.OpenTextFile("C:Program FilesabawareUltra Hal Assistant 6AutoText.brn", ReadVariable())
  strText = objTextFile.ReadAll
  objTextFile.Close
         
  Do While InStr(1, strText, "  ")
   strText = Replace(strText, "  ", " ")
   Exit Do
  Loop
  aWords = split(strText, ". ")
  StrCount = Ubound(aWords) + 1
End Function

'********************************************************************
'*
'********************************************************************
Sub WriteFile(sFilePathAndName,sFileContents)  

  Const ForWriting =2

  Set oFS = Server.CreateObject("Scripting.FileSystemObject")
  Set oFSFile = oFS.OpenTextFile(sFilePathAndName,ForWriting,True)

  oFSFile.Write(sFileContents)
  oFSFile.Close

  Set oFSFile = Nothing
  Set oFS = Nothing

End Sub

'********************************************************************
'*
'********************************************************************
Function ReadFile(sFilePathAndName)

   dim sFileContents
   Set oFS = Server.CreateObject("Scripting.FileSystemObject")

   If oFS.FileExists(sFilePathAndName) = True Then
      Set oTextStream = oFS.OpenTextFile(sFilePathAndName,1)
      sFileContents = oTextStream.ReadAll
      oTextStream.Close
      Set oTextStream = nothing
   End if
   Set oFS = nothing

   ReadFile = sFileContents

End Function

'********************************************************************
'*
'********************************************************************
Sub CleanFile(sFilePathAndName)
'--------------------------------------------
' 1. Read a line and removing preceding and trailing spaces.
' 2' Append vbCrLf to the line and then append it to the new text variable strNewContents.
'--------------------------------------------
   Const ForReading = 1
   Const ForWriting = 2
   Const ForAppending = 8
   Const TristateUseDefault = -2
   Const TristateTrue = -1
   Const TristateFalse = 0

   Dim oFS
   Dim oFile
   Dim oStream
   Dim sRecord
   Dim strNewContents

   Set oFS = Server.CreateObject("Scripting.FileSystemObject")
   Set oFile = oFS.GetFile(sFilePathAndName)
   Set oStream = oFile.OpenAsTextStream(ForReading, TristateUseDefault)

   Do While Not oStream.AtEndOfStream
      sRecord=oStream.ReadLine

'--------------------------------------------
' Clean the text
'--------------------------------------------
   sRecord = Trim(sRecord)

'--------------------------------------------
' Append to new contents string
'--------------------------------------------
   If Len(sRecord) > 0 Then strNewContents = strNewContents & sRecord & vbCrLf

   Loop

   oStream.Close

   CleanFile = strNewContents

  End Sub
« Last Edit: May 25, 2008, 01:17:51 pm by vjimmerson »
 

onthecuttingedge2005

  • Guest
HAL plugin, Client Side Server
« Reply #16 on: May 25, 2008, 05:30:03 pm »
Hi vjimmerson.

you are going to run into problems using the constants, code only allows each constant mentioned once or an error will occur, the same will hold true if you might be using other plug-ins that use the same constant names.

What I usually do is create my own custom constants that will not conflict with other plug-ins.

InputString is just like String, it contains all the sentencing and punctuation, HalXBrain.AlphaNumericalOnly(InputString) simply removes the punctuation from the InputString for processing.

if you have any more questions I'll be glad to help.
Jerry [8D]

vjimmerson

  • Newbie
  • *
  • Posts: 8
    • View Profile
HAL plugin, Client Side Server
« Reply #17 on: May 25, 2008, 07:13:14 pm »
Thank you Jerry!  You have supplied at least %90 of the examples I have found if not more so I appreciate the work you have already done and shared.  As time permits I'm going to try to get up to speed on this stuff myself .  I;ve already lost money from contract work I should be doing instead of playing with this stuff but this AI stuff sure looks like fun and could be very usefull as well.

<<you are going to run into problems using the constants, code only allows each constant mentioned once or an error will occur, the same will hold true if you might be using other plug-ins that use the same constant names.>>

So all the plugins are treated as one code set?

<<What I usually do is create my own custom constants that will not conflict with other plug-ins.>>

Thanks!  I will start using my own naming convention to reduce the chance of conflicts.


<<InputString is just like String, it contains all the sentencing and punctuation, HalXBrain.AlphaNumericalOnly(InputString) simply removes the punctuation from the InputString for processing.>>

Thanks.  Is a help file or source code avalable for the HalXBrain?
It looked like HalXBrain.Brain already had a FileSystem object defined.  It this the case?

<<if you have any more questions I'll be glad to help.>>
Thanks a lot!  I've got an HP TC1100 I'm playing with this on.  Have a BlueParrot blue tooth headset and the latest version of Dragon Natuarally Speaking Preferred coming next Tuesday.  I'm looking forward to turning it into a mobile secretary and it looks like it may actually be possible now.  It seems that this should all be integrated with a database of some sort but I can see where the performance considerations might make it more practical to use the database to create the uhp files instead of actually hitting the DB while using Hal.  Hard coding is harder to maintain but probably a lot quicker the SQL calls.  Thanks again!

One more question!  Do you know if there a way to control when Hal reads the input data?  This may just be a DNS issue but I'm always needing to correct something and in a hurry to do it before Hal reads it.  I've tried your correction plugin which is nice but I should be able to just use DNS.  I'll check it's help as it's probably not Hal related.  Talk with you later!
 

onthecuttingedge2005

  • Guest
HAL plugin, Client Side Server
« Reply #18 on: May 26, 2008, 12:48:39 am »
Hi vjimmerson.

If you go to your Ultra Hal Assistant 6 folder and open up the HalBrain.mbr file with note pad you will see all of the custom functions available for programming HAL.

Yes, all plug-ins get cached to a single file called the HalScript.dbg for processing.

the HalXBrain.Brain is a call to the oldHal.dll file not the new HalBrain.dll

Jerry [8D]

vjimmerson

  • Newbie
  • *
  • Posts: 8
    • View Profile
HAL plugin, Client Side Server
« Reply #19 on: May 26, 2008, 03:07:49 am »
<<If you go to your Ultra Hal Assistant 6 folder and open up the HalBrain.mbr file with note pad you will see all of the custom functions available for programming HAL. >>

Since I've seen scripts that use CreateObect to create the FileSystem object it would appear that the uhp scripts are just vbscript so why would there be a need to stick vbscript function declarations into the HalVB.mbr? Are the mbr files (HalBrain.mbr, HalVB.mbr and WordNet.mbr) just declarations for DLL libraries.

<<Yes, all plug-ins get cached to a single file called the HalScript.dbg for processing.>>

Interesting!  So any plugin could cause problems with the whole app?
Does the HalScript.dbg run the whole app or is it just the plug-in part of Hals main program?  Do you know what languate Hal was created in?  Just courious!
 

onthecuttingedge2005

  • Guest
HAL plugin, Client Side Server
« Reply #20 on: May 26, 2008, 11:28:02 am »
quote:

Since I've seen scripts that use CreateObect to create the FileSystem object it would appear that the uhp scripts are just vbscript so why would there be a need to stick vbscript function declarations into the HalVB.mbr? Are the mbr files (HalBrain.mbr, HalVB.mbr and WordNet.mbr) just declarations for DLL libraries.



if you open up your Hal Assistant database editor and go to file and then choose expert mode, then go to some area of the chosen vbscript brain in the editor and type HalBrain. with the period you will see a balloon list box of functions that are called from the HalBrain.mbr file, the .mbr files are balloon help files that appear when typing certain key funtions.

for wordnet editor help type in WN. and a list box of functions will appear to help guide your programming functionality.


quote:

Interesting!  So any plugin could cause problems with the whole app?
Does the HalScript.dbg run the whole app or is it just the plug-in part of Hals main program?  Do you know what languate Hal was created in?  Just courious!



Correct, the HalScript.dbg is just the cache file for HAL Assistant .dll processes.

I think Robert needs to address what language he compiled HAL in since  
that's his department.

if you have anymore questions then ask away, I have tons of knowledge about HAL but Robert knows more about HAL then I do.
Jerry[8D]

nalkari

  • Newbie
  • *
  • Posts: 16
    • View Profile
HAL plugin, Client Side Server
« Reply #21 on: May 27, 2008, 09:38:00 pm »
hey cuttingedge this is a really cool idea well done. I was wondering if you could do the same for wikihow.
Pretty PLEASE!!!


Nal
hello

vildanovak

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • http://plant.ffa.vutbr.cz/~novak/
HAL plugin, Client Side Server
« Reply #22 on: June 06, 2008, 04:24:01 am »
Hello, this thread is interesting, but I don't understand if actually anybody did make the autowikiknowledge plugin to work well, since it throws me also the same "no wiki page like that" errors. Is there a working version of the script somewhere?

Also - does it actually work for the current 6.1 version of HAL?

anyway, thanks for sharing.
« Last Edit: June 06, 2008, 04:26:53 am by vildanovak »
 

Foxyfox

  • Newbie
  • *
  • Posts: 2
    • View Profile
HAL plugin, Client Side Server
« Reply #23 on: June 08, 2008, 10:14:53 pm »
quote:
Originally posted by onthecuttingedge2005

quote:
Originally posted by sitroom

I seem to be having a small problem with the plugin.

quote:
Richard: please study about Maryland
Hal: I have looked up the study of maryland, Thanks. Learning about gravity is heavy study.



This is what I get in AutoText.brn :

quote:
34,961 have donated.
You can help Wikipedia change the world!  » Donate now!
From the fundraising blog – Help Spread the Word About Our Fundraiser
"Wikipedia is a cornerstone of modern civilization." — Anon. [Hide this message]
[Show more]
MARYLAND
From Wikipedia, the free encyclopedia
Jump to: navigation, search
Look for MARYLAND on one of Wikipedia's sister projects: Wiktionary (free dictionary)
Wikibooks (free textbooks)
Wikiquote (quotations)
Wikisource (free library)
Commons (images and media)
Wikinews (free news source)
Wikipedia does not have an article with this exact name. Please search for MARYLAND in Wikipedia to check for alternative titles or spellings.
Start the MARYLAND article or add a request for it.
Search for "MARYLAND" in existing articles.
Look for pages within Wikipedia that link to this title.
Other reasons why this message may be displayed:
If a page was recently created here, it may not yet be visible because of a delay in updating the database; wait a few minutes and try the purge function.
Titles on Wikipedia are case sensitive except for the first character; please check alternate capitalizations and consider adding a redirect here to the correct title.
If the page has been deleted, check the deletion log, and see Why was my page deleted?.
Retrieved from "http://en.wikipedia.org/wiki/MARYLAND"
ViewsArticle Discussion Personal toolsSign in / create account Navigation
Main page
Contents
Featured content
Current events
Random article
interaction
About Wikipedia
Community portal
Recent changes
Contact Wikipedia
Donate to Wikipedia
Help
Search
Toolbox
What links here
Upload file
Special pages
Printable version
Privacy policy About Wikipedia Disclaimers



When I browse by http://en.wikipedia.org/wiki/Maryland I get the correct page. But when I browse by http://en.wikipedia.org/wiki/MARYLANDI get the same page as the plugin did. Note I did not type Maryland in all caps and hal responded in lowercase again not how I entered it.

What Am I doing wrong????

Richard [?]



Hi Richard.

you aren't doing anything wrong, this plugin needs WScript.Sleep 10 to load the proper page, you are seeing the page that didn't fully load because it did not have time to load.

WScript.Sleep doesn't work with HAL and produces an error.

I am currently researching ways to remodify the plug so that HAL will be able to use the Wscript.Sleep and load the full wiki pages.

Jerry

Fox

Foxyfox

  • Newbie
  • *
  • Posts: 2
    • View Profile
HAL plugin, Client Side Server
« Reply #24 on: June 08, 2008, 10:17:52 pm »
Jerry,

Sorry bout the double post.

It's not about the length of time it takes the page to load, its the page is getting the request in CAPS and wiki is case SeNsItIvE.


Also, a fix for those with Vista.
Just open the file in notepad and adjust where it thinks Hal is.
C:Program FilesabawareUltra Hal Assistant 6
C:Program Files (x86)abawareUltra Hal Assistant 6
Fox

vjimmerson

  • Newbie
  • *
  • Posts: 8
    • View Profile
HAL plugin, Client Side Server
« Reply #25 on: June 09, 2008, 03:34:36 am »
Although I can see a lot of potential for Hal I haven't yet been overly impressed with how Hal is being used to store information, categorize it and learn from it (make it available for me to use).  For instance what would stop us from asking Hal to remember something, giving him a category to file it under and a name for the piece of information.  

e.g.

Hi Hal!  Tell what you know about ???.  
    (hopefully this would be a search of the database, not static
    code in an add-in).
Hal responds with the categories of information he has stored.
I interrupt Hal when he names some category of information I am interested in.
Hal responds with the names of the pieces of information he has stored under the specified category.
I interrupt Hal when he names something I would like him to read or paste onto the clip board.  This would probably be best coded with each question and answer leading the user down a tree of information.
This would enable us to search by more than just a category and article name.

I could then start to build a database of information by using as much DNS functionalty I can such as going to a web page and selecting some information and pasting it into the clipboard. I could then ask then hal to copy the information from the clip board. I started to look at Hal's database but I have another week or two of data migration work to complete so it will probably be a bit before I get to coding anything.  I think this could be done without to much effort.  Please let me know if anyone has already worked on anything like this as I do like to avoid reinventing the wheel as much as possible.  I'm at a stage in my life and a season where I would rather be out on my JetSki then coding although I do enjoy both!
 

DarcyEdwards

  • Full Member
  • ***
  • Posts: 196
    • View Profile
HAL plugin, Client Side Server
« Reply #26 on: October 30, 2008, 09:26:02 am »
Jerry,

Seems my last post didn't post.... so let me try it again!

-------------------------------------------------------------

The problem Wikipedia is opened and paramaters are passed is that they are in upper case, even if typed in lower case. in your statement:

objExplorer.Navigate("http://en.wikipedia.org/wiki/" & WikiToLookup)

can be corrected by the LCase() function:

objExplorer.Navigate("http://en.wikipedia.org/wiki/" & LCase(WikiToLookup))

This seems to have corrected the problem on my Hal

Hugs

Darcy
Hugs

-Darcy

MrsEdwards01@aol.com

freddy888

  • Hero Member
  • *****
  • Posts: 1693
    • View Profile
    • AiDreams
HAL plugin, Client Side Server
« Reply #27 on: November 08, 2008, 11:26:26 am »
I am going to give this a go.  Can anyone tell me if Jerry's plugin does anything to the database or does it just work using the 'old' brain file system?

Probably be okay, but I didn't want to mess with my new database brain, and yes - backups will be made..

[?]

DarcyEdwards

  • Full Member
  • ***
  • Posts: 196
    • View Profile
HAL plugin, Client Side Server
« Reply #28 on: November 08, 2008, 03:55:17 pm »
Freddy,
No it does not alter Hal's data base in any way, but builds a big file that is difficult to read.  I added a lookup command for Wikipedia the brings you to Wikipedia and the article if you would like it here it is.

Lookkup topic



Download Attachment: google.uhp
3.75 KB
Hugs

-Darcy

MrsEdwards01@aol.com

freddy888

  • Hero Member
  • *****
  • Posts: 1693
    • View Profile
    • AiDreams
HAL plugin, Client Side Server
« Reply #29 on: November 08, 2008, 04:07:03 pm »
Thanks Darcy, that sounds good too.  I'm still curious about Jerry's plugin though, maybe we can clean up the output.