Giter Club home page Giter Club logo

aiml's Introduction

aiml

This is a fork of the paulovn/python-aiml Python AIML interpreter. It has been refactored to make it

  1. support Chinese
  2. support both Python 2.7 and Python 3
  3. support all combinations of * operation
  4. support if-exists tab

Part of the idea and example are from andelf/PyAIML.

PyAIML is (c) Cort Stratton. python-aiml uses the same license as PyAIML (2-clause BSD), except for the ALICE AIML files taken from the Free ALICE AIML set, which are licensed with the LGPL license.

Install

git clone https://github.com/Shuang0420/aiml.git
cd aiml
python setup.py build
python setup.py install

Usage

Quick & dirty example (assuming you've downloaded the "alice" AIML set):

import aiml
import os

# the path where your AIML startup.xml file located
chdir = os.getcwd()

k = aiml.Kernel()

# for alice
k.bootstrap(learnFiles="std-startup.xml", commands="load aiml b", chdir=chdir)

# if python 2
# while True: print(k.respond(raw_input("> ")))
# if python 3
while True: print(k.respond(input("> ")))

example3

Quick & dirty example (assuming you've downloaded the "cn-examples" AIML set): first cd cn-examples

import aiml
import os

# the path where your AIML startup.xml file located
chdir = os.getcwd()

k = aiml.Kernel()

# for chinese
k.bootstrap(learnFiles="cn-startup.xml", commands="load aiml cn", chdir=chdir)

# if python 2
# while True: print(k.respond(raw_input("> ")))
# if python 3
while True: print(k.respond(input("> ")))

See Examples for details.

Examples

Some specific examples:

/example1:

example1

/example2:

example2

/example3: Run python start.py first and then run python continue.py. Example3 does not work for python2 due to shelve sync issue.

example3

/example4:

example4

Scripts

Two small scripts are added upon installation:

  • aiml-validate can be used to validate AIML files
  • aiml-bot can be used to start a simple interactive session with a bot, after loading either AIML files or a saved brain file.

Datasets

The installation includes two AIML datasets:

  • The standard AIML set, as it was included in PyAIML
  • The Free ALICE AIML set_ v. 1.9, taken from the data published by the ALICE AI Foundation_ (with a few small fixes in files that did not validate as AIML 1.0.1_)

They can be loaded via the bootstrap method in the Kernel class. See the bot.py_ script for an example.

Tests

There are a number of unit tests included (in the test subdirectory); they can be executed by the setup infrastructure as:

python setup.py test

or they can also be launched by directly calling:

python test [testname ...]

This last version allows executing only some of the test files by explicitly naming them in the command line; if none is specified all will be executed.

aiml's People

Contributors

paulovn avatar rarredon avatar shuang0420 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  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.