1
Ultra Hal 7.0 / what to do about hyphens , other characters ?
« on: January 03, 2004, 06:04:17 pm »
Okay, I did enough to answer my own original question. By editting the mywebhal.uhp script I was able to get a web-search to focus on my literal string rather than being subject to the HalBrain.ExtractKeywords(UserSentence) processing that removed my hyphen and kind of messes around with the search string.
First off, you do need to set up a webhal account with Zabaware which is how you specify your search engine choice like "google". Originally, I set it up and requested that Hal
> find t-vec
where "t-vec" is the name of the company that I work for. Before modification, the GetResponse() function in mywebhal.uhp did the following
Keywords = Replace(Trim(HalBrain.AlphaNumericalOnly(HalBrain.ExtractKeywords(UserSentence))), " ", "+")
GetResponse = "I will help you research this topic on the Internet.<RUN>http://www.zabaware.com/mywebhal/index.html?username=" & UserName & "&action=search&keywords=" & Keywords & "&char=" & FacePrvw & "</RUN>"
You can see that the "-" character probably gets removed by the HalBrain.AlphaNumericalOnly() function. But since "t-vec" is a proper name the search string "tvec" is no good at all. So I modified the script as follows
quote_position = InStr(1, UserSentence, Chr(34), 1)
If quote_position > 0 Then
Keywords = Right(UserSentence, len(UserSentence) + quote_position)
Else
Set HalBrain = CreateObject("UltraHalAsst.Brain")
Keywords = Replace(Trim(HalBrain.AlphaNumericalOnly(HalBrain.ExtractKeywords(UserSentence))), " ", "+")
End If
GetResponse = "I will help you research this topic on the Internet.<RUN>http://www.zabaware.com/mywebhal/index.html?username=" & UserName & "&action=search&keywords=" & Keywords & "&char=" & FacePrvw & "</RUN>"
I set it up so that if I issued the hal command
> find "t-vec"
the the exact string "t-vec" gets used as the bases of Keywords which gets submitted to google. If I don't use quotes around the search target, the original processing gets used.
I also made a few other changes to the script to make it more efficient, such as using ElseIF statements rather then If statements where the cases are mutually exclusive. But what I need to figure out now is how to pass quote characters as part of the google search string (Keywords). Right now, they are apparently being stripped out by the
<RUN>http://www.zabaware.com/mywebhal/index.html?username=" & UserName & "&action=search&keywords=" & Keywords & "&char=" & FacePrvw & "</RUN>
command. Even if I explicitly add them right before this command by doing something like
Keywords = Chr(34) & Keywords & Chr(34)
Does anyone know how I might be able to accomplish that. Quote characters tell google to match the exact string between the quote characters, rather than treat them as independent search words.
I also tried using the URL encoding approach "%23" (an escaped hexidecimal code for the " character) but it appears that the processing down by the Hal command <RUN>url spec</RUN> is filtering out the " characters.
Web-search functionality could be greatly enhanced by providing a way for un-adulterated search strings to be passed directly to a search engine without.
First off, you do need to set up a webhal account with Zabaware which is how you specify your search engine choice like "google". Originally, I set it up and requested that Hal
> find t-vec
where "t-vec" is the name of the company that I work for. Before modification, the GetResponse() function in mywebhal.uhp did the following
Keywords = Replace(Trim(HalBrain.AlphaNumericalOnly(HalBrain.ExtractKeywords(UserSentence))), " ", "+")
GetResponse = "I will help you research this topic on the Internet.<RUN>http://www.zabaware.com/mywebhal/index.html?username=" & UserName & "&action=search&keywords=" & Keywords & "&char=" & FacePrvw & "</RUN>"
You can see that the "-" character probably gets removed by the HalBrain.AlphaNumericalOnly() function. But since "t-vec" is a proper name the search string "tvec" is no good at all. So I modified the script as follows
quote_position = InStr(1, UserSentence, Chr(34), 1)
If quote_position > 0 Then
Keywords = Right(UserSentence, len(UserSentence) + quote_position)
Else
Set HalBrain = CreateObject("UltraHalAsst.Brain")
Keywords = Replace(Trim(HalBrain.AlphaNumericalOnly(HalBrain.ExtractKeywords(UserSentence))), " ", "+")
End If
GetResponse = "I will help you research this topic on the Internet.<RUN>http://www.zabaware.com/mywebhal/index.html?username=" & UserName & "&action=search&keywords=" & Keywords & "&char=" & FacePrvw & "</RUN>"
I set it up so that if I issued the hal command
> find "t-vec"
the the exact string "t-vec" gets used as the bases of Keywords which gets submitted to google. If I don't use quotes around the search target, the original processing gets used.
I also made a few other changes to the script to make it more efficient, such as using ElseIF statements rather then If statements where the cases are mutually exclusive. But what I need to figure out now is how to pass quote characters as part of the google search string (Keywords). Right now, they are apparently being stripped out by the
<RUN>http://www.zabaware.com/mywebhal/index.html?username=" & UserName & "&action=search&keywords=" & Keywords & "&char=" & FacePrvw & "</RUN>
command. Even if I explicitly add them right before this command by doing something like
Keywords = Chr(34) & Keywords & Chr(34)
Does anyone know how I might be able to accomplish that. Quote characters tell google to match the exact string between the quote characters, rather than treat them as independent search words.
I also tried using the URL encoding approach "%23" (an escaped hexidecimal code for the " character) but it appears that the processing down by the Hal command <RUN>url spec</RUN> is filtering out the " characters.
Web-search functionality could be greatly enhanced by providing a way for un-adulterated search strings to be passed directly to a search engine without.