Go to file
Helge Heß 7567cbc4b9 Update README w/ fork info
...
2019-03-29 15:33:28 +01:00
.travis.d Travis: Add basic setup 2018-04-24 21:31:11 +02:00
Sources Port to Linux 2018-04-24 21:53:55 +02:00
SwiftEliza Swift 4.2: Port UIKit code 2019-03-29 15:28:53 +01:00
SwiftEliza.xcodeproj Xcode 10.2: Apply suggested project changes 2019-03-29 15:26:49 +01:00
.gitignore Port to Linux 2018-04-24 21:53:55 +02:00
.travis.yml Add Swift 5 pkg Swift & Travis setup 2019-03-29 15:21:39 +01:00
Package.swift Add the SPM Package.swift, and a tool 2018-04-24 20:38:53 +02:00
Package@swift-5.swift Add Swift 5 pkg Swift & Travis setup 2019-03-29 15:21:39 +01:00
README.md Update README w/ fork info 2019-03-29 15:33:28 +01:00

README.md

SwiftEliza

Swift3 Swift4 Swift5 macOS iOS tuxOS Travis

Note: This is the ARI fork of kennysong/SwiftEliza. Upstream doesn't seem to incorporate PRs.

SwiftEliza is a Swift + iOS implementation of Weizenbaum's ELIZA chatbot, which is a simulation of a Rogerian psychotherapist.

Based on kennysong's Go implementation and QuestionBot from Apple's App Development with Swift book.

SwiftEliza screenshot

Notes

To run, just open the SwiftEliza.xcodeproj in XCode.

The functionality of ELIZA is contained in the Eliza.swift file, and the rest are boilerplate for the iOS app.

Written in Swift 3 for iOS 10 and above.

Swift Package Manager

Import Package

You can import Eliza as a regular Swift Package Manager package. To do so, use a Package.swift like this:

// swift-tools-version:5.0

import PackageDescription

let package = Package(
    name: "MyEliza",
    dependencies: [
        .package(url: "https://github.com/kennysong/SwiftEliza.git",
                 from: "1.0.0")
    ],
    targets: [
        .target(name: "MyEliza", dependencies: [ "Eliza" ])
    ]
)

API

The API consists of just three functions:

  • elizaHi() -> String
  • elizaBye() -> String
  • replyTo(_: String) -> String

Example:

let eliza = Eliza()
print(eliza.elizaHi())
print(eliza.replyTo("Hi Eliza, I'm feeling super-bad today!"))
print(eliza.elizaBye())

It is recommended that you add proper delays when responding to interactive questions. See the iOS app or the therapist tool for an example.