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 Jun 14, 2017
2 parents 98c2be3 + e7bf87c commit a2a55b4
Show file tree
Hide file tree
Showing 28 changed files with 364 additions and 88 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
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"
- "8.0.0"
before_install:
- npm install -g npm
before_script:
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 (No) | Yes |
| entityType | name translation | No |
| sourceLanguageOfOrigin | name translation | No |
| sourceLanguageOfUse | name translation | No |
| sourceScript | name translation | No |
| targetScript | name translation | No |
| sourceLanguage | transliteration | No |
| sourceScript | name translation, transliteration | No |
| targetScript | name translation, transliteration | No |
| targetScheme | name translation | No |
| options | relationships | No |
| accuracyMode | relationships | Yes |
| linkEntities | entities | No |
| explain | sentiment | No |
| morphology | morphology | Yes |

Expand Down
29 changes: 29 additions & 0 deletions examples/name_deduplication.js
Original file line number Diff line number Diff line change
@@ -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";

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){
if(err){
console.log(err);
} else {
console.log(JSON.stringify(res, null, 2));
}
});
1 change: 0 additions & 1 deletion examples/syntax_dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
27 changes: 27 additions & 0 deletions examples/transliteration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"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.";

api.parameters.content = transliteration_data;

api.rosette(endpoint, function(err, res) {
if (err) {
console.log(err);
} else {
console.log(JSON.stringify(res, null, 2));
}
});
6 changes: 4 additions & 2 deletions lib/Api.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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");
Expand All @@ -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
Expand All @@ -44,7 +46,7 @@ var syntax_dependencies = require("./syntax_dependencies");
* 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) {
Expand Down
4 changes: 2 additions & 2 deletions lib/categories.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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() {
Expand Down
8 changes: 4 additions & 4 deletions lib/entities.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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);

}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/info.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions lib/language.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions lib/morphology.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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() {
Expand Down
57 changes: 57 additions & 0 deletions lib/nameDeduplication.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Rosette API.
*
* @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
* @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 2016-2017 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 {
// 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;
6 changes: 3 additions & 3 deletions lib/nameSimilarity.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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() {
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/nameTranslation.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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() {
Expand All @@ -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 {
Expand Down
Loading

0 comments on commit a2a55b4

Please sign in to comment.