Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AskMerlin, your AI expert system guru oracle advisor

2 views
Skip to first unread message

Ron Stephens

unread,
Oct 28, 2001, 2:57:25 PM10/28/01
to
Ok, so this is what happens when Guido promotes CP4E. You get newbie,
duffer, weekend hackers doing whatever turns them on.

I make no claims that this code is anything more than a hack. Please
excuse it, but if anyone is interested, you can link to my programs
below. Thanks to the inventors of NLQ and multiChoiceGuesser! I hope you
can forgive me for hacking your code ;-))

#!/usr/bin/python
# AskMerlin is a weekend hack I did by putting together a short program
called NLQ,
# or natural language query, which can be found online at
http://gurno.com/adam/nlq/#download
# NLQ is a Class to take an inputted query and output 1. Keywords and 2.
also to categorize
# the type of question being asked. I am primarily interested in using
the Keywords
# extracted form a query by NLQ. I shamelessly modified NLQ to add many
more
# IGNORE_WORDS and otherwise spruce it up.
# Next, I utilized the multiChoise Guesser script that some nice person
posted
# on the newsgroup a couple weeks ago. This uses urllib to go out to the
web
# and judge teh appropriateness of a given answer by how many hits it
gets on Google
# when coupled with the original question in a Google search.
# My main contribution, such as it was, was simply to enable the program
to create
# choices in order to choose a most appropriate answer. This is done by
using
# NLQ to pick out Keywords form teh HTML page returned by Google in its
search
# on the question. This version, AskMerlin, currently takes a long time
# to come to an answer because it must do many web searches/ I have also
a simpler version
# called aNoDivisorAskMerlin that comes to a much quicker decision, btu
is not as good in the
# appropriateness of its answer's. In either case, you must wait
patiently while
# merlin considers his options...dependign on speed of your internet
connection.
# On my cable modem at home, AsKMerlin takes about three minutes.
# I am hoping that someone or other might give me ideas on how to
improve the
# intelligence behind Merlin's deliberations. This version is just a
hack to see if it works
# in principle. I have other ideas to increase "intelligence" but I need
more.
# Currently, Merlin is very low IQ, but he has potential for the future.

# Anyway, Merlin can already answer just about any question.
# Someday, perhaps he will even answer correctly or at least with wisdom

# ;-)))))))))))))

http://www.awaretek.com/AskMerlin.py

http://www.awaretek.com/aNoDivisorAskMerlin.py

Ron Stephens

unread,
Oct 28, 2001, 6:19:52 PM10/28/01
to
Ok i want to ask a simple question that I can not figure out yet. (Even
though I used and then modified the the line of code below:

x = (self._getGoogleHits(self.question + ' ' + reply))
y = (self._getGoogleHits(reply))

I am not sure what the significance of the (self.question + ' ' +reply) is.
Specifically, what is the significance of the two quotation marks in the
middle? Doe sit just ad a space between the two strings (question and
reply), or does it do something else? I tried the program without hte two
quotes and it didn't seem to change the operation noticeably.

OK, I feel dumb but I would still like to know the answer. Anyone?

Ron Stephens
http://www.awaretek.com

John Roth

unread,
Oct 28, 2001, 9:48:43 PM10/28/01
to

"Ron Stephens" <rds...@earthlink.net> wrote in message
news:3BDC9411...@earthlink.net...

> Ok i want to ask a simple question that I can not figure out yet.
(Even
> though I used and then modified the the line of code below:
>
> x = (self._getGoogleHits(self.question + ' ' + reply))
> y = (self._getGoogleHits(reply))
>
> I am not sure what the significance of the (self.question + ' '
+reply) is.
> Specifically, what is the significance of the two quotation marks in
the
> middle? Doe sit just ad a space between the two strings (question and
> reply), or does it do something else? I tried the program without hte
two
> quotes and it didn't seem to change the operation noticeably.


As you assumed, it's a string concatination, and the two quotes
are a one character string.

John Roth

> Ron Stephens
> http://www.awaretek.com
>
>


Peter Hansen

unread,
Oct 29, 2001, 12:58:32 AM10/29/01
to
Ron Stephens wrote:
>
> x = (self._getGoogleHits(self.question + ' ' + reply))
> y = (self._getGoogleHits(reply))
>
> I am not sure what the significance of the (self.question + ' ' +reply) is.
> Specifically, what is the significance of the two quotation marks in the
> middle? Doe sit just ad a space between the two strings (question and
> reply), or does it do something else?

Python is exceptionally friendly about this kind of question
when you use the interactive prompt. It's worth spending a
moment getting used to it:

>>> someString = 'this is a test'
>>> reply = 'and a reply'
>>> someString + reply
'this is a testand a reply'
>>> someString + ' ' + reply
'this is a test and a reply'
>>> '%s %s' % (someString, reply)
'this is a test and a reply'

Enjoy! :)

--
----------------------
Peter Hansen, P.Eng.
pe...@engcorp.com

maxm

unread,
Oct 29, 2001, 1:17:03 PM10/29/01
to
"Ron Stephens" <rds...@earthlink.net> wrote in message
news:3BDC9411...@earthlink.net...

> x = (self._getGoogleHits(self.question + ' ' + reply))


> y = (self._getGoogleHits(reply))
>
> I am not sure what the significance of the (self.question + ' ' +reply)
is.
> Specifically, what is the significance of the two quotation marks in the
> middle? Doe sit just ad a space between the two strings (question and
> reply), or does it do something else? I tried the program without hte two
> quotes and it didn't seem to change the operation noticeably.

The program works by sending questions and possible answers to google at the
same time. Then it counts the hits for each combination.

"Who wrote linux"

"Linus Torvalds"
"Bill Gates"
"Steve Jobs"

So question + ' ' + reply:

"Who wrote linux Linus Torvalds" (49,800 hits)
"Who wrote linux Bill Gates" (23,900 hits)
"Who wrote linux Steve Jobs" (18,000 hits)

and question + reply:

"Who wrote linuxLinus Torvalds" (did not match any documents)
"Who wrote linuxBill Gates" (did not match any documents)
"Who wrote linuxSteve Jobs" (did not match any documents)

These searchstrings are not as accurate as the first, but as the program is
all about statistical probabilities, you can get sensible reples though your
input data is not as good as it can be.

In this case it is no god though, and multiChoiceGuesser would just return
index 0 "Linus Torvalds". Purely by luck.

regards Max M


0 new messages