Skip to content

Commit 7a5094a

Browse files
author
Chris Park
committed
Merge branch 'develop'
2 parents 1726213 + 72cdd95 commit 7a5094a

14 files changed

+68
-15
lines changed

Jenkinsfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ node {
88
checkout scm
99
}
1010
stage("Test with Docker") {
11-
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${env.BINDING_TEST_URL}"]) {
11+
echo "${env.ALT_URL}"
12+
def useUrl = ("${env.ALT_URL}" == "null") ? "${env.BINDING_TEST_URL}" : "${env.ALT_URL}"
13+
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${useUrl}"]) {
1214
sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source rosetteapi/docker-nodejs"
1315
}
1416
}

Jenkinsfile.examples

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ node {
1111
}
1212
stage("Build Dockerfile") {
1313
dir ("${DOCKERFILE_DIR}") {
14-
docker.build("${TEST_CONTAINER}")
14+
sh "docker build --no-cache -t ${TEST_CONTAINER} ."
1515
}
1616
}
1717
stage("Run Examples") {
18-
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${env.BINDING_TEST_URL}"]) {
18+
echo "${env.ALT_URL}"
19+
def useUrl = ("${env.ALT_URL}" == "null") ? "${env.BINDING_TEST_URL}" : "${env.ALT_URL}"
20+
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${useUrl}"]) {
1921
def examplesDir = "${SOURCEDIR}" + '/examples'
2022
sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${examplesDir}:/source ${TEST_CONTAINER}"
2123
}

examples/entities.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var args = parser.parseArgs();
1313

1414
var api = new Api(args.key, args.url);
1515
var endpoint = "entities";
16-
var entities_text_data = "Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS";
16+
var entities_text_data = "The Securities and Exchange Commission today announced the leadership of the agency’s trial unit. Bridget Fitzpatrick has been named Chief Litigation Counsel of the SEC and David Gottesman will continue to serve as the agency’s Deputy Chief Litigation Counsel. Since December 2016, Ms. Fitzpatrick and Mr. Gottesman have served as Co-Acting Chief Litigation Counsel. In that role, they were jointly responsible for supervising the trial unit at the agency’s Washington D.C. headquarters as well as coordinating with litigators in the SEC’s 11 regional offices around the country.";
1717

1818
api.parameters.content = entities_text_data;
1919
api.parameters.genre = "social-media";

examples/language_multilingual.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"use strict";
2+
3+
var Api = require("../lib/Api");
4+
var ArgumentParser = require("argparse").ArgumentParser;
5+
6+
var parser = new ArgumentParser({
7+
addHelp: true,
8+
description: "Determine the language of a piece of text"
9+
});
10+
parser.addArgument(["--key"], {help: "Rosette API key", required: true});
11+
parser.addArgument(["--url"], {help: "Rosette API alt-url", required: false});
12+
var args = parser.parseArgs();
13+
var api = new Api(args.key, args.url);
14+
var endpoint = "language";
15+
var appHeader = [];
16+
appHeader[0] = "X-RosetteAPI-App"
17+
appHeader[1] = "app";
18+
api.parameters.customHeaders = [appHeader];
19+
20+
var language_multilingual_data = "On Thursday, as protesters gathered in Washington D.C., the United States Federal Communications Commission under Chairman Ajit Pai voted 3-2 to overturn a 2015 decision, commonly called Net Neutrality, that forbade Internet service providers (ISPs) such as Verizon, Comcast, and AT&T from blocking individual websites or charging websites or customers more for faster load times. Quatre femmes ont été nommées au Conseil de rédaction de la loi du Qatar. Jeudi, le décret royal du Qatar a annoncé que 28 nouveaux membres ont été nommés pour le Conseil de la Choura du pays. ذكرت مصادر أمنية يونانية، أن 9 موقوفين من منظمة \"د هـ ك ب ج\" الذين كانت قد أوقفتهم الشرطة اليونانية في وقت سابق كانوا يخططون لاغتيال الرئيس التركي رجب طيب أردوغان.";
21+
22+
api.parameters.content = language_multilingual_data;
23+
var appHeader = [];
24+
appHeader[0] = "X-RosetteAPI-App"
25+
appHeader[1] = "app";
26+
api.parameters.customHeaders = [appHeader];
27+
api.parameters.options = { "multilingual": "true" };
28+
29+
api.rosette(endpoint, function(err, res){
30+
if(err){
31+
console.log(err);
32+
} else {
33+
console.log(JSON.stringify(res, null, 2));
34+
}
35+
});

examples/morphology_complete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var args = parser.parseArgs();
1313
var api = new Api(args.key, args.url);
1414
var endpoint = "morphology";
1515

16-
var morphology_complete_data = "The quick brown fox jumped over the lazy dog. Yes he did.";
16+
var morphology_complete_data = "The quick brown fox jumped over the lazy dog. 👍🏾 Yes he did. B)";
1717
var content = morphology_complete_data;
1818

1919
api.parameters.content = content;

examples/name_deduplication.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var args = parser.parseArgs();
1313
var api = new Api(args.key, args.url);
1414
var endpoint = "nameDeduplication";
1515

16-
var name_dedupe_data = "John Smith,Johnathon Smith,Fred Jones";
16+
var name_dedupe_data = "Alice Terry,Alice Thierry,Betty Grable,Betty Gable,Norma Shearer,Norm Shearer,Brigitte Helm,Bridget Helem,Judy Holliday,Julie Halliday";
1717

1818
api.parameters.names = name_dedupe_data.split(",").map(function(name) {
1919
return {"text": name, "language": "eng", "entityType": "PERSON"}

examples/relationships.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var args = parser.parseArgs();
1414
var api = new Api(args.key, args.url);
1515
var endpoint = "relationships";
1616

17-
var relationships_text_data = "Bill Gates, Microsoft's former CEO, is a philanthropist.";
17+
var relationships_text_data = "FLIR Systems is headquartered in Oregon and produces thermal imaging, night vision, and infrared cameras and sensor systems. According to the SEC’s order instituting a settled administrative proceeding, FLIR entered into a multi-million dollar contract to provide thermal binoculars to the Saudi government in November 2008. Timms and Ramahi were the primary sales employees responsible for the contract, and also were involved in negotiations to sell FLIR’s security cameras to the same government officials. At the time, Timms was the head of FLIR’s Middle East office in Dubai.";
1818
var content = relationships_text_data;
1919

2020
api.parameters.content = content;

examples/sentences.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var args = parser.parseArgs();
1414
var api = new Api(args.key, args.url);
1515
var endpoint = "sentences";
1616

17-
var sentences_data = "This land is your land. This land is my land\nFrom California to the New York island;\nFrom the red wood forest to the Gulf Stream waters\n\nThis land was made for you and Me.\n\nAs I was walking that ribbon of highway,\nI saw above me that endless skyway:\nI saw below me that golden valley:\nThis land was made for you and me.";
17+
var sentences_data = "This land is your land. This land is my land, from California to the New York island; from the red wood forest to the Gulf Stream waters. This land was made for you and Me. As I was walking that ribbon of highway, I saw above me that endless skyway: I saw below me that golden valley: This land was made for you and me.";
1818
var content = sentences_data;
1919

2020
api.parameters.content = content;

examples/text_embedding.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var args = parser.parseArgs();
1313

1414
var api = new Api(args.key, args.url);
1515
var endpoint = "textEmbedding";
16-
var embeddings_data = 'Cambridge, Massachusetts'
16+
var embeddings_data = "Cambridge, Massachusetts"
1717

1818
api.parameters.content = embeddings_data;
1919
api.rosette(endpoint, function(err, res){

examples/transliteration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var args = parser.parseArgs();
1414
var api = new Api(args.key, args.url);
1515
var endpoint = "transliteration";
1616

17-
var transliteration_data = "Bill Gates, Microsoft's former CEO, is a philanthropist.";
17+
var transliteration_data = "ana r2ye7 el gam3a el sa3a 3 el 3asr";
1818

1919
api.parameters.content = transliteration_data;
2020

lib/parameters.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function parameters() {
4646
this.language = null;
4747
this.documentFile = null;
4848
this.genre = null;
49+
this.options = null;
4950

5051
// name matching parameters
5152
this.name1 = null;
@@ -69,7 +70,6 @@ function parameters() {
6970
this.sourceLanguage = null;
7071

7172
//relationships parameters
72-
this.options = null;
7373
this.accuracyMode = null;
7474

7575
//sentiment parameters
@@ -162,7 +162,7 @@ parameters.prototype.loadFile = function(filePath, loadedParameters, userKey, pr
162162
"accept": 'application/json',
163163
"accept-encoding": "gzip",
164164
"content-type": 'multipart/mixed',
165-
"user-agent": "rosetteapinode/" + BINDING_VERSION,
165+
"user-agent": "rosetteapinode/" + BINDING_VERSION + "/" + process.version,
166166
"X-RosetteAPI-Binding": "nodejs",
167167
"X-RosetteAPI-Binding-Version": BINDING_VERSION
168168
}

lib/rosetteRequest.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ var querystring = require('querystring');
2828
*
2929
* @type string
3030
*/
31-
var BINDING_VERSION = "1.8.0";
31+
var BINDING_VERSION = "1.8.1";
32+
var USER_AGENT = "rosetteapinode/" + BINDING_VERSION + "/" + process.version;
3233

3334
/**
3435
* @class
@@ -41,6 +42,7 @@ function rosetteRequest() {
4142
};
4243

4344
rosetteRequest.prototype.bindingVersion = function() { return BINDING_VERSION; }
45+
rosetteRequest.prototype.userAgent = function() { return USER_AGENT; }
4446

4547
/**
4648
* Makes an HTTP request to the specified Rosette API endpoint and returns the result
@@ -55,7 +57,7 @@ rosetteRequest.prototype.makeRequest = function(requestType, userKey, protocol,
5557
"accept": "application/json",
5658
"accept-encoding": "gzip",
5759
"content-type": "application/json",
58-
"user-agent": "rosetteapinode/" + BINDING_VERSION,
60+
"user-agent": USER_AGENT,
5961
"X-RosetteAPI-Binding": "nodejs",
6062
"X-RosetteAPI-Binding-Version": BINDING_VERSION
6163
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rosette-api",
3-
"version": "1.8.0",
3+
"version": "1.8.1",
44
"description": "Rosette API Node.js client SDK",
55
"main": "index",
66
"directories": {

tests/unittests.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ var ping = require("../lib/ping");
2323
var syntax_dependencies = require("../lib/syntax_dependencies");
2424
var paramObj = require("../lib/parameters");
2525
var rosetteException = require("../lib/rosetteExceptions");
26+
var rosetteRequest = require("../lib/rosetteRequest.js");
27+
28+
describe("User Agent", function() {
29+
it("correctly constructs the User-Agent", function() {
30+
var req = new rosetteRequest();
31+
var testUserAgent = "rosetteapinode/" + req.bindingVersion() + "/" + process.version;
32+
33+
req.userAgent(function(err, res) {
34+
chai.expect(res.name).to.equal(testUserAgent);
35+
});
36+
});
37+
});
2638

2739
describe("Language Endpoint", function() {
2840
beforeEach(function(done) {

0 commit comments

Comments
 (0)