Skip to content

Commit

Permalink
v3
Browse files Browse the repository at this point in the history
  • Loading branch information
germanattanasio committed Feb 12, 2016
1 parent e81679a commit b44edf9
Show file tree
Hide file tree
Showing 47 changed files with 4,222 additions and 14,740 deletions.
2 changes: 1 addition & 1 deletion .cfignore
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules
node_modules
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
node_modules
.DS_Store
VCAP_SERVICES.json
run.sh
env*.sh
.DS_Store
202 changes: 0 additions & 202 deletions LICENSE

This file was deleted.

16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
# Tone Analyzer Nodejs Starter Application
# Tone Analyzer Node.js Starter Application

The IBM Watson [Tone Analyzer][service_url] service is a cognitive linguistic analysis service used to monitor and identify tones within a piece of writing. It detects three types of tones, including emotions (negative emotions, cheerfulness, anger), social propensities (open, agreeable, and conscientious), and writing styles (analytical, confident and tentative) from people’s writings. Furthermore, it helps people understand how the tones are derived from various linguistic signals. It also offers actionable suggestions to revise the writings for desirable communication tones.

<p align="center">
<img src="http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/img/service-gifs/tone-analyzer.gif" width="400">
</p>


Give it a try! Click the button below to fork into IBM DevOps Services and deploy your own copy of this application on Bluemix.

[![Deploy to Bluemix](https://bluemix.net/deploy/button.png)](https://bluemix.net/deploy)
[![Deploy to Bluemix](https://bluemix.net/deploy/button.png)](https://bluemix.net/deploy?repository=https://github.com/watson-developer-cloud/tone-analyzer-nodejs)

## Getting Started

Expand Down Expand Up @@ -40,7 +35,7 @@ applications:
5. Create the Personality Insights service in Bluemix

```sh
$ cf create-service tone_analyzer experimental tone-analyzer-service
$ cf create-service tone_analyzer beta tone-analyzer-service
```

6. Push it live!
Expand Down Expand Up @@ -73,7 +68,7 @@ See the full [Getting Started][getting_started] documentation for more details,
},
"label": "tone_analyzer",
"name": "tone-analyzer-service",
"plan": "experimental"
"plan": "beta"
}]
}
}
Expand All @@ -99,7 +94,6 @@ To troubleshoot your Bluemix app the main useful source of information are the l
## License

This sample code is licensed under Apache 2.0. Full license text is available in [LICENSE](LICENSE).
This sample code uses d3 and jquery, both distributed under a MIT license.

## Contributing

Expand All @@ -111,4 +105,4 @@ To troubleshoot your Bluemix app the main useful source of information are the l
[service_url]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/tone-analyzer.html
[cloud_foundry]: https://github.com/cloudfoundry/cli
[getting_started]: http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/getting_started/
[sign_up]: https://apps.admin.ibmcloud.com/manage/trial/bluemix.html?cm_mmc=WatsonDeveloperCloud-_-LandingSiteGetStarted-_-x-_-CreateAnAccountOnBluemixCLI
[sign_up]: https://console.ng.bluemix.net/registration/
37 changes: 12 additions & 25 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,27 @@

'use strict';

var express = require('express'),
app = express(),
bluemix = require('./config/bluemix'),
extend = require('util')._extend,
watson = require('watson-developer-cloud');
var express = require('express'),
app = express(),
watson = require('watson-developer-cloud');

// Bootstrap application settings
require('./config/express')(app);

var credentials = extend({
version: 'v2-experimental',
username: '<username>',//
password: '<password>'//
}, bluemix.getServiceCreds('tone_analyzer'));


// Create the service wrapper
var toneAnalyzer = watson.tone_analyzer(credentials);
var toneAnalyzer = watson.tone_analyzer({
url: 'https://gateway.watsonplatform.net/tone-analyzer-beta/api/',
username: '<username>',
password: '<password>',
version_date: '2016-11-02',
version: 'v3-beta'
});

// render index page
app.get('/', function(req, res) {
res.render('index');
});

app.post('/tone', function(req, res, next) {
app.post('/api/tone', function(req, res, next) {
toneAnalyzer.tone(req.body, function(err, data) {
if (err)
return next(err);
Expand All @@ -49,16 +45,7 @@ app.post('/tone', function(req, res, next) {
});
});

app.get('/synonyms', function(req, res, next) {
toneAnalyzer.synonym(req.query, function(err, data) {
if (err)
return next(err);
else
return res.json(data);
});
});

// error-handler settings
// error-handler application settings
require('./config/error-handler')(app);

var port = process.env.VCAP_APP_PORT || 3000;
Expand Down
42 changes: 0 additions & 42 deletions config/bluemix.js

This file was deleted.

8 changes: 8 additions & 0 deletions config/error-handler.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@

module.exports = function (app) {

// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.code = 404;
err.message = 'Not Found';
next(err);
});

// error handler
app.use(function(err, req, res, next) {
var error = {
Expand Down
Loading

0 comments on commit b44edf9

Please sign in to comment.