Giter VIP home page Giter VIP logo

go-wit's Introduction

#go-wit

wercker status

A Go library for the Wit.ai API for Natural Language Processing.

Version

0.3

Installation

go get github.com/jsgoecke/go-wit

Documentation

http://godoc.org/github.com/jsgoecke/go-wit

Usage

package main

import (
	"github.com/jsgoecke/go-wit"
	"encoding/json"
	"log"
	"os"
)

func main() {
	client := wit.NewClient(os.Getenv("WIT_ACCESS_TOKEN"))

	// Process a text message
	request := &wit.MessageRequest{}
	request.Query = "Hello world"
	result, err := client.Message(request)
	if err != nil {
		println(err)
		os.Exit(-1)
	}
	log.Println(result)
	data, _ := json.MarshalIndent(result, "", "    ")
	log.Println(string(data[:]))

	// Process an audio/wav message
	request = &wit.MessageRequest{}
	request.File = "../audio_sample/helloWorld.wav"
	request.ContentType = "audio/wav;rate=8000"
	result, err = client.AudioMessage(request)
	if err != nil {
		println(err)
		os.Exit(-1)
	}
	log.Println(result)
	data, _ = json.MarshalIndent(result, "", "    ")
	log.Println(string(data[:]))
}

// Output:

// structs:
// &{bf699a8f-bc90-4fb4-a715-bd8bd77749db Hello world {hello {{ } []} 0.996}}
// &{54ed4e6d-0653-453e-8c0c-81da57c3846c hello world {hello {{ } []} 0.993}}

// json:
// {
//     "msg_id": "76f1c370-bd92-417f-8cb3-e1419d1a9cb3",
//     "msg_body": "Hello world",
//     "outcome": {
//         "intent": "hello",
//         "entities": {
//             "metric": {},
//             "datetime": null
//         },
//         "confidence": 0.996
//     }
// }
// {
//     "msg_id": "322f9b61-0f75-4953-a392-f8eca058a12f",
//     "msg_body": "hello world",
//     "outcome": {
//         "intent": "hello",
//         "entities": {
//             "metric": {},
//             "datetime": null
//         },
//         "confidence": 0.993
//     }
// }

Testing

Must have the environment variable WIT_ACCESS_TOKEN set to your Wit API token.

cd go-wit
go test

Test Coverage

http://gocover.io/github.com/jsgoecke/go-wit

Lint

http://go-lint.appspot.com/github.com/jsgoecke/go-wit

License

MIT, see LICENSE.txt

Author

Jason Goecke @jsgoecke.

go-wit's People

Contributors

jsgoecke avatar oliviervaussy avatar

Watchers

James Cloos avatar FrankWang 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.