lib/tonality.js
function (texts, options, callback) {

        if (typeof(options) === 'function') {
            callback = options;
            options = {};
        }

        if (Array.isArray(texts)) {
            texts = texts.map(function (text, i) {
                return textObj(text, i);
            });
        } else if (typeof(texts) === 'string') {
            texts = [textObj(texts)];
        }

        options = options || {};
        options.language = options.language || 'en';

        var body = {};
        for (var key in options) {
            if (options.hasOwnProperty(key)) {
                body[key] = options[key]
            }
        }
        body.texts = texts;

        var params = {
            method: 'POST',
            url: '/tonality',
            body: body
        };

        return client.request(params, callback);
    }
function (texts, options, callback) {

        if (typeof(options) === 'function') {
            callback = options;
            options = {};
        }

        if (Array.isArray(texts)) {
            texts = texts.map(function (text, i) {
                return textObj(text, i);
            });
        } else if (typeof(texts) === 'string') {
            texts = [textObj(texts)];
        }

        options = options || {};
        options.language = options.language || 'en';

        var body = {};
        for (var key in options) {
            if (options.hasOwnProperty(key)) {
                body[key] = options[key]
            }
        }
        body.texts = texts;

        var params = {
            method: 'POST',
            url: '/tonality',
            body: body
        };

        return client.request(params, callback);
    }
function ( texts , options , callback ) { if ( typeof ( options ) === 'function' ) { callback = options ; options = { } ; } if ( Array . isArray ( texts ) ) { texts = texts . map ( function ( text , i ) { return textObj ( text , i ) ; } ) ; } else if ( typeof ( texts ) === 'string' ) { texts = [ textObj ( texts ) ] ; } options = options || { } ; options . language = options . language || 'en' ; var body = { } ; for ( var key in options ) { if ( options . hasOwnProperty ( key ) ) { body [ key ] = options [ key ] } } body . texts = texts ; var params = { method : 'POST' , url : '/tonality' , body : body } ; return client . request ( params , callback ) ; }
Given a set of documents, return their tonality based on lexical analysis in multiple dimensions.
The tonality is calculated on a document level, that is, the response will return the tonality of
each document.

@param {Array|string} texts - an array of document objects or strings to be analyzed.
@param {object} [options] - optional set of options, forwarded to Gavagai API.
@param callback - callback function for when request is complete
- @param {object} error - an error object if there was a problem processing the request
- @param {object} data - the JSON-parsed data
@returns {*} - a promise.
Given a set of documents return their tonality based on lexical analysis in multiple dimensions . The tonality is calculated on a document level that is the response will return the tonality of each document .