dupa

Author Topic: WordNet with Images - New For Hal 6  (Read 12896 times)

mikmoth

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • http://karigirl.com
WordNet with Images - New For Hal 6
« on: February 19, 2005, 10:22:30 pm »
This is the new Wordnet with Images for Hal 6. I am also attaching the Perl script that makes all this possible. In essence what it does is stream images from Yahoo Image Search.

How to install:

Fire up the BrainEditor. Make sure you that Hal is not running. Find the Wordnet "Dictionary Function". Copy/Paste this script right under it. Your done! Run Hal.

Now, every time you type in "Show me a cat." it will pop up an image of a cat plus give you the definition. Also looks up images that aren't in the dictionary. "Show me Captain Kirk." A picture of Kirk appears.

You can type within these parameters:

Show me WORD. ie: Show me Einstein.
Show me a WORD. ie: Show me a dog.
Show me an WORD. ie: Show me an apple.

With a little know how you can change "Show me" to whatever you want.

You can also specify if you want the window to close automatically and for how many seconds it should be visible.  Just change the "secs=" to the number you want. A value of zero (secs=0) makes the window stay up forever or until you close it manually.

Please let me know how I can improve this script or if you find any bugs. Again, the Perl script is attached in case you want to run in off your own website/server. Just don't forget to change its permissions to 755. Which means EXECUTABLE. You also need the cgi-lib.pl script which I am including. Both need to be in your cgi-bin and set to 755.

Have fun!


Code: [Select]
   'RESPOND: LOOK UP IMAGE
If InStr(1, UserSentence, "SHOW YOU ", 1) > 0  Then
lookup = Replace(UserSentence, "SHOW YOU ", "", 1, -1, vbTextCompare)
If InStr(1,lookup,".", 1) > 0 Then lookup = Replace(lookup,".","",1,-1, vbTextCompare)
If InStr(1,lookup," A ", 1) > 0 Then lookup = Replace(lookup," A ","",1,-1, vbTextCompare)
If InStr(1,lookup," AN ", 1) > 0 Then lookup = Replace(lookup," AN ","",1,-1, vbTextCompare)
If WN.LookUpWord(lookup) = False Then
GetResponse = "I have no definition but I will try to find an image."
End If
If WN.LookupWord(lookup) = True Then
GetResponse = GetResponse & lookup & ": " & WN.GetDefinition(WN.GuessPartOfSpeech, 1, "D") & ". " & WN.GetDefinition(WN.GuessPartOfSpeech, 1, "S") & ". " & WN.GetDefinition(WN.GuessPartOfSpeech, 1, "E") & "." & vbCrLf & "<EXCLUSIVE>"
End If
Set IE = CreateObject("InternetExplorer.Application")
cdc = "http://www.karigirl.com/cgi-bin/popup.pl?term=" + lookup + "&secs=5" 'Secs until window closes. 0=never
IE.Navigate cdc
IE.AddressBar = False
IE.menubar = False
IE.ToolBar = False
IE.StatusBar = False
IE.width = 450
IE.height = 450
IE.resizable = False
IE.visible = True
End If


This is the Perl Script. Download only if you know what you are doing. Otherwise, just copy and paste the above text into your Brain.

Download Attachment: popup1.zip
6.62 KB
« Last Edit: June 21, 2006, 12:53:43 pm by mikmoth »
 

onthecuttingedge2005

  • Guest
WordNet with Images - New For Hal 6
« Reply #1 on: February 20, 2005, 01:56:20 am »
quote:
Originally posted by mikmoth

I have a new toy! This script enhances Wordnet by displaying an image of the word that is being looked up. So if you type "What is cat?" a picture of a cat will appear. It can even do words that *aren't* in the dictionary like "What is dirty dog?" The script will do its best to match the image with the words.

How it works: Basically it searches the internet for the word or words and retrieves the image. No two lookups of the same word are the same and the image is usually dead-on. Images are small and download in a few seconds. The image pops up and disappears.
 
All you have to do is paste this code into your brain (follow directions):

'*** WORDNET IMAGES ***
Set IE = CreateObject("InternetExplorer.Application")
cdc = "http://www.glice3d.com/cgi-bin/popup.pl?term=" + WordToLookup
IE.Navigate cdc
IE.AddressBar = False
IE.menubar = False
IE.ToolBar = False
IE.StatusBar = False
IE.width = 300
IE.height = 300
IE.resizable = False
IE.visible = True
'*** END WORDNET IMAGES ***

Where you place this script is VERY important. Find the end of Wordnet Dictionary function. You'll see 2 End Ifs at the end of the function:

          *PLACE SCRIPT HERE*
    End If
End If
*PLACE SECOND SCRIPT HERE*

If you want to let Hal look up words outside the dictionary paste this script after the last End If.

*** NON-WORDNET IMAGES ***
If WN.LookUpWord(WordToLookUp) = False Then
GetResponse = "No description is availabe but here is an image."
Set IE = CreateObject("InternetExplorer.Application")
cdc = "http://www.glice3d.com/cgi-bin/popup.pl?term=" + WordToLookup
IE.Navigate cdc
IE.AddressBar = False
IE.menubar = False
IE.ToolBar = False
IE.StatusBar = False
IE.width = 300
IE.height = 300
IE.resizable = False
IE.visible = True
End If
'*** END NON-WORDNET IMAGES ***


Not too complicated eh?

The Perl script which makes all this possible is currently being run on my server. If anyone is interested in looking inside, let me know. I am planning a new script based on Hal and user conversation. Have fun! And whatever you do dont type "What is digusting?" ;^)

Mik



Very cool.
But I wanted to point out something over looked possibly.
Talk to your AIM bot with that script using AIM and you might see that Users on AIM may flood your computer with pictures while talking with your bot.
Do you think that we can pop up those pics on a User's computer instead using AIM?
I've seen code that allows a website to be placed into an IM instead of a hyperlink.
I like it though, Really nice work.
Jerry.
« Last Edit: February 20, 2005, 02:00:29 am by onthecuttingedge2005 »

Rett1950

  • Newbie
  • *
  • Posts: 3
    • View Profile
WordNet with Images - New For Hal 6
« Reply #2 on: February 20, 2005, 07:13:45 pm »
This is very very cool mikmoth!

This is my first post and I'm just starting with Hal but had no problem following your instructions.

ME: "What is a capuchin monkey?"
HAL: "I have no definition but here is an image."

"The image was indeed of a capuchin monkey!

Thank you.
 

mikmoth

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • http://karigirl.com
WordNet with Images - New For Hal 6
« Reply #3 on: February 20, 2005, 09:04:08 pm »
capuchin monkey lol
 
I took your example and looked up capuchin monkey. I was disappointed that the script could only find 2 matching images. I've reworked the Perl program and now the search is more expansive. Instead of choosing from 2 "capuchin monkeys" it can now choose from over 20. All other word lookups have of course also been expanded.
 
You guys dont have to do anything so dont worry. Just know your image searches are now better.
 
Mik
« Last Edit: February 20, 2005, 09:13:24 pm by mikmoth »
 

Rett1950

  • Newbie
  • *
  • Posts: 3
    • View Profile
WordNet with Images - New For Hal 6
« Reply #4 on: February 20, 2005, 09:56:44 pm »
One of the things that I noticed with your non-word net images is that it always popped up a window and I moved it up one if statement and now it only pops up at the appropriate time.

I learned basic many, many years ago and have never worked with Visual Basic.

Thanks for expanding the world search.

Rett
 

Calipsy

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • http://www.cyber-minds.net
WordNet with Images - New For Hal 6
« Reply #5 on: March 22, 2005, 09:41:01 pm »
great script. I just followed the instructions and it was a snap. Andrey look up words for me and brings images. that's cool!

spydaz

  • Hero Member
  • *****
  • Posts: 670
    • View Profile
    • http://www.spydazweb.co.uk/
WordNet with Images - New For Hal 6
« Reply #6 on: March 24, 2005, 06:31:08 pm »
love it to death bruv

spydaz

  • Hero Member
  • *****
  • Posts: 670
    • View Profile
    • http://www.spydazweb.co.uk/
WordNet with Images - New For Hal 6
« Reply #7 on: March 24, 2005, 06:45:33 pm »
now to catch that image and save it in the default brain folder for offline reference.. hmm.. otherwise an annoying window can keep popping up when your offline.  ...

mikmoth

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • http://karigirl.com
WordNet with Images - New For Hal 6
« Reply #8 on: March 25, 2005, 08:33:01 am »
Whoa...! Thanks for the positive feedback! It really is cool.
 
Some of you may have noticed some downtime with the Perl script (server hard drive went down) but all should be well now.
 
For those who don't know what I'm talking about... the script which you are pasting into your brain is actually calling another script being run on my server which then looks up the image and sends it back to your computer. Its a classic example of different languages working together... VBScript, Perl, XML, HTML, and even some Java.
 
Also (I got an email) the script is not intended to look up porn. It will block these type of images. I know... but for all of you with kids its pretty safe.
 
Besides that I don't really know of any issues except, like Spydaz said, you have to be online to use it. I'm real happy you guys are enjoying it!
 
Peace.

Mik  
 
« Last Edit: March 25, 2005, 09:08:00 am by mikmoth »
 

spydaz

  • Hero Member
  • *****
  • Posts: 670
    • View Profile
    • http://www.spydazweb.co.uk/
WordNet with Images - New For Hal 6
« Reply #9 on: March 25, 2005, 03:03:25 pm »
I WOULD LIKE TO GET A COPY OF THE PERL SCRIPT OR THE SAME THING IN A VISUAL BASIC FUNCTION

Holllywood

  • Sr. Member
  • ****
  • Posts: 357
    • View Profile
WordNet with Images - New For Hal 6
« Reply #10 on: March 30, 2005, 04:00:49 pm »
I pasted the mod.Brn. in everything fine, no problem with that. I asked about the monkey, I got a great explaination about monkies,but no pop-ups. Am I missing some software? I am using the full ver. of Hal with all the plugins I can think of to play with. Besides intelligence, "Am I missing something"?

Still Trying,Still Listening,Still Learning.
Hollywood

heather valentine

  • Full Member
  • ***
  • Posts: 198
    • View Profile
WordNet with Images - New For Hal 6
« Reply #11 on: June 18, 2005, 11:32:04 am »
mikmoth

Hi [8D]

i really love the script
since im using voice alot i wanted to make some changes
so i had added a line like this

If WordToLookup = "" Then WordToLookup = HalBrain.SearchPattern(UserSentence, "WHO IS *", 1)

2 more questions
if id like to see more then one picture for example maybe 5 pics
lopoing from one to another like for example

1.say loading images
10 for x = 1 to 5 : next x
goto10

on the subject how woud that be asccomplished in the line without repeatng what is
go
also is there a way i can add a wav file effect for when the results of my search window pops up?



« Last Edit: June 18, 2005, 12:09:05 pm by heather valentine »
 

mikmoth

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • http://karigirl.com
WordNet with Images - New For Hal 6
« Reply #12 on: June 22, 2005, 09:13:57 pm »
Hey Hollywood,

Not sure if I understood you. The "mod" brain download is a brain and you dont have to paste it. Besides that be sure to upgrade to Internet Explorer 6 or 7. And double check your code. Sometimes long lines can wordwrap and mess everything up.


Hey Heather,

That would require some programming server side. I'll look into it. I like the idea and as soon as I get some time here I'll make this slideshow script. I'm not sure about the wavs.

Have you ever tried asking Hal really strange questions to see what image you get?

I tried these:

What is my destiny?
What is dirty coconut?
What is the secret of satan?
 
You get some really interesting things! Some of these things can get really spooky.
 
Thinking of a new version (a new brain) that uses images to communicate instead of words. That would be a trip. With .wavs if possible.

Mik
« Last Edit: June 26, 2005, 05:23:21 am by mikmoth »
 

spydaz

  • Hero Member
  • *****
  • Posts: 670
    • View Profile
    • http://www.spydazweb.co.uk/
WordNet with Images - New For Hal 6
« Reply #13 on: June 11, 2006, 06:16:34 am »
what happen to this popup script???

is there a way to use GOOGLE search for images in stead of glice3d ?

if so
cdc = "http://www.google.com/cgi-bin/popup.pl?term=" + WordToLookup

What is the Search string ?

the above does not work ....

mikmoth

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • http://karigirl.com
WordNet with Images - New For Hal 6
« Reply #14 on: June 20, 2006, 04:05:03 pm »
Wow, been a long time since I wrote this. I wrote it for Hal5 and I have since lost the script plus taken my site down.

Anyone with a little programming skills can make this work. Basically, its a Perl script that looks up a word in Google Image Search. The resulting thumbnails are then extracted from the page and it picks a random image from the images listed.

If I recall the script wasn't even 20 lines long.