Prof.Phreak
  home | services | products | resources | forum
 
about us | contact   
Particle
November 25th, 2024



www.theparticle.com
Main
Services
Products
Resources
Forum
About Us
Contact

Particle Revelation
Hardware Destruction
Quotes
Humor [alpha]
Murphy's Laws

Programming
Java
Java Data Structures
C# Data Structures
Database Design
Graphics Tutorial
Artificial Intelligence

Downloads
SQLRunner
Graphics Tutorials
Hacking Tutorials
Java Applets
MIDI Music
Gov & Misc Docs

Games
Chess Game
Asteroids
Tic-Tac-Toe
Tetris

Applets
DRAW!
FlightBox
pWobble 3D
pRunner
NYU HWs
Swarms
Geometry
Chaos
Machine Learning

Academic
CISC 7700X
CISC 7512X
CISC 7500X
IT Mngmt (old)
SW (old)
Networks (old)
OS (old)
AI (old)
App Dev (old)
C++ (old)
OOP (old)
Web (old)
Perl (old)
DBMS (old)
ProgLangs (old)
PHP (old)
MltMedia (old)
Oracle (old)

Misc
Privacy Policy
Publications
profphreak.com



Prof.Phreak POC3

Experience Prof.Phreak here! (ajax)

Experience Java Applet Prof.Phreak here! (java applet)

Experience CGI Prof.Phreak here! (cgi; for very old browsers)

Note: this current Prof.Phreak is only a Proof Of Concept (POC) for use of this type of technology & database.

Prof.Phreak the AJAX/Web Service

After hearing quite a bit of hype about AJAX (and what the hell it is), I decided to turn ProfPhreak into an AJAX page (and learn something about this whole JavaScript thing, err).

The ProfPhreak core service is nearly identical to the Java one (except it doesn't use XML now), and instead of a Java Applet for UI (and networking), JavaScript it used. That's pretty much it. You can do a view-source to see how it wr0ks, etc.

Prof.Phreak the Java Applet/Web Service

Prof.Phreak has been made into an XML based Web Service! It is now possible for any system/language/software to communicate with Prof.Phreak. The system is loosely based on the web-service specs from both Sun ONE and Microsoft .NET. The service accepts an XML SOAP envelope packaging the input phrase. Prof.Phreak Web Service then responds with a SOAP envelope containing result. This enables front end Applets that communicate with the service.

You can find more info about the service and the format of the SOAP XML (I didn't crate a DTD for this simple thing) in file: webservice.cgi (this is the file that implements the Web Service). Sample applet is: ProfPhreakApplet.java (it connects to the service).  The sample html for Applet is: source_database.html (note that you'll probably want to modify it to refer to a correct Service URL). There is also a command line, stand alone client WebServiceClient.java (again, you'll probably need to modify it to refer to a correct service URL).

What's new in POC2

The major addition to Prof.Phreak since POC1 is the computation engine. This enables Prof.Phreak to answer some basic math expression questions. For example:

You: Hey, Professor, do you know what seven thousand five hundred forty seven plus ninety six is?
Prof.Phreak: Is it seven thousand six hundred forty three?

You can also combine digit numbers into it... ie: "what's 7 minus two?", would get you a response like "I'm kind of bad with math, but is it five?".

You can also do more complicated things. For example, you can use "open parenthesis" and "close parenthesis" to group expressions. i.e.: "open parenthesis eight plus seven close parenthesis times three" would give the result "forty five" instead of "twenty nine" without the parenthesis. Note: the ( and ) work just as well, ie: ( eight + seven ) * three

You can have a lot of fun with this, try making ridiculously complicated expressions, and let Prof.Phreak figure it out. For example: "Hey, Professor, solve this: open parenthesis negative eighteen hundred forty seven plus three thousand eighteen close parenthesis times seven hundred ninety six plus negative thirteen times thirty six divide by twelve minus open parenthesis eight hundred sixty four plus four hundred seventy three close parenthesis times negative fourteen" and the Professor instantly spits out "You mean nine hundred fifty thousand seven hundred ninety five... right?"

Also, notice that spacing doesn't really matter in most cases. Prof.Phreak knows that sixhundredsixtysix is 666 ;-) It looks for the biggest match, so, the 'sixty' will be matched instead of the 'six'...

In the end, if professor phreak has determined that you're trying to ask him a math question, he may simply choose to ignore it, choose not to answer it, answer it incorrectly, etc. (Hey, Prof.Phreak has FREE WILL!) Also, if you made some error in the expression (like your parenthesis don't match, etc.) Prof.Phreak will try to hint at the problem, or may simply say he hates math, etc. Prof.Phreak also doesn't like numbers above 232, and he'll let you know that if your computation involves such large numbers.

More POC2 Stuff:
Added floating point calculation engine. If you ask "what's 2.5 plus 3.14" it will answer correctly.
Fixed divide by zero bug.
Strip matching variables of spaces.
Created a lookup list of words that have numbers as substring. Prof.Phreak will no longer confuse "Money" for "one" (or "tent" for "ten"; along with a few hundred other words)

Prof.Phreak command API

Another major addition is support for little scriptlets (little Perl code fragments) inside the database. Once a match has been found (along with the variables, etc.) If defined, the code for that rule gets evaluated. The code can use the variables found in the regular expression, and also output variables.

This Command structure is the next step in making Prof.Phreak useful. You can put code to query some SQL database for some results, extract something from some file, do some XML stuff, query environment variables (you can make Prof.Phreak suck up to the user by saying "Hello. Oh, I love Windows users", or "Hello. Oh, I love Machintosh users", or "Hello. Oh, I love Linux users" just by quering the CGI environment).

There isn't much room for code though, so if you're doing something very serious for some particular feedback, then you might want to put a scriptlet to execute some outside perl code found in another file...

For the time being, There are examples of how to get the time and date. When you say "what time is it?" Prof.Phreak will reply with the current time embeded in diff formats in diff replies. Similar goes for the date.

Prof.Phreak POC1

The entire program is a relatively small (but complex) Perl script. The database has keywords, phrases, pattern matching, etc., in order to make this whole thing work. The database makes use of Perl regular expressions to facilitate easier (and more precise) string matching. A sample rule looks like this:

// simple regular expression match test
([a-z]+) hits ([a-z]+)

Why would $1 hit $2?
Can you prove that $1 hit $2?
I hope $2 didn't get hurt.
Is $1 violent?
Did $2 provoke $1?

Any Rule can have multiple regular expression matches (the rule above only has one), and multiple replies (rule above has five). Replies are chosen in sequence relative to the server (but not necessarily the client).

The rules can also have parameters. In the case above, ([a-z]+) matches any word. So, the rule above can be more or less translated into:

SUBJECT hits OBJECT

Where both SUBJECT and OBJECT are words. We can then place them into replies... like:

Why would SUBJECT hit OBJECT?

These matching rules combined with some hard coded rules make for some powerful database capabilities. There is also an additional 'type' of rule, which is not like the one shown (it's similar though): 

// you are (complement)
(u|you|(you.*are)|(are.*you)).*(clever|fun|interesting|cool|smart|good)
How could you tell? Yes, I'm $4.
It must be my $4'nes. Everybody tells me that.
Yep. I'm $4.
Well, I admit it. I'm $4.
You got me. I'm definitely $4.

These new type of rules are more flexible, since you can apply them to specific areas. For example, there is a general rule "you are (.*)", in which case Prof.Phreak would reply "how did you know I am $1" or something like that... but that's not very nice, especially when people make fun, and say things like "you are a dork" and Prof.Phreak replies with "How did you know I am a dork," but now with these more targeted matches (which are searched first) you might get a more precise match, and things like "you are a dork" will be met with "You're the dork'est dork I've ever met!" Giving the impression that Prof.Phreak does not allow himself to be insulted (and understands what "dork" means).

There is another feature to this:

After all the matches have been completed, the program determines which rule matched the most. For example, we wouldn't want to call rule "you are good" when we see a pattern "you are good bastard" in the input. The maximum match almost guarantees we will only get the largest (and usually correct) match. (i.e.: in this case, Prof.Phreak would catch the insult, even though it's disguised by a complementary "you are good" phrase.

That's not the end either! The program also pre-processes all input, and converts things like: "I'm" into "I am" and "don't" into "do not", etc., which makes the database a bit smaller. Also, the number of spaces between words makes no difference. For example: "How are you?" is interpreted the same as "Howareyou?" and the same as "How   ARE   YOU?"

In the end, the program also post-processes all output to make sure things like "me" in the input refer to "you" in the output, and similar things like that.

Credit

I would like to give some credit to the thousands of people who wrote such a program and let other people play with it. Before writing Prof.Phreak I roamed the web through a lot of these types of programs, and obviously got many ideas from them.

The Prof.Phreak database is riddled with database chunks from many other such programs. I've modified it enough to give it a distinct personality, but if you really look for things, I'm sure you can find replies which you've already seen elsewhere. The databases used a lot are:

Bob (Bob Over Bob) by Luka
ElizaApplet (Cheezy Eliza) by Shoel Perelman

The others, are just my paranoia...

Download

To download Prof.Phreak POC2, visit the products page.





















© 1996-2024 by End of the World Production, LLC.