Latest 0.1.1
Homepage https://github.com/fredfoc/OpenWit
License MIT
Platforms ios 9.0
Dependencies Moya-ObjectMapper
Frameworks CoreAudio
Authors

Version
License
Platform

This Pod is an intent to get a swift framework for Wit.ai© HTTP API.

You can find more information about Wit© on: https://wit.ai and https://wit.ai/docs/http/20160526
Wit© is an amazing NLP api where you can define stories (at the time of this writing they are in beta). Wit© does speech recognition, converse, message analyse, can learn to understand what you want and many more things.

This library is a first version where you can analyse a message and converse (speech is actually not fully implemented but should be soon). It requires Moya and ObjectMapper.

You can find some informations about how the Wit application is structured in the WitData folder.

OpenWit

Converse with WIT API:

OpenWit OpenWit OpenWit

Message with WIT API:

OpenWit

Entities:

OpenWit

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Configure your WIT App:

OpenWit

in XCode:

Setup OpenWit sharedInstance with your own access tokens (generally in AppDelegate)

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    OpenWit.sharedInstance.WITTokenAcces = "WIT Client Token"
    OpenWit.sharedInstance.WITServerTokenAcces = "WIT Server Token"
    return true
}

Create a model if needed (Custom entity in Wit)

/// a custom entity defined in Wit
struct ShopItemEntity: Mappable {
    static var entityId = "shopItem"

    var suggested: Bool = false
    var confidence: Float?
    var type: String?
    var value: String?

    public init?(map: Map) {}

    mutating public func mapping(map: Map) {
        confidence          <- map[OpenWitJsonKey.confidence.rawValue]
        type                <- map[OpenWitJsonKey.type.rawValue]
        value               <- map[OpenWitJsonKey.mainValue.rawValue]
        suggested           <- map[OpenWitJsonKey.suggested.rawValue]
    }
}

Launch a request using method in OpenWit

OpenWit
    .sharedInstance
    .message(message,
    messageId: nil,
    threadId: nil) {[unowned self] result in
        switch result {
            case .success(let message):
                /// Your logic should start here... :-)
                /// intents are generic entities so they are built in
                self.printResult(message.intents?.description ?? "no intent", clearResult: true)
                /// shopItems are custom entities
                self.printResult(message.shopItems?.description ?? "no shopItem")
            case .failure(let error):
                print(error)
        }
    }

Requirements

Installation

OpenWit is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "OpenWit"

Author

fauquette fred, [email protected]

License

OpenWit is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "OpenWit",
    "version": "0.1.1",
    "summary": "swift framework for Witu00a9 HTTP API.",
    "description": "This Pod is an intent to get a swift framework for Wit.aiu00a9 HTTP API.nYou can find more information about Wit on: https://wit.ai and https://wit.ai/docs/http/20160526nWitu00a9 is an amazing NLP api wher you can define stories (at the time of this writing they are in beta). It does speech recognition, converse, message analyse, can learn to understand what you want and many more things.nThis library is a first version where you can analyse a message and converse (speech is actually not fully implemented but should be soon).nIt requires Moya and ObjectMapper.",
    "homepage": "https://github.com/fredfoc/OpenWit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "fauquette fred": "[email protected]"
    },
    "source": {
        "git": "https://github.com/fredfoc/OpenWit.git",
        "tag": "0.1.1"
    },
    "social_media_url": "https://twitter.com/FredFauquette",
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "OpenWit/Classes/**/*",
    "frameworks": "CoreAudio",
    "dependencies": {
        "Moya-ObjectMapper": [
            "2.2.1"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This