Skip to content

Commit 73429d2

Browse files
committed
Merge pull request #12 from rosette-api/0.7.6
Merge 0.7.6 to master
2 parents e4e4b10 + fef9a97 commit 73429d2

File tree

11 files changed

+62
-16
lines changed

11 files changed

+62
-16
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ before_install:
99
before_script:
1010
- npm install grunt-cli -g
1111
script: grunt
12+
notifications:
13+
slack:
14+
rooms:
15+
- secure: 4FRaTAAiYyeUvgw2RhmblgbNiJO4wmd34OBgWcwURjP9oVmFfSwR9r1LNCdUGxrPOghexSY2DjXIuvIrfTfi/xYbhHb3Kw7PEAyB8IuBMlKtY4NSFou62S2VhYpxyg58T+C7P2zi0eDnDE06pwTCoGPaimxMZQY91yQ0yPYDPVXbwe5SjEgamzlwGBxlS/0A6w1iCPHg27/iO2hXtdW3oLS2I0F/Q8Q95RBkX9hpg6yqHlTV7jRbSqvQ9OFBqk/tXMHQvhoPDGgCgQDuykJuaAYx7g9d0YL0eEYYOh9B/TJ/kNOwdRFBu5kuQ2/nFS5Z0S3Y3UIhdYjUmm9gSMnwIbYnrW22EqDJLoT9Zi3Gv7Prg/8/fSkWsof7BJTMSuXUqO1AxDGKIxFv9uSF1daZoY+AC1ooU1xDu1nNvWVYPlkwEdDxxmHpFkGT3ESTZYccPovQl8Z5K0I1BBAVdJKDzm07lE6VHbxkKcvK6gG0TN3uLxnSlQtjkfJ+aVMq1kxeVsB9lEsKs9oezsKzzbftMm525aXPg+OAv+31CUFWxvT/p4ps8Q+AV6aZpoPHkpK8VryyNirUeZ/m4m4ebDHhD9vcN+JqE9gzshT+0U3g19SvLiUMQtbuZ2BUvrq2hh2LEGs03AFZaNg9AEUVA1PQRhV5NILyoS/lbiBYJPT39Sg=
16+
- secure: D4VxkkZlj7uaaFbqEBITkJCusVeii436N8X6GijuosUSaee9lqGYUF5ZS9lV6VGMKs719IfSJsCc2v/N4nc9Y/8AKgXd7AWHUwaRR+MC6r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FneShIQsbl9KgYXoR6HiXcbBiNdmmZjSrzkPYh7vlsujYrz6Cg2msKybWJ/FfOz0tS1cjlCtiCMOTExN6tEF8YCp9l+s+5RLe61pgFPy4Snr9pEjuTS5DYliTyZMY2ZZC1clBQtgE8E2qCG1QSzqnqqiGxj2K4zmLPpB4y1XpW8e3yk=
18+

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![Build Status](https://travis-ci.org/rosette-api/nodejs.svg?branch=master)](https://travis-ci.org/rosette-api/nodejs)
2+
13
# rosette-api
24

35
Rosette API binding for node.js
@@ -13,4 +15,4 @@ var rosette-api = require('rosette-api');
1315
See [examples](examples).
1416

1517
## Additional Information
16-
See [Rosette API site](https://developer.rosette.com/)
18+
See [Rosette API site](https://developer.rosette.com/)

examples/base64_input.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Example code to call Rosette API to get entities from a piece of text.
3+
*/
4+
5+
"use strict";
6+
7+
var Api = require("rosette-api").Api;
8+
var ArgumentParser = require("argparse").ArgumentParser;
9+
var DocumentParameters = require("rosette-api").DocumentParameters;
10+
var rosetteConstants = require("rosette-api").rosetteConstants
11+
12+
var parser = new ArgumentParser({
13+
addHelp: true,
14+
description: "Get the entities from a piece of text"
15+
});
16+
parser.addArgument(["--key"], {help: "Rosette API key", required: true});
17+
var args = parser.parseArgs();
18+
19+
var docParams = new DocumentParameters();
20+
var content = new Buffer("Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS ").toString('base64');
21+
22+
docParams.setItem("content", content);
23+
docParams.setItem("contentType", rosetteConstants.dataFormat.UNSPECIFIED);
24+
25+
var api = new Api(args.key);
26+
api.entities(docParams, false, function(err, res) {
27+
if (err) {
28+
throw err;
29+
}
30+
else {
31+
console.log(res);
32+
}
33+
});

examples/categories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var parser = new ArgumentParser({
1414
});
1515
parser.addArgument(["--key"], {help: "Rosette API key", required: true});
1616
parser.addArgument(["--url"], {help: "Optional URL for data",
17-
defaultValue: "https://en.wikipedia.org/wiki/Basis_Technology_Corp."});
17+
defaultValue: "http://www.onlocationvacations.com/2015/03/05/the-new-ghostbusters-movie-begins-filming-in-boston-in-june/"});
1818
var args = parser.parseArgs();
1919

2020
var docParams = new DocumentParameters();

examples/entities.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ parser.addArgument(["--key"], {help: "Rosette API key", required: true});
1616
var args = parser.parseArgs();
1717

1818
var docParams = new DocumentParameters();
19-
var content = "President Obama urges the Congress and Speaker Boehner to pass the $50 billion spending bill based on Christian faith by July 1st or Washington will become totally dysfunctional, a terrible outcome for American people.";
19+
var content = "Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS ";
2020

2121
docParams.setItem("content", content);
2222

examples/entities_linked.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ parser.addArgument(["--key"], {help: "Rosette API key", required: true});
1616
var args = parser.parseArgs();
1717

1818
var docParams = new DocumentParameters();
19-
var content = "President Obama urges the Congress and Speaker Boehner to pass the $50 billion spending bill based on Christian faith by July 1st or Washington will become totally dysfunctional, a terrible outcome for American people.";
19+
var content = "Last month director Paul Feig announced the movie will have an all-star female cast including Kristen Wiig, Melissa McCarthy, Leslie Jones and Kate McKinnon.";
2020
docParams.setItem("content", content);
2121

2222
var api = new Api(args.key);

examples/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "rosette-api-examples",
33
"description": "Usage examples for Rosette API Node.JS client SDK",
4-
"version": "0.7.1",
4+
"version": "0.7.5",
55
"homepage": "https://developer.rosette.com",
66
"author": {
77
"name": "Basis Technology Corp.",
@@ -22,7 +22,7 @@
2222
],
2323
"main": "index",
2424
"engines": {
25-
"node": ">= 0.8.0"
25+
"node": ">= 0.12.0"
2626
},
2727
"scripts": {
2828
"test": "grunt nodeunit"

examples/relationships.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ parser.addArgument(["--key"], {help: "Rosette API key", required: true});
1616
var args = parser.parseArgs();
1717

1818
var relationshipsParams = new RelationshipsParameters();
19-
var content = "Yesterday in Guatemala, the Supreme Court approved the attorney general's request to impeach President Otto Pérez Molina.";
19+
var content = "Bill Murray is in the new Ghostbusters film!";
2020

2121
relationshipsParams.setItem("content", content);
2222

examples/sentiment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var args = parser.parseArgs();
1919
var docParams = new DocumentParameters();
2020

2121
var file = new tmp.File();
22-
var fileContents = "<html><head><title>Performance Report</title></head><body><p>This article is clean, concise, and very easy to read.</p></body></html>";
22+
var fileContents = "<html><head><title>New Ghostbusters Film</title></head><body><p>Original Ghostbuster Dan Aykroyd, who also co-wrote the 1984 Ghostbusters film, couldn’t be more pleased with the new all-female Ghostbusters cast, telling The Hollywood Reporter, “The Aykroyd family is delighted by this inheritance of the Ghostbusters torch by these most magnificent women in comedy.”</p></body></html>";
2323

2424
file.writeFileSync(fileContents);
2525

lib/Api.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ function Api(userKey, serviceUrl) {
5757
* @desc URL of the API
5858
* @default
5959
*/
60-
this.serviceUrl = "https://api.rosette.com/rest/v1";
60+
this.serviceUrl = "https://api.rosette.com/rest/v1/";
6161
if (serviceUrl) {
6262
this.serviceUrl = serviceUrl;
6363
}
64+
if (this.serviceUrl.indexOf('/', this.serviceUrl.length - 1) === -1) {
65+
this.serviceUrl = this.serviceUrl + '/';
66+
}
6467
/**
6568
* @desc True if the version has already been checked. Saves round trips.
6669
* @type {boolean}
@@ -126,6 +129,7 @@ Api.prototype.retryingRequest = function(err, callback, op, url, data, action, a
126129
if (err) {
127130
return callback(err);
128131
}
132+
129133
if (!tryNum) {
130134
tryNum = 0;
131135
}
@@ -134,7 +138,7 @@ Api.prototype.retryingRequest = function(err, callback, op, url, data, action, a
134138
if (urlParts.protocol === "https:") {
135139
protocol = https;
136140
}
137-
var headers = {"accept": "application/json", "accept-encoding": "gzip", "content-type": "application/json"};
141+
var headers = {"accept": "application/json", "accept-encoding": "gzip", "content-type": "application/json", "user-agent": "rosetteapinode/" + BINDING_VERSION};
138142
if (this.userKey) {
139143
headers["user_key"] = this.userKey;
140144
}
@@ -242,7 +246,7 @@ Api.prototype.callEndpoint = function(callback, parameters, subUrl) {
242246
err = new RosetteException("incompatible", "Multipart requires contentType SIMPLE", parameters.contentType);
243247
return callback(err);
244248
}
245-
var url = this.serviceUrl + "/" + subUrl;
249+
var url = this.serviceUrl + subUrl;
246250

247251
// Check that parameters follow their guidelines
248252
parameters.validate();
@@ -303,7 +307,7 @@ Api.prototype.finishResult = function(err, result, action, callback) {
303307
* @param {function} callback
304308
*/
305309
Api.prototype.info = function(callback) {
306-
var url = this.serviceUrl + "/info";
310+
var url = this.serviceUrl + "info";
307311
this.retryingRequest(null, callback, "GET", url, null, "info", this);
308312
};
309313

@@ -314,7 +318,7 @@ Api.prototype.info = function(callback) {
314318
* @param {function} callback
315319
*/
316320
Api.prototype.ping = function(callback) {
317-
var url = this.serviceUrl + "/ping";
321+
var url = this.serviceUrl + "ping";
318322
this.retryingRequest(null, callback, "GET", url, null, "ping", this);
319323
};
320324

@@ -325,7 +329,7 @@ Api.prototype.ping = function(callback) {
325329
* @param {function} callback
326330
*/
327331
Api.prototype.compareBindingToServer = function(callback) {
328-
var url = this.serviceUrl + "/info?clientVersion=" + BINDING_VERSION;
332+
var url = this.serviceUrl + "info?clientVersion=" + BINDING_VERSION;
329333
this.retryingRequest(null, callback, "POST", url, null, "info", this);
330334
};
331335

@@ -346,7 +350,7 @@ Api.prototype.language = function(parameters, callback) {
346350
* @throws RosetteException
347351
*/
348352
Api.prototype.languageInfo = function(callback) {
349-
var url = this.serviceUrl + "/language/info";
353+
var url = this.serviceUrl + "language/info";
350354
this.retryingRequest(null, callback, "GET", url, null, "language-info", this);
351355
};
352356

0 commit comments

Comments
 (0)