Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Park committed Jan 12, 2018
2 parents 1726213 + 72cdd95 commit 7a5094a
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 15 deletions.
4 changes: 3 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ node {
checkout scm
}
stage("Test with Docker") {
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${env.BINDING_TEST_URL}"]) {
echo "${env.ALT_URL}"
def useUrl = ("${env.ALT_URL}" == "null") ? "${env.BINDING_TEST_URL}" : "${env.ALT_URL}"
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${useUrl}"]) {
sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source rosetteapi/docker-nodejs"
}
}
Expand Down
6 changes: 4 additions & 2 deletions Jenkinsfile.examples
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ node {
}
stage("Build Dockerfile") {
dir ("${DOCKERFILE_DIR}") {
docker.build("${TEST_CONTAINER}")
sh "docker build --no-cache -t ${TEST_CONTAINER} ."
}
}
stage("Run Examples") {
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${env.BINDING_TEST_URL}"]) {
echo "${env.ALT_URL}"
def useUrl = ("${env.ALT_URL}" == "null") ? "${env.BINDING_TEST_URL}" : "${env.ALT_URL}"
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${useUrl}"]) {
def examplesDir = "${SOURCEDIR}" + '/examples'
sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${examplesDir}:/source ${TEST_CONTAINER}"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var args = parser.parseArgs();

var api = new Api(args.key, args.url);
var endpoint = "entities";
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";
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.";

api.parameters.content = entities_text_data;
api.parameters.genre = "social-media";
Expand Down
35 changes: 35 additions & 0 deletions examples/language_multilingual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"use strict";

var Api = require("../lib/Api");
var ArgumentParser = require("argparse").ArgumentParser;

var parser = new ArgumentParser({
addHelp: true,
description: "Determine the language of a piece of text"
});
parser.addArgument(["--key"], {help: "Rosette API key", required: true});
parser.addArgument(["--url"], {help: "Rosette API alt-url", required: false});
var args = parser.parseArgs();
var api = new Api(args.key, args.url);
var endpoint = "language";
var appHeader = [];
appHeader[0] = "X-RosetteAPI-App"
appHeader[1] = "app";
api.parameters.customHeaders = [appHeader];

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 موقوفين من منظمة \"د هـ ك ب ج\" الذين كانت قد أوقفتهم الشرطة اليونانية في وقت سابق كانوا يخططون لاغتيال الرئيس التركي رجب طيب أردوغان.";

api.parameters.content = language_multilingual_data;
var appHeader = [];
appHeader[0] = "X-RosetteAPI-App"
appHeader[1] = "app";
api.parameters.customHeaders = [appHeader];
api.parameters.options = { "multilingual": "true" };

api.rosette(endpoint, function(err, res){
if(err){
console.log(err);
} else {
console.log(JSON.stringify(res, null, 2));
}
});
2 changes: 1 addition & 1 deletion examples/morphology_complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var args = parser.parseArgs();
var api = new Api(args.key, args.url);
var endpoint = "morphology";

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

api.parameters.content = content;
Expand Down
2 changes: 1 addition & 1 deletion examples/name_deduplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var args = parser.parseArgs();
var api = new Api(args.key, args.url);
var endpoint = "nameDeduplication";

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

api.parameters.names = name_dedupe_data.split(",").map(function(name) {
return {"text": name, "language": "eng", "entityType": "PERSON"}
Expand Down
2 changes: 1 addition & 1 deletion examples/relationships.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var args = parser.parseArgs();
var api = new Api(args.key, args.url);
var endpoint = "relationships";

var relationships_text_data = "Bill Gates, Microsoft's former CEO, is a philanthropist.";
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.";
var content = relationships_text_data;

api.parameters.content = content;
Expand Down
2 changes: 1 addition & 1 deletion examples/sentences.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var args = parser.parseArgs();
var api = new Api(args.key, args.url);
var endpoint = "sentences";

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.";
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.";
var content = sentences_data;

api.parameters.content = content;
Expand Down
2 changes: 1 addition & 1 deletion examples/text_embedding.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var args = parser.parseArgs();

var api = new Api(args.key, args.url);
var endpoint = "textEmbedding";
var embeddings_data = 'Cambridge, Massachusetts'
var embeddings_data = "Cambridge, Massachusetts"

api.parameters.content = embeddings_data;
api.rosette(endpoint, function(err, res){
Expand Down
2 changes: 1 addition & 1 deletion examples/transliteration.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var args = parser.parseArgs();
var api = new Api(args.key, args.url);
var endpoint = "transliteration";

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

api.parameters.content = transliteration_data;

Expand Down
4 changes: 2 additions & 2 deletions lib/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function parameters() {
this.language = null;
this.documentFile = null;
this.genre = null;
this.options = null;

// name matching parameters
this.name1 = null;
Expand All @@ -69,7 +70,6 @@ function parameters() {
this.sourceLanguage = null;

//relationships parameters
this.options = null;
this.accuracyMode = null;

//sentiment parameters
Expand Down Expand Up @@ -162,7 +162,7 @@ parameters.prototype.loadFile = function(filePath, loadedParameters, userKey, pr
"accept": 'application/json',
"accept-encoding": "gzip",
"content-type": 'multipart/mixed',
"user-agent": "rosetteapinode/" + BINDING_VERSION,
"user-agent": "rosetteapinode/" + BINDING_VERSION + "/" + process.version,
"X-RosetteAPI-Binding": "nodejs",
"X-RosetteAPI-Binding-Version": BINDING_VERSION
}
Expand Down
6 changes: 4 additions & 2 deletions lib/rosetteRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ var querystring = require('querystring');
*
* @type string
*/
var BINDING_VERSION = "1.8.0";
var BINDING_VERSION = "1.8.1";
var USER_AGENT = "rosetteapinode/" + BINDING_VERSION + "/" + process.version;

/**
* @class
Expand All @@ -41,6 +42,7 @@ function rosetteRequest() {
};

rosetteRequest.prototype.bindingVersion = function() { return BINDING_VERSION; }
rosetteRequest.prototype.userAgent = function() { return USER_AGENT; }

/**
* Makes an HTTP request to the specified Rosette API endpoint and returns the result
Expand All @@ -55,7 +57,7 @@ rosetteRequest.prototype.makeRequest = function(requestType, userKey, protocol,
"accept": "application/json",
"accept-encoding": "gzip",
"content-type": "application/json",
"user-agent": "rosetteapinode/" + BINDING_VERSION,
"user-agent": USER_AGENT,
"X-RosetteAPI-Binding": "nodejs",
"X-RosetteAPI-Binding-Version": BINDING_VERSION
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rosette-api",
"version": "1.8.0",
"version": "1.8.1",
"description": "Rosette API Node.js client SDK",
"main": "index",
"directories": {
Expand Down
12 changes: 12 additions & 0 deletions tests/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ var ping = require("../lib/ping");
var syntax_dependencies = require("../lib/syntax_dependencies");
var paramObj = require("../lib/parameters");
var rosetteException = require("../lib/rosetteExceptions");
var rosetteRequest = require("../lib/rosetteRequest.js");

describe("User Agent", function() {
it("correctly constructs the User-Agent", function() {
var req = new rosetteRequest();
var testUserAgent = "rosetteapinode/" + req.bindingVersion() + "/" + process.version;

req.userAgent(function(err, res) {
chai.expect(res.name).to.equal(testUserAgent);
});
});
});

describe("Language Endpoint", function() {
beforeEach(function(done) {
Expand Down

0 comments on commit 7a5094a

Please sign in to comment.