From 86ec3d88af10d14cef1895fadca46441dbdb3385 Mon Sep 17 00:00:00 2001 From: Chris Park Date: Mon, 9 Jan 2017 09:15:48 -0500 Subject: [PATCH 01/10] RCB-488 - Removed social-media from syntax_dependencies - Update to travis.yml --- .travis.yml | 3 +-- examples/syntax_dependencies.js | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index a01758e..5f24231 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,10 @@ language: node_js node_js: - - "0.11.16" - - "0.12.7" - "1.0.4" - "4.2.4" - "4.4.7" - "6.3.0" + - "7.2.0" before_install: - npm install -g npm before_script: diff --git a/examples/syntax_dependencies.js b/examples/syntax_dependencies.js index 58600bd..146407a 100644 --- a/examples/syntax_dependencies.js +++ b/examples/syntax_dependencies.js @@ -16,7 +16,6 @@ var endpoint = "syntax_dependencies"; var syntax_dependencies_data = "Yoshinori Ohsumi, a Japanese cell biologist, was awarded the Nobel Prize in Physiology or Medicine on Monday."; api.parameters.content = syntax_dependencies_data; -api.parameters.genre = "social-media"; api.rosette(endpoint, function(err, res){ if(err){ console.log(err); From 615af0025de9b9915758de751e2a4b6ad0f2776a Mon Sep 17 00:00:00 2001 From: Chris Park Date: Tue, 18 Apr 2017 10:45:11 -0400 Subject: [PATCH 02/10] Added endpoint - name deduplication - unit tests - example --- examples/name_deduplication.js | 29 ++++++++++++ lib/nameDeduplication.js | 60 +++++++++++++++++++++++++ lib/parameters.js | 8 +++- tests/unittests.js | 82 +++++++++++++++++++++++++++------- 4 files changed, 163 insertions(+), 16 deletions(-) create mode 100644 examples/name_deduplication.js create mode 100644 lib/nameDeduplication.js diff --git a/examples/name_deduplication.js b/examples/name_deduplication.js new file mode 100644 index 0000000..b36e20e --- /dev/null +++ b/examples/name_deduplication.js @@ -0,0 +1,29 @@ +"use strict"; + +var Api = require("../lib/Api"); +var ArgumentParser = require("argparse").ArgumentParser; + +var parser = new ArgumentParser({ + addHelp: true, + description: "Deduplicate a list of names" +}); +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 = "nameDeduplication"; + +api.parameters.names = [ + {"text": "John Smith", "language": "eng", "entityType": "PERSON"}, + {"text": "Johnathon Smith", "language": "eng", "entityType": "PERSON"}, + {"text": "Fred Jones Smith", "language": "eng", "entityType": "PERSON"} +]; +api.parameters.threshold = 0.75; + +api.rosette(endpoint, function(err, res){ + if(err){ + console.log(err); + } else { + console.log(JSON.stringify(res, null, 2)); + } +}); diff --git a/lib/nameDeduplication.js b/lib/nameDeduplication.js new file mode 100644 index 0000000..48cf748 --- /dev/null +++ b/lib/nameDeduplication.js @@ -0,0 +1,60 @@ +/** + * Rosette API. + * + * @copyright 2014-2015 Basis Technology Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * @license http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. + **/ +"use strict"; + +var URL = require("url"); + +var rosetteConstants = require("./rosetteConstants"); +var RosetteException = require("./rosetteExceptions"); +var rosetteRequest = require("./rosetteRequest"); + +/** + * @class + * + * @copyright 2014-2015 Basis Technology Corporation. + * @license http://www.apache.org/licenses/LICENSE-2.0 + */ +function nameDeduplication() { + +}; + +/** + * Makes an HTTP request to the specified Rosette API endpoint and returns the result + * @param {string} parameters - The Rosette API endpoint parameters + * @param {string} userKey - The Rosette API user access key + * @param {string} serviceURL - The base service URL to be used to access the Rosette API + * @param {function} callback - Callback function to be exectuted after the function to which it is passed is complete + */ +nameDeduplication.prototype.getResults = function(parameters, userKey, protocol, serviceURL, callback) { + + if (parameters.documentFile != null) { + return callback(new RosetteException("badArgument", "nameDeduplication does not support documentFile")); + } else { + if (parameters.loadParams().threshold == null) { + parameters.threshold = 0.75; + } + // validate parameters + if (parameters.loadParams().names == null) { + return callback(new RosetteException("badArgument", "Must supply a list of names for deduplication")); + } else { + // configure URL + var urlParts = URL.parse(serviceURL + "name-deduplication"); + var req = new rosetteRequest(); + req.makeRequest('POST', userKey, protocol, urlParts, parameters, callback); + } + } + +}; + +module.exports = nameDeduplication; diff --git a/lib/parameters.js b/lib/parameters.js index 8c1d737..42a1a1d 100644 --- a/lib/parameters.js +++ b/lib/parameters.js @@ -51,6 +51,10 @@ function parameters() { this.name1 = null; this.name2 = null; + // name deduplication parameters + this.names = null; + this.threshold = null; + // name translation parameters this.name = null; this.targetLanguage = null; @@ -94,6 +98,8 @@ parameters.prototype.loadParams = function() { "name1": this.name1, "name2": this.name2, "name": this.name, + "names": this.names, + "threshold": this.threshold, "targetLanguage": this.targetLanguage, "entityType": this.entityType, "sourceLanguageOfOrigin": this.sourceLanguageOfOrigin, @@ -152,7 +158,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, "X-RosetteAPI-Binding": "nodejs", "X-RosetteAPI-Binding-Version": BINDING_VERSION } diff --git a/tests/unittests.js b/tests/unittests.js index 998a6ae..f6399b5 100644 --- a/tests/unittests.js +++ b/tests/unittests.js @@ -8,6 +8,7 @@ var fs = require('fs'); var Api = require("../lib/Api"); var language = require("../lib/language"); var relationships = require("../lib/relationships"); +var nameDeduplication = require("../lib/nameDeduplication"); var nameSimilarity = require("../lib/nameSimilarity"); var nameTranslation = require("../lib/nameTranslation"); var sentiment = require("../lib/sentiment"); @@ -42,7 +43,7 @@ describe("Language Endpoint", function() { nock.cleanAll(); done(); }); - + it("successfully calls the language endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); api.parameters.content = "Sample Content"; @@ -101,7 +102,7 @@ describe("Relationships Endpoint", function() { nock.cleanAll(); done(); }); - + it("successfully calls the relationships endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); api.parameters.content = "Sample Content"; @@ -129,6 +130,57 @@ describe("Relationships Endpoint", function() { }); +describe("Name Deduplication Endpoint", function() { + beforeEach(function(done) { + var mockResponse = JSON.stringify({'name': 'Rosette API', 'versionChecked': true}); + + nock('https://api.rosette.com', {"encodedQueryParams": true }) + .post('/rest/v1/info') + .query({"clientVersion": "1.1"}) + .reply(200, JSON.parse(mockResponse)); + + nock('https://api.rosette.com', {"encodedQueryParams": true }) + .post('/rest/v1/name-deduplication') + .query({"clientVersion": "1.1"}) + .reply(200, JSON.parse(mockResponse)); + done(); + }); + + afterEach(function(done) { + nock.cleanAll(); + done(); + }); + + it("successfully calls the name deduplication endpoint", function(done) { + var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); + + api.parameters.names = [ + {"text": "John Smith", "language": "eng", "entityType": "PERSON"}, + {"text": "Johnathon Smith", "language": "eng", "entityType": "PERSON"}, + {"text": "Fred Jones Smith", "language": "eng", "entityType": "PERSON"} + ]; + api.parameters.threshold = 0.75; + + api.rosette("nameDeduplication", function(err, res) { + chai.expect(err).to.be.null; + chai.expect(res.name).to.equal('Rosette API'); + done(); + }); + }); + + it("detects missing names parameter", function(done) { + var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); + + api.rosette("nameSimilarity", function(err, res) { + chai.expect(err).to.not.be.null; + chai.expect(err.name).to.equal('RosetteException'); + chai.expect(err.message).to.contain('badArgument'); + done(); + }); + }); + +}); + describe("Name Similarity Endpoint", function() { beforeEach(function(done) { var mockResponse = JSON.stringify({'name': 'Rosette API', 'versionChecked': true}); @@ -149,7 +201,7 @@ describe("Name Similarity Endpoint", function() { nock.cleanAll(); done(); }); - + it("successfully calls the name similarity endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); var name_similarity_data1 = "Michael Jackson"; @@ -202,7 +254,7 @@ describe("Name Translation Endpoint", function() { nock.cleanAll(); done(); }); - + it("successfully calls the name translation endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); api.parameters.name = "Some Name"; @@ -265,7 +317,7 @@ describe("Sentiment Endpoint", function() { nock.cleanAll(); done(); }); - + it("successfully calls the sentiment endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); api.parameters.content = "Some Content"; @@ -324,7 +376,7 @@ describe("Categories Endpoint", function() { nock.cleanAll(); done(); }); - + it("successfully calls the categories endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); api.parameters.content = "Some Content"; @@ -383,7 +435,7 @@ describe("Entities Endpoint", function() { nock.cleanAll(); done(); }); - + it("successfully calls the entities endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); api.parameters.content = "Some Content"; @@ -442,7 +494,7 @@ describe("Morphology Endpoint (suite covers all features)", function() { nock.cleanAll(); done(); }); - + it("successfully calls the morphology endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); api.parameters.content = "Some Content"; @@ -518,7 +570,7 @@ describe("Tokens Endpoint", function() { nock.cleanAll(); done(); }); - + it("successfully calls the tokens endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); api.parameters.content = "Some Content"; @@ -577,7 +629,7 @@ describe("Sentences Endpoint", function() { nock.cleanAll(); done(); }); - + it("successfully calls the sentences endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); api.parameters.content = "Some Content"; @@ -631,7 +683,7 @@ describe("Text Embedding Endpoint", function() { nock.cleanAll(); done(); }); - + it("successfully calls the textEmbedding endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); api.parameters.content = "Some Content"; @@ -690,7 +742,7 @@ describe("Syntactic Dependencies Endpoint", function() { nock.cleanAll(); done(); }); - + it("successfully calls the syntactic dependencies endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); api.parameters.content = "Some Content"; @@ -748,7 +800,7 @@ describe("Info Endpoint", function() { nock.cleanAll(); done(); }); - + it("successfully calls the info endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); @@ -781,7 +833,7 @@ describe("Ping Endpoint", function() { nock.cleanAll(); done(); }); - + it("successfully calls the ping endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); @@ -813,7 +865,7 @@ describe("Error 409 Incompatible Binding Check", function() { nock.cleanAll(); done(); }); - + it("successfully handles the error", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); api.rosette("info", function(err, res) { From ec9942a30f22d026e9a6d84970533ba6e9e78fa0 Mon Sep 17 00:00:00 2001 From: Chris Park Date: Tue, 18 Apr 2017 11:19:14 -0400 Subject: [PATCH 03/10] Transliteration endpoint - added - unit tests - example - README updated --- README.md | 11 ++-- examples/transliteration.js | 32 ++++++++++ lib/Api.js | 2 + lib/nameSimilarity.js | 2 +- lib/nameTranslation.js | 4 +- lib/parameters.js | 4 ++ lib/transliteration.js | 70 +++++++++++++++++++++ tests/unittests.js | 119 ++++++++++++++++++++++++++++++++++++ 8 files changed, 236 insertions(+), 8 deletions(-) create mode 100644 examples/transliteration.js create mode 100644 lib/transliteration.js diff --git a/README.md b/README.md index 77c4bab..e2b3b8f 100644 --- a/README.md +++ b/README.md @@ -37,23 +37,24 @@ api.rosette(endpoint, function(err, res){ ## API Parameters | Parameter | Endpoint | Required | ------------- |------------- |------------- -| content | categories, entities, language, morphology, relationships, sentences, sentiment, tokens | Either content or contentUri required | +| content | categories, entities, language, morphology, relationships, sentences, sentiment, tokens, transliteration | Either content or contentUri required, transliteration requires content only | | contentUri | categories, entities, language, morphology, relationships, sentences, sentiment, tokens | Either content or contentUri required | | language | categories, entities, language, morphology, relationships, sentences, sentiment, tokens, name similarity | No | | documentFile | categories, entities, language, morphology, relationships, sentences, sentiment, tokens | No | | name1 | name similarity | Yes | | name2 | name similarity| Yes | | name | name translation | Yes | -| targetLanguage | name translation | Yes | +| names | name deduplication | Yes | +| targetLanguage | name translation, transliteration | Yes | | entityType | name translation | No | | sourceLanguageOfOrigin | name translation | No | | sourceLanguageOfUse | name translation | No | -| sourceScript | name translation | No | -| targetScript | name translation | No | +| sourceLanguage | transliteration | Yes | +| sourceScript | name translation, transliteration | No, transliteraion Yes | +| targetScript | name translation, transliteration | No, transliteraion Yes | | targetScheme | name translation | No | | options | relationships | No | | accuracyMode | relationships | Yes | -| linkEntities | entities | No | | explain | sentiment | No | | morphology | morphology | Yes | diff --git a/examples/transliteration.js b/examples/transliteration.js new file mode 100644 index 0000000..1e47038 --- /dev/null +++ b/examples/transliteration.js @@ -0,0 +1,32 @@ +"use strict"; + +var Api = require("../lib/Api"); +var ArgumentParser = require("argparse").ArgumentParser; + +var parser = new ArgumentParser({ + addHelp: true, + description: "Get the transliteration from 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 = "transliteration"; + +var transliteration_data = "Bill Gates, Microsoft's former CEO, is a philanthropist."; +var content = transliteration_data; + +api.parameters.content = content; +api.parameters.targetLanguage = "eng"; +api.parameters.targetScript = "Latn"; +api.parameters.sourceLanguage = "eng"; +api.parameters.sourceScript = "Latn"; + +api.rosette(endpoint, function(err, res) { + if (err) { + console.log(err); + } else { + console.log(JSON.stringify(res, null, 2)); + } +}); diff --git a/lib/Api.js b/lib/Api.js index c3b95cf..f4b7104 100644 --- a/lib/Api.js +++ b/lib/Api.js @@ -26,6 +26,7 @@ var entities = require("./entities"); var info = require("./info"); var language = require("./language"); var matchedName = require("./nameSimilarity"); +var nameDeduplication = require("./nameDeduplication"); var morphology = require("./morphology"); var ping = require("./ping"); var relationships = require("./relationships"); @@ -35,6 +36,7 @@ var textEmbedding = require("./textEmbedding"); var translatedName = require("./nameTranslation"); var tokens = require("./tokens"); var syntax_dependencies = require("./syntax_dependencies"); +var transliteration = require("./transliteration"); /** * @class diff --git a/lib/nameSimilarity.js b/lib/nameSimilarity.js index 64a7a21..34ffd68 100644 --- a/lib/nameSimilarity.js +++ b/lib/nameSimilarity.js @@ -39,7 +39,7 @@ function nameSimilarity() { nameSimilarity.prototype.getResults = function(parameters, userKey, protocol, serviceURL, callback) { if (parameters.documentFile != null) { - parameters.loadFile(parameters.documentFile, parameters, userKey, protocol, serviceURL, "name-similarity", callback); + return callback(new RosetteException("badArgument", "Name similarity does not support documentFile", "bad arguments")); } else { // validate parameters diff --git a/lib/nameTranslation.js b/lib/nameTranslation.js index ba2b864..7c1eab1 100644 --- a/lib/nameTranslation.js +++ b/lib/nameTranslation.js @@ -39,12 +39,12 @@ function nameTranslation() { nameTranslation.prototype.getResults = function(parameters, userKey, protocol, serviceURL, callback) { if (parameters.documentFile != null) { - parameters.loadFile(parameters.documentFile, parameters, userKey, protocol, serviceURL, "name-translation", callback); + return callback(new RosetteException("badArgument", "Name translation does not support documentFile", "bad arguments")); } else { // validate parameters if (parameters.loadParams().name == null) { - return callback(new RosetteException("badArgument", "Must name parameter", "bad arguments")); + return callback(new RosetteException("badArgument", "Must supply name parameter", "bad arguments")); } else if (parameters.loadParams().targetLanguage == null) { return callback(new RosetteException("badArgument", "Must supply target language parameter", "bad arguments")); } else { diff --git a/lib/parameters.js b/lib/parameters.js index 42a1a1d..a5e7ad8 100644 --- a/lib/parameters.js +++ b/lib/parameters.js @@ -65,6 +65,9 @@ function parameters() { this.targetScript = null; this.targetScheme = null; + // transliteration parameters + this.sourceLanguage = null; + //relationships parameters this.options = null; this.accuracyMode = null; @@ -104,6 +107,7 @@ parameters.prototype.loadParams = function() { "entityType": this.entityType, "sourceLanguageOfOrigin": this.sourceLanguageOfOrigin, "sourceLanguageOfUse": this.sourceLanguageOfUse, + "sourceLanguage": this.sourceLanguage, "sourceScript": this.sourceScript, "targetScript": this.targetScript, "targetScheme": this.targetScheme, diff --git a/lib/transliteration.js b/lib/transliteration.js new file mode 100644 index 0000000..3235271 --- /dev/null +++ b/lib/transliteration.js @@ -0,0 +1,70 @@ +/** + * Rosette API. + * + * @copyright 2014-2015 Basis Technology Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * @license http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. + **/ +"use strict"; + +var URL = require("url"); + +var rosetteConstants = require("./rosetteConstants"); +var RosetteException = require("./rosetteExceptions"); +var rosetteRequest = require("./rosetteRequest"); + +/** + * @class + * + * @copyright 2014-2015 Basis Technology Corporation. + * @license http://www.apache.org/licenses/LICENSE-2.0 + */ +function transliteration() { + +}; + +/** + * Makes an HTTP request to the specified Rosette API endpoint and returns the result + * @param {string} parameters - The Rosette API endpoint parameters + * @param {string} userKey - The Rosette API user access key + * @param {string} serviceURL - The base service URL to be used to access the Rosette API + * @param {function} callback - Callback function to be exectuted after the function to which it is passed is complete + */ +transliteration.prototype.getResults = function(parameters, userKey, protocol, serviceURL, callback) { + + if (parameters.documentFile != null) { + parameters.loadFile(parameters.documentFile, parameters, userKey, protocol, serviceURL, "transliteration", callback); + } else { + + // validate parameters + if (parameters.loadParams().content == null) { + return callback(new RosetteException("badArgument", "Must supply Content", "bad arguments")); + } + if (parameters.loadParams().targetLanguage == null) { + return callback(new RosetteException("badArgument", "Must supply targetLanguage", "bad arguments")); + } + if (parameters.loadParams().targetScript == null) { + return callback(new RosetteException("badArgument", "Must supply targetScript", "bad arguments")); + } + if (parameters.loadParams().sourceLanguage == null) { + return callback(new RosetteException("badArgument", "Must supply sourceLanguage", "bad arguments")); + } + if (parameters.loadParams().sourceScript == null) { + return callback(new RosetteException("badArgument", "Must supply sourceScript", "bad arguments")); + } + + // configure URL + var urlParts = URL.parse(serviceURL + "transliteration"); + var req = new rosetteRequest(); + req.makeRequest('POST', userKey, protocol, urlParts, parameters, callback); + } + +}; + +module.exports = transliteration; diff --git a/tests/unittests.js b/tests/unittests.js index f6399b5..c4c1477 100644 --- a/tests/unittests.js +++ b/tests/unittests.js @@ -781,6 +781,125 @@ describe("Syntactic Dependencies Endpoint", function() { }); +describe("Transliteration Endpoint", function() { + beforeEach(function(done) { + var mockResponse = JSON.stringify({'name': 'Rosette API', 'versionChecked': true}); + + nock('https://api.rosette.com', {"encodedQueryParams": true }) + .post('/rest/v1/info') + .query({"clientVersion": "1.1"}) + .reply(200, JSON.parse(mockResponse)); + + nock('https://api.rosette.com', {"encodedQueryParams": true }) + .post('/rest/v1/transliteration') + .query({"clientVersion": "1.1"}) + .reply(200, JSON.parse(mockResponse)); + done(); + }); + + afterEach(function(done) { + nock.cleanAll(); + done(); + }); + + it("successfully calls the transliteration endpoint", function(done) { + var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); + api.parameters.content = "Some Content"; + api.parameters.targetLanguage = "eng"; + api.parameters.targetScript = "Latn"; + api.parameters.sourceLanguage = "eng"; + api.parameters.sourceScript = "Latn"; + + api.rosette("transliteration", function(err, res) { + chai.expect(err).to.be.null; + chai.expect(res.name).to.equal('Rosette API'); + done(); + }); + + }); + + it("detects content parameter is not defined", function(done) { + var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); + + api.parameters.targetLanguage = "eng"; + api.parameters.targetScript = "Latn"; + api.parameters.sourceLanguage = "eng"; + api.parameters.sourceScript = "Latn"; + + api.rosette("transliteration", function(err, res) { + chai.expect(err).to.not.be.null; + chai.expect(err.name).to.equal('RosetteException'); + chai.expect(err.message).to.contain('badArgument'); + done(); + }); + }); + + it("detects targetLanguage parameter is not defined", function(done) { + var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); + + api.parameters.content = "Sample Content"; + api.parameters.targetScript = "Latn"; + api.parameters.sourceLanguage = "eng"; + api.parameters.sourceScript = "Latn"; + + api.rosette("transliteration", function(err, res) { + chai.expect(err).to.not.be.null; + chai.expect(err.name).to.equal('RosetteException'); + chai.expect(err.message).to.contain('badArgument'); + done(); + }); + }); + + it("detects targetScript parameter is not defined", function(done) { + var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); + + api.parameters.content = "Sample Content"; + api.parameters.targetLanguage = "eng"; + api.parameters.sourceLanguage = "eng"; + api.parameters.sourceScript = "Latn"; + + api.rosette("transliteration", function(err, res) { + chai.expect(err).to.not.be.null; + chai.expect(err.name).to.equal('RosetteException'); + chai.expect(err.message).to.contain('badArgument'); + done(); + }); + }); + + it("detects sourceLanguage parameter is not defined", function(done) { + var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); + + api.parameters.content = "Sample Content"; + api.parameters.targetLanguage = "eng"; + api.parameters.targetScript = "Latn"; + api.parameters.sourceScript = "Latn"; + + api.rosette("transliteration", function(err, res) { + chai.expect(err).to.not.be.null; + chai.expect(err.name).to.equal('RosetteException'); + chai.expect(err.message).to.contain('badArgument'); + done(); + }); + }); + + it("detects sourceScript parameter is not defined", function(done) { + var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); + + api.parameters.content = "Sample Content"; + api.parameters.targetLanguage = "eng"; + api.parameters.targetScript = "Latn"; + api.parameters.sourceLanguage = "eng"; + + api.rosette("transliteration", function(err, res) { + chai.expect(err).to.not.be.null; + chai.expect(err.name).to.equal('RosetteException'); + chai.expect(err.message).to.contain('badArgument'); + done(); + }); + }); + +}); + describe("Info Endpoint", function() { beforeEach(function(done) { var mockResponse = JSON.stringify({'name': 'Rosette API', 'versionChecked': true}); From a1b34a05011c247d7e6e88a4bb8ef48fb89aa505 Mon Sep 17 00:00:00 2001 From: Chris Park Date: Tue, 2 May 2017 08:55:20 -0400 Subject: [PATCH 04/10] Transliteration revision - removed check on now optional parameters - updated README - updated example - updated unit tests --- README.md | 8 ++-- examples/transliteration.js | 7 +--- lib/transliteration.js | 12 ------ tests/unittests.js | 74 ------------------------------------- 4 files changed, 5 insertions(+), 96 deletions(-) diff --git a/README.md b/README.md index e2b3b8f..7bbe406 100644 --- a/README.md +++ b/README.md @@ -45,13 +45,13 @@ api.rosette(endpoint, function(err, res){ | name2 | name similarity| Yes | | name | name translation | Yes | | names | name deduplication | Yes | -| targetLanguage | name translation, transliteration | Yes | +| targetLanguage | name translation, transliteration (No) | Yes | | entityType | name translation | No | | sourceLanguageOfOrigin | name translation | No | | sourceLanguageOfUse | name translation | No | -| sourceLanguage | transliteration | Yes | -| sourceScript | name translation, transliteration | No, transliteraion Yes | -| targetScript | name translation, transliteration | No, transliteraion Yes | +| sourceLanguage | transliteration | No | +| sourceScript | name translation, transliteration | No | +| targetScript | name translation, transliteration | No | | targetScheme | name translation | No | | options | relationships | No | | accuracyMode | relationships | Yes | diff --git a/examples/transliteration.js b/examples/transliteration.js index 1e47038..e9ca696 100644 --- a/examples/transliteration.js +++ b/examples/transliteration.js @@ -15,13 +15,8 @@ var api = new Api(args.key, args.url); var endpoint = "transliteration"; var transliteration_data = "Bill Gates, Microsoft's former CEO, is a philanthropist."; -var content = transliteration_data; -api.parameters.content = content; -api.parameters.targetLanguage = "eng"; -api.parameters.targetScript = "Latn"; -api.parameters.sourceLanguage = "eng"; -api.parameters.sourceScript = "Latn"; +api.parameters.content = transliteration_data; api.rosette(endpoint, function(err, res) { if (err) { diff --git a/lib/transliteration.js b/lib/transliteration.js index 3235271..3632d0a 100644 --- a/lib/transliteration.js +++ b/lib/transliteration.js @@ -46,18 +46,6 @@ transliteration.prototype.getResults = function(parameters, userKey, protocol, s if (parameters.loadParams().content == null) { return callback(new RosetteException("badArgument", "Must supply Content", "bad arguments")); } - if (parameters.loadParams().targetLanguage == null) { - return callback(new RosetteException("badArgument", "Must supply targetLanguage", "bad arguments")); - } - if (parameters.loadParams().targetScript == null) { - return callback(new RosetteException("badArgument", "Must supply targetScript", "bad arguments")); - } - if (parameters.loadParams().sourceLanguage == null) { - return callback(new RosetteException("badArgument", "Must supply sourceLanguage", "bad arguments")); - } - if (parameters.loadParams().sourceScript == null) { - return callback(new RosetteException("badArgument", "Must supply sourceScript", "bad arguments")); - } // configure URL var urlParts = URL.parse(serviceURL + "transliteration"); diff --git a/tests/unittests.js b/tests/unittests.js index c4c1477..acb7838 100644 --- a/tests/unittests.js +++ b/tests/unittests.js @@ -805,10 +805,6 @@ describe("Transliteration Endpoint", function() { it("successfully calls the transliteration endpoint", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); api.parameters.content = "Some Content"; - api.parameters.targetLanguage = "eng"; - api.parameters.targetScript = "Latn"; - api.parameters.sourceLanguage = "eng"; - api.parameters.sourceScript = "Latn"; api.rosette("transliteration", function(err, res) { chai.expect(err).to.be.null; @@ -821,43 +817,6 @@ describe("Transliteration Endpoint", function() { it("detects content parameter is not defined", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); - api.parameters.targetLanguage = "eng"; - api.parameters.targetScript = "Latn"; - api.parameters.sourceLanguage = "eng"; - api.parameters.sourceScript = "Latn"; - - api.rosette("transliteration", function(err, res) { - chai.expect(err).to.not.be.null; - chai.expect(err.name).to.equal('RosetteException'); - chai.expect(err.message).to.contain('badArgument'); - done(); - }); - }); - - it("detects targetLanguage parameter is not defined", function(done) { - var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); - - api.parameters.content = "Sample Content"; - api.parameters.targetScript = "Latn"; - api.parameters.sourceLanguage = "eng"; - api.parameters.sourceScript = "Latn"; - - api.rosette("transliteration", function(err, res) { - chai.expect(err).to.not.be.null; - chai.expect(err.name).to.equal('RosetteException'); - chai.expect(err.message).to.contain('badArgument'); - done(); - }); - }); - - it("detects targetScript parameter is not defined", function(done) { - var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); - - api.parameters.content = "Sample Content"; - api.parameters.targetLanguage = "eng"; - api.parameters.sourceLanguage = "eng"; - api.parameters.sourceScript = "Latn"; - api.rosette("transliteration", function(err, res) { chai.expect(err).to.not.be.null; chai.expect(err.name).to.equal('RosetteException'); @@ -866,39 +825,6 @@ describe("Transliteration Endpoint", function() { }); }); - it("detects sourceLanguage parameter is not defined", function(done) { - var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); - - api.parameters.content = "Sample Content"; - api.parameters.targetLanguage = "eng"; - api.parameters.targetScript = "Latn"; - api.parameters.sourceScript = "Latn"; - - api.rosette("transliteration", function(err, res) { - chai.expect(err).to.not.be.null; - chai.expect(err.name).to.equal('RosetteException'); - chai.expect(err.message).to.contain('badArgument'); - done(); - }); - }); - - it("detects sourceScript parameter is not defined", function(done) { - var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); - - api.parameters.content = "Sample Content"; - api.parameters.targetLanguage = "eng"; - api.parameters.targetScript = "Latn"; - api.parameters.sourceLanguage = "eng"; - - api.rosette("transliteration", function(err, res) { - chai.expect(err).to.not.be.null; - chai.expect(err.name).to.equal('RosetteException'); - chai.expect(err.message).to.contain('badArgument'); - done(); - }); - }); - -}); describe("Info Endpoint", function() { beforeEach(function(done) { From 98edd6da862ce39f6d82e032443c085739db3ae8 Mon Sep 17 00:00:00 2001 From: Chris Park Date: Tue, 2 May 2017 09:08:32 -0400 Subject: [PATCH 05/10] Fixed test bracketing --- tests/unittests.js | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/tests/unittests.js b/tests/unittests.js index acb7838..a9bd814 100644 --- a/tests/unittests.js +++ b/tests/unittests.js @@ -79,7 +79,6 @@ describe("Language Endpoint", function() { done(); }); }); - }); describe("Relationships Endpoint", function() { @@ -127,7 +126,6 @@ describe("Relationships Endpoint", function() { done(); }); }); - }); describe("Name Deduplication Endpoint", function() { @@ -178,7 +176,6 @@ describe("Name Deduplication Endpoint", function() { done(); }); }); - }); describe("Name Similarity Endpoint", function() { @@ -231,7 +228,6 @@ describe("Name Similarity Endpoint", function() { done(); }); }); - }); describe("Name Translation Endpoint", function() { @@ -294,7 +290,6 @@ describe("Name Translation Endpoint", function() { done(); }); }); - }); describe("Sentiment Endpoint", function() { @@ -353,7 +348,6 @@ describe("Sentiment Endpoint", function() { done(); }); }); - }); describe("Categories Endpoint", function() { @@ -471,7 +465,6 @@ describe("Entities Endpoint", function() { done(); }); }); - }); describe("Morphology Endpoint (suite covers all features)", function() { @@ -546,8 +539,6 @@ describe("Morphology Endpoint (suite covers all features)", function() { done(); }); }); - - }); describe("Tokens Endpoint", function() { @@ -606,7 +597,6 @@ describe("Tokens Endpoint", function() { done(); }); }); - }); describe("Sentences Endpoint", function() { @@ -665,7 +655,6 @@ describe("Sentences Endpoint", function() { done(); }); }); - }); describe("Text Embedding Endpoint", function() { @@ -719,7 +708,6 @@ describe("Text Embedding Endpoint", function() { done(); }); }); - }); describe("Syntactic Dependencies Endpoint", function() { @@ -778,7 +766,6 @@ describe("Syntactic Dependencies Endpoint", function() { done(); }); }); - }); describe("Transliteration Endpoint", function() { @@ -824,7 +811,7 @@ describe("Transliteration Endpoint", function() { done(); }); }); - +}); describe("Info Endpoint", function() { beforeEach(function(done) { @@ -854,9 +841,7 @@ describe("Info Endpoint", function() { chai.expect(res.name).to.equal('Rosette API'); done(); }); - }); - }); describe("Ping Endpoint", function() { @@ -887,7 +872,6 @@ describe("Ping Endpoint", function() { chai.expect(res.name).to.equal('Rosette API'); done(); }); - }); }); @@ -920,5 +904,4 @@ describe("Error 409 Incompatible Binding Check", function() { done(); }); }); - }); From 3af9d01cdee0bc9fb24125d0d3a345f7b9792fb9 Mon Sep 17 00:00:00 2001 From: Chris Park Date: Thu, 11 May 2017 09:58:42 -0400 Subject: [PATCH 06/10] Changed copyright date --- lib/Api.js | 4 ++-- lib/categories.js | 4 ++-- lib/entities.js | 8 ++++---- lib/info.js | 4 ++-- lib/language.js | 4 ++-- lib/morphology.js | 4 ++-- lib/nameDeduplication.js | 4 ++-- lib/nameSimilarity.js | 4 ++-- lib/nameTranslation.js | 4 ++-- lib/parameters.js | 4 ++-- lib/ping.js | 4 ++-- lib/relationships.js | 4 ++-- lib/rosetteConstants.js | 2 +- lib/rosetteExceptions.js | 2 +- lib/rosetteRequest.js | 6 +++--- lib/sentences.js | 4 ++-- lib/sentiment.js | 4 ++-- lib/syntax_dependencies.js | 10 +++++----- lib/textEmbedding.js | 4 ++-- lib/tokens.js | 4 ++-- lib/transliteration.js | 4 ++-- 21 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lib/Api.js b/lib/Api.js index f4b7104..4358efd 100644 --- a/lib/Api.js +++ b/lib/Api.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -46,7 +46,7 @@ var transliteration = require("./transliteration"); * Api server endpoints. * * @example var api = new API(userKey, serviceUrl); - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function Api(userKey, serviceURL) { diff --git a/lib/categories.js b/lib/categories.js index 08e7ab3..6071ede 100644 --- a/lib/categories.js +++ b/lib/categories.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function categories() { diff --git a/lib/entities.js b/lib/entities.js index cbd7391..64668aa 100644 --- a/lib/entities.js +++ b/lib/entities.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function entities() { @@ -50,10 +50,10 @@ entities.prototype.getResults = function(parameters, userKey, protocol, serviceU } else { // configure URL var urlParts = URL.parse(serviceURL + "entities"); - + var req = new rosetteRequest(); req.makeRequest('POST', userKey, protocol, urlParts, parameters, callback); - + } } diff --git a/lib/info.js b/lib/info.js index cd9baf3..879b328 100644 --- a/lib/info.js +++ b/lib/info.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function info() { diff --git a/lib/language.js b/lib/language.js index dcfe637..64cbf02 100644 --- a/lib/language.js +++ b/lib/language.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function language() { diff --git a/lib/morphology.js b/lib/morphology.js index de885eb..4983f1b 100644 --- a/lib/morphology.js +++ b/lib/morphology.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function morphology() { diff --git a/lib/nameDeduplication.js b/lib/nameDeduplication.js index 48cf748..3e842da 100644 --- a/lib/nameDeduplication.js +++ b/lib/nameDeduplication.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function nameDeduplication() { diff --git a/lib/nameSimilarity.js b/lib/nameSimilarity.js index 34ffd68..9e535f5 100644 --- a/lib/nameSimilarity.js +++ b/lib/nameSimilarity.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function nameSimilarity() { diff --git a/lib/nameTranslation.js b/lib/nameTranslation.js index 7c1eab1..8a89a90 100644 --- a/lib/nameTranslation.js +++ b/lib/nameTranslation.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function nameTranslation() { diff --git a/lib/parameters.js b/lib/parameters.js index a5e7ad8..5d120dd 100644 --- a/lib/parameters.js +++ b/lib/parameters.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -35,7 +35,7 @@ var BINDING_VERSION = "1.1"; /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function parameters() { diff --git a/lib/ping.js b/lib/ping.js index 5e74484..6730053 100644 --- a/lib/ping.js +++ b/lib/ping.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function ping() { diff --git a/lib/relationships.js b/lib/relationships.js index 3d660f5..7deba4b 100644 --- a/lib/relationships.js +++ b/lib/relationships.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function relationships() { diff --git a/lib/rosetteConstants.js b/lib/rosetteConstants.js index fd06ccb..c3c3fcc 100644 --- a/lib/rosetteConstants.js +++ b/lib/rosetteConstants.js @@ -1,7 +1,7 @@ /** * Container for the Rosette Constants. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at diff --git a/lib/rosetteExceptions.js b/lib/rosetteExceptions.js index 893128c..e407a88 100644 --- a/lib/rosetteExceptions.js +++ b/lib/rosetteExceptions.js @@ -1,7 +1,7 @@ /** * RosetteException. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at diff --git a/lib/rosetteRequest.js b/lib/rosetteRequest.js index 309d1ef..ccf2ef7 100644 --- a/lib/rosetteRequest.js +++ b/lib/rosetteRequest.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -33,7 +33,7 @@ var BINDING_VERSION = "1.5.0"; /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function rosetteRequest() { @@ -82,7 +82,7 @@ rosetteRequest.prototype.makeRequest = function(requestType, userKey, protocol, path: path, method: requestType, headers: headers, - agent: false + agent: false }; if (urlParts.port) { diff --git a/lib/sentences.js b/lib/sentences.js index f3d347b..c26d488 100644 --- a/lib/sentences.js +++ b/lib/sentences.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function sentences() { diff --git a/lib/sentiment.js b/lib/sentiment.js index d95ab77..e3935a3 100644 --- a/lib/sentiment.js +++ b/lib/sentiment.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function sentiment() { diff --git a/lib/syntax_dependencies.js b/lib/syntax_dependencies.js index d12feac..b6817f8 100644 --- a/lib/syntax_dependencies.js +++ b/lib/syntax_dependencies.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function syntax_dependencies() { @@ -40,7 +40,7 @@ syntax_dependencies.prototype.getResults = function(parameters, userKey, protoco if (parameters.documentFile != null) { parameters.loadFile(parameters.loadParams().documentFile, parameters, userKey, protocol, serviceURL, "syntax/dependencies", callback); - + } else { // validate parameters @@ -53,10 +53,10 @@ syntax_dependencies.prototype.getResults = function(parameters, userKey, protoco var urlParts = URL.parse(serviceURL + "syntax/dependencies"); } - + var req = new rosetteRequest(); req.makeRequest('POST', userKey, protocol, urlParts, parameters, callback); - + } }; diff --git a/lib/textEmbedding.js b/lib/textEmbedding.js index 7e44af6..505be14 100644 --- a/lib/textEmbedding.js +++ b/lib/textEmbedding.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function textEmbedding() { diff --git a/lib/tokens.js b/lib/tokens.js index 6fd0540..af40ff7 100644 --- a/lib/tokens.js +++ b/lib/tokens.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function tokens() { diff --git a/lib/transliteration.js b/lib/transliteration.js index 3632d0a..f9e9a84 100644 --- a/lib/transliteration.js +++ b/lib/transliteration.js @@ -1,7 +1,7 @@ /** * Rosette API. * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at @@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest"); /** * @class * - * @copyright 2014-2015 Basis Technology Corporation. + * @copyright 2016-2017 Basis Technology Corporation. * @license http://www.apache.org/licenses/LICENSE-2.0 */ function transliteration() { From f6f453e226d33d7fe8b1854101732dcf685b2314 Mon Sep 17 00:00:00 2001 From: Chris Park Date: Mon, 15 May 2017 09:14:30 -0400 Subject: [PATCH 07/10] Updated name_deduplication example - Uses data token of string of names - Separates string into name objects --- examples/name_deduplication.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/name_deduplication.js b/examples/name_deduplication.js index b36e20e..db98f5b 100644 --- a/examples/name_deduplication.js +++ b/examples/name_deduplication.js @@ -13,11 +13,11 @@ var args = parser.parseArgs(); var api = new Api(args.key, args.url); var endpoint = "nameDeduplication"; -api.parameters.names = [ - {"text": "John Smith", "language": "eng", "entityType": "PERSON"}, - {"text": "Johnathon Smith", "language": "eng", "entityType": "PERSON"}, - {"text": "Fred Jones Smith", "language": "eng", "entityType": "PERSON"} -]; +var name_dedupe_data = "John Smith,Johnathon Smith,Fred Jones"; + +api.parameters.names = name_dedupe_data.split(",").map(function(name) { + return {"text": name, "language": "eng", "entityType": "PERSON"} +}); api.parameters.threshold = 0.75; api.rosette(endpoint, function(err, res){ From 2b1f6f9a09eb6944e31ca1e1bcaf86f9c3e35e49 Mon Sep 17 00:00:00 2001 From: Brian Sawyer Date: Fri, 26 May 2017 10:15:15 -0400 Subject: [PATCH 08/10] WS-1138 Allow server to set default name dedeuplication threshold --- lib/nameDeduplication.js | 3 --- tests/unittests.js | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/nameDeduplication.js b/lib/nameDeduplication.js index 3e842da..707a651 100644 --- a/lib/nameDeduplication.js +++ b/lib/nameDeduplication.js @@ -41,9 +41,6 @@ nameDeduplication.prototype.getResults = function(parameters, userKey, protocol, if (parameters.documentFile != null) { return callback(new RosetteException("badArgument", "nameDeduplication does not support documentFile")); } else { - if (parameters.loadParams().threshold == null) { - parameters.threshold = 0.75; - } // validate parameters if (parameters.loadParams().names == null) { return callback(new RosetteException("badArgument", "Must supply a list of names for deduplication")); diff --git a/tests/unittests.js b/tests/unittests.js index a9bd814..78b8760 100644 --- a/tests/unittests.js +++ b/tests/unittests.js @@ -165,6 +165,22 @@ describe("Name Deduplication Endpoint", function() { done(); }); }); + + it("successfully calls the name deduplication endpoint without threshold", function(done) { + var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); + + api.parameters.names = [ + {"text": "John Smith", "language": "eng", "entityType": "PERSON"}, + {"text": "Johnathon Smith", "language": "eng", "entityType": "PERSON"}, + {"text": "Fred Jones Smith", "language": "eng", "entityType": "PERSON"} + ]; + + api.rosette("nameDeduplication", function(err, res) { + chai.expect(err).to.be.null; + chai.expect(res.name).to.equal('Rosette API'); + done(); + }); + }); it("detects missing names parameter", function(done) { var api = new Api('123456789', 'https://api.rosette.com/rest/v1'); From 63b25072e6ea0c8a2960fdfd60c085d7be74e422 Mon Sep 17 00:00:00 2001 From: Chris Park Date: Wed, 31 May 2017 14:37:53 -0400 Subject: [PATCH 09/10] Updated test versions --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f24231..93764f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,8 @@ language: node_js node_js: - - "1.0.4" - - "4.2.4" - - "4.4.7" - "6.3.0" - "7.2.0" + - "8.0.0" before_install: - npm install -g npm before_script: From e7bf87ca992ff22e3133a5c21b1bbf4fdd790cd6 Mon Sep 17 00:00:00 2001 From: Chris Park Date: Wed, 14 Jun 2017 12:54:35 +0000 Subject: [PATCH 10/10] Version 1.7.0 --- lib/rosetteRequest.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rosetteRequest.js b/lib/rosetteRequest.js index ccf2ef7..e2969ab 100644 --- a/lib/rosetteRequest.js +++ b/lib/rosetteRequest.js @@ -28,7 +28,7 @@ var querystring = require('querystring'); * * @type string */ -var BINDING_VERSION = "1.5.0"; +var BINDING_VERSION = "1.7.0"; /** * @class diff --git a/package.json b/package.json index 289286f..4b9595a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rosette-api", - "version": "1.5.0", + "version": "1.7.0", "description": "Rosette API Node.js client SDK", "main": "index", "directories": {