0.3.1 • Published 8 years ago

watson-translate-stream v0.3.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

watson-translate-stream

A duplex stream that detects and translates natural language using IBM Watson.

Installation

Download node at nodejs.org and install it, if you haven't already.

npm install watson-translate-stream --save

Usage

Watson translate stream uses a duplex stream to manage two text streams between differing natural languages.

Constructor

class LanguageStream extends Stream.Transform
 constructor: (@fromLanguage, @toLanguage) ->

Snippet

LanguageFilter = require('watson-translate-stream')
Pipe = require("multipipe")

# Create a shell process to attach to.
cmd =  'telnet'
arguments = ['localhost', '3001']
process = ChildProcess.spawn(cmd, arguments)

# Make a new language filter, and set the egress stream language to
# english. In this example, we know what we are speaking (en), and
# we don't set the far end language so it can be detected and translated.
# To turn off detection, specify both ingress and egress languages.
# Supports the current Watson languages (en, es, fr, ko)
language = new LanguageFilter('en')

ingressProcessStream = Pipe(language.ingressStream, process.stdin)
egressProcessStream = Pipe(process.stdout, language.egressStream)

Dependencies

Dev Dependencies

License

MIT

Generated by package-json-to-readme