The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. December 04, 2008, 11:58:46 PM

Login with username, password and session length


Pages: [1] 2
  Print  
Author Topic: Artificial Intelligence as we know it today  (Read 747 times)
jammaster82
Expert
****
Offline Offline

Posts: 297

bloody hacker


View Profile WWW
« on: September 28, 2008, 04:11:29 PM »

AHA AHAHAHAH  thought y'all might appreciate this last
link that giggle suggested i read... guess were an idiocratic
thought away from ELIZA still hahahaha



* LOL.PNG (51.71 KB, 1006x768 - viewed 110 times.)
Logged

Of course Big Brother exists, he is the embodiment of the party..... Does he exist in the same way I exist?....... You, do not exist.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 5229


:sniffle: Humor was so much easier before.


View Profile
« Reply #1 on: September 28, 2008, 04:33:33 PM »

LOL nice find JM. It's a peculiar world.
Logged

If I can't be Mr. Root then I don't want to play.
nutballs
Administrator
Lifer
*****
Online Online

Posts: 3453


View Profile
« Reply #2 on: September 28, 2008, 05:36:52 PM »

lol. thats like my traffic logs. I get the strangest stuff on pages that shouldnt match it. Yes, they have a LONG way to go it seems.

Eliza is a girls name though. obviously someone bought it for peeing.... personally Id have gone for boobs.
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 5229


:sniffle: Humor was so much easier before.


View Profile
« Reply #3 on: September 28, 2008, 06:19:57 PM »

Hmm. Well, on reflection, anyone looking for Eliza (in this context) would clearly be an uberdweeb.
Ergo, they may in fact, very well NOT know how a girl pees.

Makes much more sense now.
Logged

If I can't be Mr. Root then I don't want to play.
nutballs
Administrator
Lifer
*****
Online Online

Posts: 3453


View Profile
« Reply #4 on: September 28, 2008, 06:53:27 PM »

lol good point
Logged
jammaster82
Expert
****
Offline Offline

Posts: 297

bloody hacker


View Profile WWW
« Reply #5 on: October 06, 2008, 10:44:44 AM »

Actually it looks like N.A.S.A. may have its hands
on a program to diagnose and treat depression... ROFLMAO

Eliza 2008?  ahahaha i cant believe this is serious :

http://dsc.discovery.com/news/2008/10/06/depressed-astronaut.html
Logged

Of course Big Brother exists, he is the embodiment of the party..... Does he exist in the same way I exist?....... You, do not exist.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 5229


:sniffle: Humor was so much easier before.


View Profile
« Reply #6 on: October 06, 2008, 11:13:11 AM »

... right up to the point it says, "I'm sorry Dave, I can't do that."
Logged

If I can't be Mr. Root then I don't want to play.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 5229


:sniffle: Humor was so much easier before.


View Profile
« Reply #7 on: October 06, 2008, 11:20:58 AM »

JM - Here's an Eliza routine I just found, you might find it interesting. On quick review it looks somewhat clever, but could use some efficienciafying. Also, the text method it's using is bad - if this was production, that should be parsed into an array and kept in an APC cache so that lookups would be really fast.

Have fun!

/p

eliza.php
Code:
<?
#####################################################
# eliza.php- Final Project: Eliza program written in PHP
#
# The purpose of this program is to mimick the
# infamous Eliza program that was created some
# time ago.
#
# Note: I am not especially good with regular
# expressions at the moment, thus much of this code
# could most likely have been slimmed down.  This is
# also the reason I don't have parts of strings the
# user types stored in a variable and print them out
# when responding to the user (for ex: User: "I have
# a cat".... Eliza: "Oh you have a cat? That's nice.")
# I will be getting a regular expression book for
# X-Mas, however =)
#
# ©2001 Wayne Eggert
#-----------------------------------------------------
# DISCLAIMER: THIS CODE MAY NOT BE MODIFIED IN ANY MANNER
# WITHOUT MY CONSENT.  IT SHOULD BE USED FOR EDUCATIONAL
# PURPOSES ONLY.  LEARN, BUT DO NOT STEAL -- MEANING
# DO NOT COPY CODE VERBATIM JUST TO PASS A CLASS IF YOU
# EVER HAVE A SIMILAR PROJECT, ETC.  IT WILL BE WORTH
# YOUR WHILE TO PUT SOME THOUGHT INTO THE TASK AT HAND
# AND COME UP WITH YOUR OWN SOLUTION.  THAT'S ALL I'M
# GOING TO SAY -- OTHERWISE GOD HELP YOU WHEN YOU ENTER
# INTO THE REAL WORLD WITH THOSE HABITS.
######################################################
?>

<HTML>
<HEAD><TITLE>PHPLiza</TITLE></HEAD>
<BODY>
<?
// setup initial variables and values
$kwarray = array();
$vararray = array();
$resparray = array();
$priarray = array();
$wordarray = array();
$kwcount=0; $varcount=0; $respcount=0; $syncount=0;
mt_srand ((double) microtime() * 1000000);

// load knowledge file
$lines_array = file("knowledge.txt");

$count = count($lines_array);

// This for loop goes through the entire knowledge file and places
// the elements into arrays.  This later allows us to pull the information
// (ie. key words, variances on the keywords, and responses) out of the
// arrays.
for ($x=0;$x<$count;$x++){
$lines_array[$x] = trim($lines_array[$x]);
$lines_array[$x] = ereg_replace("[\]","",$lines_array[$x]);
    if (strstr($lines_array[$x],"key:")){
eregi("key: (.*)",$lines_array[$x],$kw);
$kwarray[$kwcount] = strtoupper($kw[1]);
$currentkw = $kwcount;
$kwcount++;
$varcount=0; // reset varcount to null
$respcount=0; // reset respcount to null
$pricount=0; // reset pricount to null
    }else if (strstr($lines_array[$x],"var:")){
        eregi("var: (.*)",$lines_array[$x],$variance);
$vararray[$currentkw][$varcount] = strtoupper($variance[1]);
$varcurrent=$varcount;
$varcount++;
$respcount=0;
    }else if (strstr($lines_array[$x],"pri:")){
eregi("pri: (.*)",$lines_array[$x],$priority);
$priarray[$currentkw] = $priority[1];
    }else if (strstr($lines_array[$x],"resp:")){
        eregi("resp: (.*)",$lines_array[$x],$response);
$resparray[$currentkw][$varcurrent][$respcount] = $response[1];
$respcount++;
    }else if (strstr($lines_array[$x],"syn:")){
eregi("syn: (.*)",$lines_array[$x],$synonym);
$synonymarray[$syncount] = strtoupper($synonym[1]);
$syncount++;
    }else if (strstr($lines_array[$x],"goto:")){
eregi("goto: (.*)",$lines_array[$x],$goto);
$goto = strtoupper($goto[1]);
// find the keyword
for ($zcount=0;$zcount<count($kwarray);$zcount++){
   // if the keyword already exists
   if (eregi($goto,$kwarray[$zcount])){
// then we assign properties of the keyword
$vararray[$currentkw][0] = $kwarray[$currentkw];
$resparray[$currentkw] = $resparray[$zcount];
   }
}
   }
}

$y=0;
$z=0;
$v=0;
$bestpriority=-2;
$originalstring = $string;
if (!$string){
    $string = "hello";
}
$string = strtoupper($string);

// Figures out what word in the string has the most priority.
// It can then check words to the left/right of this word depending
// upon settings in the knowledge.txt file.
while ($y < count($kwarray)){
// remove beginning and trailing white space, breaks, etc
$string = trim($string);
// remove puncuation from string
$string = ereg_replace('[!?,.]','',$string);
    // split the string up into seperate words   
    $wordarray = explode(" ",$string);
    while ($v < count($wordarray)){
        if(eregi($wordarray[$v]."$",$kwarray[$y])){
    // find which word holds the most weight in the sentance
    if($bestpriority==-2){
       $bestpriority=$y;
            }else if ($priarray[$bestpriority] < $priarray[$y]){
$bestpriority = $y;
        }
}
    $v++;
    }
    $v = 0;
    $y++;
}

// find the variance with the most matching words
$vcount=0;
while ($vcount < count($vararray[$bestpriority])){
if (strstr($vararray[$bestpriority][$vcount],"@")){
eregi("@(.*)",$vararray[$bestpriority][$vcount],$syn); // fix this
$syn = $syn[1];
for($x=0;$x<count($synonymarray);$x++){
if (eregi($syn,strtoupper($synonymarray[$x]))){
$sarray = explode(" ",$synonymarray[$x]);
for($f=0;$f<count($sarray);$f++){
$newstring = ereg_replace("@(.*)$",$sarray[$f],$vararray[$bestpriority][$vcount]);
// works to this point
if(eregi($newstring."$",$string)){
   $varray = explode(" ",$vararray[$bestpriority][$vcount]);
   if(count($varray) > $pvarray){
  $bestvariance = $vcount;
  $pvarray = count($varray);
   }
}
}
}
}
}else{
if(ereg($vararray[$bestpriority][$vcount],$string)){
   $varray = explode(" ",$vararray[$bestpriority][$vcount]);
   if(count($varray) > $pvarray){
  $bestvariance = $vcount;
  $pvarray = count($varray);
   }
}
}
$vcount++;
}

// Using the bestpriority (aka the keyword (key:) with the most weight in the sentence)
// and the bestvariance (aka, the variance (var:) phrase that most fits the context of
// the original sentence, we form a response.
if (count($resparray[$bestpriority][$bestvariance]) > 1){
$random = mt_rand(0,count($resparray[$bestpriority][$bestvariance])-1);
}else{
$random = 0;
}
$response = $resparray[$bestpriority][$bestvariance][$random];
if ($response==""){
$response = "Sorry, I don't understand what you're trying to say.";
}

$originalstring = ereg_replace("[\]","",$originalstring);
echo "<h3>Chat with PHPliza!</h3>";
echo "<b>You: </b>".$originalstring."<br>";
echo "<b>PHPliza: </b>".$response;

?>
<FORM ACTION="eliza.php">
   <INPUT TYPE="text" size="20" name="string"><INPUT TYPE="SUBMIT" value="Submit">
</FORM>
</BODY>
</HTML>

knowledge.txt
syn: Hello Hi Hey Goodday Hola Yo Hiya
syn: Friend Comrad Mate
syn: you man dood

key: Hello
pri: 3
var: Hello
   resp: How's it going?
   resp: Yo what's up?
   resp: Yo Yo Yo
var: Hello @you
   resp: Howdy
var: Hello @you there
   resp: G'day.
var: Hello @friend
   resp: Hi Friend!

key: Goodbye
pri: 2
var: Goodbye
   resp: See ya later!
   resp: Good day, sir.
   resp: Later mang
var: Goodbye friend
   resp: Goodbye, friend.

key: How
pri: 3
var: How
   resp: You got me!
var: How are you
   resp: I'm not sure
   resp: I'm doing fine
   resp: Swell, thanks for asking.
var: How do
   resp: I don't know
   resp: I cannot answer that question
var: How is
   resp: I don't know how that is.

key: You
pri: 2
var: You
   resp: Does that interest you?
var: You are
   resp: Let's not talk about me

key: Name
pri: 4
var: name
   resp: I'm not good with names.
var: your name
   resp: Why is my name important?
   resp: Do you like my name?

key: Yes
pri: 2
var: yes
   resp: Ok, cool!
   resp: Fine with me.
   resp: Ok.

key: No
pri: 3
var: no
   resp: Oh, ok.
   resp: Why not?
   resp: Oh really?

key: Ok
pri: 3
var: ok
   resp: If you say so.
   resp: Whatever you say =)
   resp: Fine with me.

key: Have
pri: 3
var: have
   resp: Have what?
var: you have
   resp: I'm not sure if I have that.
var: have you
   resp: I'm not sure if I've done that.

key: Doctor
pri: 4
var: doctor
   resp: I'm no doctor.
   resp: What's this about doctors?

key: Hey
pri: 2
goto: Hello

key: Hola
pri: 2
goto: Hello

key: Hi
pri: 2
goto: Hello

key: Aight
pri 2:
goto: Ok

key: Thanks
pri: 3
var: thanks
   resp: You're welcome!

key: Why
pri: 3
var: why
   resp: I'm not really sure.
var: know why
   resp: I don't know why.

key: Maybe
pri: 3
var: maybe
   resp: Ok.
   resp: Whatever you say.
   resp: If you say so.

key: Probably
pri: 3
goto: maybe

key: Possible
pri: 3
goto: maybe

key: yep
pri: 3
goto: yes

key: yeah
pri: 3
goto: yes

key: nope
pri: 3
goto: no

key: Where
pri: 4
var: Where
   resp: I really couldn't tell ya.
var: you live
   resp: Why do you want to know where I live?
var: you from
   resp: Why do you want to know where I'm from?

key: What
pri: 3
var: What
   resp: WHAT!!!

key: god
pri: 3
var: god
   resp: Sorry, I don't know him.

key: Watt
pri: 3
goto: What

key: Like
pri: 3
var: like
   resp: I'm not sure.
var: do you like
   resp: I don't know if I like that.
   resp: Do you think I like that?

key: Because
pri: 3
goto: Ok

key: Problem
pri: 5
var: you have
   resp: I don't have any problems.. I'm here to answer your problems =)
var: I have
   resp: Please tell me your problem.
   resp: I'd like to hear more about your problem.

key: I
pri: 2
var: I
   resp: Oh do you?
   resp: I see.
var: I am
   resp: Are you really?
   resp: Interesting.


Logged

If I can't be Mr. Root then I don't want to play.
dink
Expert
****
Offline Offline

Posts: 330


View Profile
« Reply #8 on: October 06, 2008, 04:13:57 PM »

Hmmmm.  Interesting approach. 

Thanks Perk, methinks there may be a future for a variant of this code.   Grin

//off topic//
When do you travel across the big blue pond?
Logged

[quote Nutballs]
the universe has a giant fist, and its got enough whoop ass for everyone.
[/quote]
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 5229


:sniffle: Humor was so much easier before.


View Profile
« Reply #9 on: October 06, 2008, 04:19:14 PM »

Wheels up oh-dark-thirty Thursday. A brief and horrible stop in some southeastern city then a hellish overnight into Dublin, arriving early in the AM Friday. Then a long, but awful, drive into Limerick where I'll probably finally get a Guinness and some decent corned beef, surrounded by heavy & pungent cigarettes and unfettered brilliance. Fellow yanks along for the ride an exception, of course.

Wishin' you were gonna show ol' chum... it's gonna be splendid Wink
Logged

If I can't be Mr. Root then I don't want to play.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Online Online

Posts: 635



View Profile
« Reply #10 on: October 07, 2008, 08:40:38 AM »

CDC, The Kaptain and I take off from Beantown thursday night as well. Arrive friday morning in Shannon.
Logged

dink
Expert
****
Offline Offline

Posts: 330


View Profile
« Reply #11 on: October 07, 2008, 04:02:08 PM »

Sounds like fun.  Perhaps next year.

Have a pint and some of that scrumptious corned beef for me.
Logged

[quote Nutballs]
the universe has a giant fist, and its got enough whoop ass for everyone.
[/quote]
dink
Expert
****
Offline Offline

Posts: 330


View Profile
« Reply #12 on: October 07, 2008, 08:34:56 PM »

CDC, The Kaptain and I take off from Beantown thursday night as well. Arrive friday morning in Shannon.

Pie for the skipper and tea leaves (or whatever a sloathe eats) for VS.

NB's and I will stay here and mind the store.  Well, NB's will.  I'll be out dinkin around.   Grin
Logged

[quote Nutballs]
the universe has a giant fist, and its got enough whoop ass for everyone.
[/quote]
nutballs
Administrator
Lifer
*****
Online Online

Posts: 3453


View Profile
« Reply #13 on: October 07, 2008, 10:43:00 PM »

theres a store?
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Online Online

Posts: 5229


:sniffle: Humor was so much easier before.


View Profile
« Reply #14 on: October 07, 2008, 10:44:18 PM »

Yes. You can get harassed and called gay even at 3am. Didn't you get the memo?
Logged

If I can't be Mr. Root then I don't want to play.
Pages: [1] 2
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!