Coder Social home page Coder Social logo

cambricorp / eliza-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arosspope/eliza-rs

0.0 0.0 0.0 1.22 MB

A rust implementation of ELIZA - a natural language processing program developed by Joseph Weizenbaum in 1966.

Home Page: https://crates.io/crates/eliza

License: Apache License 2.0

Rust 100.00%

eliza-rs's Introduction

eliza-rs

Crates.io Documentation Build Status

This rust binary is an implementation of the early 'chatbot' program ELIZA. The original program was developed from 1964 to 1966 at the MIT Artificial Intelligence Laboratory by Joseph Weizenbaum.

Introduction

convo

ELIZA simulates conversation by implementing pattern matching and a substitution methodology that gives users an illusion of understanding on the part of the program. Directives on how to process input are provided by 'scripts', (written originally in MAD-Slip, now in json) which allow ELIZA to engage in discourse by following script rules. Weizenbaum’s intention was to demonstrate that the communication between man and machine is superficial. The most famous script, DOCTOR, simulates a Rogerian psychotherapist.

Weizenbaum, J. (1996), ELIZA - A computer program for the study of natural language communication between man and machine, Communications of the ACM, vol 9, issue 1

Installation

To install this rust binary, one can do so from source or from crates.io. In either case, you need to have the rust compiler and cargo installed on your system.

From crates.io

Installing eliza from crates.io is quite simple with cargo:

user@foo(~)$ cargo install eliza

From source

After forking this project and cloning it to your local machine, navigate to the project directory and run:

user@foo(eliza-rs)$ cargo build

You may also want to optionally run the unit tests to ensure ELIZA is behaving as expected:

user@foo(eliza-rs)$ cargo test

Usage

To start an ELIZA session, you must provide the binary with a path to an ELIZA script. This script takes the form of a json file. Assuming that you have installed from source and wanted to run the famous DOCTOR program, the command you would run from the project root would be similar to:

user@foo(eliza-rs)$ cargo run scripts/doctor.json
...

If instead, you installed from crates.io, then the location of doctor.json will be different. Out of convenience I decided to bundle the doctor.json script with the eliza binary on crates.io. For each user, it's location will be slightly different within the crates registry, so I would suggest moving it to somewhere more memorable before running:

user@foo(~)$ cp .cargo/registry/src/[some_hash]/eliza-[ver]/scripts/doctor.json .
user@foo(~)$ eliza doctor.json
...

running

Starting eliza with cargo then leaving the session


Writing your own ELIZA script

The beauty of ELIZA's design methodology means that the role of the programmer and playwright are separated. An important property of ELIZA is that a script is data - it is not part of the program itself. Hence, ELIZA is not restricted to a particular set of recognition patterns or responses, indeed not even to any specific language.

As such, contributors may decide to improve the original doctor.json script or completely create their own from scratch. A simple example of a pirate script has been included to show how little is needed to start creating something neat.

More information on the structure of a script can be found in the documentation for the script module on doc.rs.

Testing

Due to the somewhat deterministic nature of ELIZA, you can write unit tests to evaluate script rules. For example, in tests/conversation_test.rs, you could add the following:

#[test]
fn your_test(){
    let mut e = Eliza::new("scripts/your_script.json").unwrap();
    assert_eq!("bar", e.respond("foo"));
}

Where 'foo' is the users input to ELIZA, and 'bar' is the response.

It is also important to note that ELIZA produces logging output. To observe these logs during program execution, start the binary with the environment variable RUST_LOG=eliza.

eliza-rs's People

Contributors

arosspope avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.