logo       

[SPOILER] Solution to Perl 'Expert' Quiz-of-the-week #18: msg#00037

Subject: [SPOILER] Solution to Perl 'Expert' Quiz-of-the-week #18
Well, this is my first post to this list and english is not my native
language, so my apologies if you don't understand me or I don't follow
the rules.

I have used a big hash called %brain where the computer remembered what
was said in the way: $brain{PLURAL_NOUN-RELATION} = POINTER_TO_ARRAY. So
if you say "All mammals are hairy animals", the remember function would
store: $brain{mammals-all}=["hairy animals"];  It also infered the
reverse based on what Ronald J Kimball said:

"All X are Y" implies "Some X are Y" and "Some Y are X".
"Some X are Y" implies "Some Y are X".
"No X are Y" implies "No Y are X".
"Some X are not Y" doesn't imply anything else.

The most important part is the look_for. It goes through the elements of
the second argument looking for the first one. If it doesn't find it, it
calls itself recursively. So if the computer knows: 
All mammals are hairy animals
All dogs are mammals
All beagles are dogs

And the question is "Are all beagles hairy animals?", then look_for
would be called with the arguments: "beagles", "hairy animals". The
computer doesn't know a direct relation so it would look inside each
element directly related to hairy animals: "All mammals are hairy
animals". The same happen with mammals and dogs, and finally it finds
that all beagles are hairy animals. How the relation is guessed is
explained in the code. This function is also used to find contradictions
and already known things, before remembering something. To describe, the
program just looks for every noun it knows starting from the one to be
described. If it finds a relation, it prints it.

The program works more or less, but it has some important flaws. First,
to separate the nouns in the question, it stops when the first noun is
in the list of known_nouns. It doesn't consider other posibilities.
Also, there's no way to upgrade the information. For example, if you
say:
> Some hairy animals are mammals.
OK.
> All mammals are hairy animals.
Sorry, that contradicts what I already know.

Because the program infers that some mammals are hairy animals, and
"some" ne "all". This seems easy to change, but consider:
> All dogs are mammals.
OK.
> All cats are mammals.
OK.
> No dogs are cats.
OK.
> All mammals are dogs.

Now, when you know that no dogs are cats, "All mammals are dogs" is a
contradiction. But if you knew nothing about the relation between cats
and dogs, then it could be possible. Although I thought it was easy to
make this upgrade path from "some" to "all", I haven't found anything
that correctly does so.
-- 

Attachment: qotw18.pl
Description: Text Data

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe