nV News Forums

 
 

nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   Software Development (http://www.nvnews.net/vbulletin/forumdisplay.php?f=53)
-   -   I want to make a simple parser that I can teach more every day. (http://www.nvnews.net/vbulletin/showthread.php?t=113273)

XDanger 05-15-08 04:41 PM

I want to make a simple parser that I can teach more every day.
 
Like an old text based adventure parser

it would have a set number of feelings that would change as I speak to it
The text it speaks would be a mix and match based on these variable feelings plus a random element.

I would keep adding to it a few lines every day.

What can I use to do this?

I want to be able to use vista speech recognition with it.

When it gets fat I would hope to change it slightly to start teaching it when its making sense.

ViN86 05-15-08 05:14 PM

Re: I want to make a simple parser that I can teach more every day.
 
why not use C?

you can use cygwin to compile the code and execute it and run it in a command line. save the data to a text file.

XDanger 05-18-08 02:10 PM

Re: I want to make a simple parser that I can teach more every day.
 
I was hoping there would be something a bit more BASIC I could use.

I need something very low level like
XX if a is => 20 then "Hello"
XX if b is => 20 then "Yes"
if c is => 20 then "No"
if a is <= 20 then "I dunno"
if a is <= 10 then "Mind your own biznis"

List of nice words
All ## "Thankyou", "Your Welcome", etc

if input ## then a = a+1

Could have a mood face image also

I remember being able to do this kind of thing on my commodore or spectrum, will I have to use an emulator????

ViN86 05-26-08 10:46 PM

Re: I want to make a simple parser that I can teach more every day.
 
Quote:

Originally Posted by XDanger
I was hoping there would be something a bit more BASIC I could use.

I need something very low level like
XX if a is => 20 then "Hello"
XX if b is => 20 then "Yes"
if c is => 20 then "No"
if a is <= 20 then "I dunno"
if a is <= 10 then "Mind your own biznis"

List of nice words
All ## "Thankyou", "Your Welcome", etc

if input ## then a = a+1

Could have a mood face image also

I remember being able to do this kind of thing on my commodore or spectrum, will I have to use an emulator????

you could do it in PHP and use the switch() statement. that way you could also put it online and share it with us :D

fizzleborth 07-10-08 01:25 PM

Re: I want to make a simple parser that I can teach more every day.
 
You're looking to write a copy of ELIZA? That didn't actually have "feelings," or any sort of "memory" at all from one response to the next, so I suppose that means you'll be advancing the state of the art :).

I think Prolog is made for exactly this sort of thing, though I've never used it myself. But your example of how you imagine the code looking is pretty declarative, if you ignore the if/then/else boilerplate. No idea of how you'd go about learning Prolog though, and I imagine it isn't a great first language, if you've never programmed before.

On the other hand, you seem to have a grasp of basic imperative control structures (if/then/else) already (although in most imperative languages, you'd be assigning the "Hello"/"Yes"/etc. responses to a variable, as in if happiness < 10 and responses_given > 5: response = "Go away", and then have a step of explicitly printing the response, not to mention a step before all that of parsing the user's reply and adjusting the "feelings" variables based on what was typed). So sticking with an imperative language would probably have you up and running the fastest, not to mention that any given imperative language will probably be easier to learn (with many more tutorials and helpful communities) than Prolog (or any other declarative language).

I'll recommend Python since you don't say if/what programming language(s) you know. In python, you can just load up the interpreter and try code out interactively to see what works and what it returns, right away, which really accelerates prototyping and learning. It also has a ton of tutorials on the net and tons of books for sale about learning python. It's pretty easy to get running on whatever sort of system you're using (just download and run a singler installer on Windows, and it registers itself to run all .py files, and includes the GUI interpreter in your start menu, and you're ready to go), and there's no extra setup (like getting a web server running locally to do PHP development). Especially for a console-based program like you're describing, it should be well-suited.

There are also a great many third-party "modules" for it, so it is pretty simple to add, say, a PyGame-based graphical component if you want, or a couple of XMPP modules if you want to turn it into an IM bot/twitter bot. And I'm sure it's possible to link it into Vista's speech recognition (though it might not be easy or pretty to do so; also, does Vista do general speech-to-text, or only recognize a set of commands?). Plus if Python becomes your general everyday hammer, that won't be too bad, since it's pretty good at hitting most nails (scripts to do file management, a program to gather statistics on your MP3s' ID3 tags, a webapp for managing your schedule, it's pretty versatile).

On the other hand, if having it on the web so that anyone with a web browser can use your program sounds like a fun idea (and many more people will visit a web page than will be willing to download and install a program), I'd recommend PHP too. Nothing beats PHP for a first-time web programmer, and (if it includes what you want) HTML is the easiest way to add a GUI that there is. Also it's super easy to find cheap hosting with PHP support. Python does have web programming, but it's more complicated, most packages are aimed more at database-driven sites, and it's not so easy to find a host for a python script. There is Google's App Engine of course, and that has the added advantage of being free, but it's still just not as easy and quick as PHP.

That said, if all you want is a pre-made ELIZA, a google search should get you one pretty quickly. There's also an example of ELIZA written in python, but it's pretty... concise, and not so easy to understand for a Python beginner (in part because it's trying to include the responses in a declarative manner).


All times are GMT -5. The time now is 06:35 AM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.