/wit-gem

A Ruby wrapper for the Wit HTTP API.

Primary LanguageRubyMIT LicenseMIT

NOTICE: Project has been superceded by Official Wit Ruby SDK

You should be using the new Wit SDK for Ruby referenced above. This repository is left for historical reasons.


Wit Ruby Gem

This is an unnoficial Ruby wrapper for the Wit HTTP API. Wit turns natural language into structured data, this gem lets you use the Wit API from your Ruby app, provided you have a developer's access token.

Installation

Add this line to your application's Gemfile:

gem 'wit'

And then execute:

$ bundle

Or install it yourself as:

$ gem install wit

Usage

At time of writing, the only API method is message.

require 'wit'

wit = Wit::Client.new '<Your API Key>'
puts wit.message("I need a bud right now")

A JSON Hash will be returned, like so:

{
  "msg_id": "d953bd6c-c620-4dae-a3fc-7634b4330073",
  "msg_body": "i need a bud right now!",
  "outcome": {
    "intent": "grab_me_something",
    "entities": {
      "object_to_grab": {
        "value": "beer",
        "start": 9,
        "end": 12,
        "body": "bud"
      }
    },
    "confidence": 0.6310633902098893
  }
}

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

Copyright © 2013 Justin Workman

MIT License, see LICENSE.txt