Skip to content

Commit a2a55b4

Browse files
author
Chris Park
committed
Merge branch 'develop'
2 parents 98c2be3 + e7bf87c commit a2a55b4

28 files changed

+364
-88
lines changed

.travis.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
language: node_js
22
node_js:
3-
- "0.11.16"
4-
- "0.12.7"
5-
- "1.0.4"
6-
- "4.2.4"
7-
- "4.4.7"
83
- "6.3.0"
4+
- "7.2.0"
5+
- "8.0.0"
96
before_install:
107
- npm install -g npm
118
before_script:

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,24 @@ api.rosette(endpoint, function(err, res){
3737
## API Parameters
3838
| Parameter | Endpoint | Required
3939
| ------------- |------------- |-------------
40-
| content | categories, entities, language, morphology, relationships, sentences, sentiment, tokens | Either content or contentUri required |
40+
| content | categories, entities, language, morphology, relationships, sentences, sentiment, tokens, transliteration | Either content or contentUri required, transliteration requires content only |
4141
| contentUri | categories, entities, language, morphology, relationships, sentences, sentiment, tokens | Either content or contentUri required |
4242
| language | categories, entities, language, morphology, relationships, sentences, sentiment, tokens, name similarity | No |
4343
| documentFile | categories, entities, language, morphology, relationships, sentences, sentiment, tokens | No |
4444
| name1 | name similarity | Yes |
4545
| name2 | name similarity| Yes |
4646
| name | name translation | Yes |
47-
| targetLanguage | name translation | Yes |
47+
| names | name deduplication | Yes |
48+
| targetLanguage | name translation, transliteration (No) | Yes |
4849
| entityType | name translation | No |
4950
| sourceLanguageOfOrigin | name translation | No |
5051
| sourceLanguageOfUse | name translation | No |
51-
| sourceScript | name translation | No |
52-
| targetScript | name translation | No |
52+
| sourceLanguage | transliteration | No |
53+
| sourceScript | name translation, transliteration | No |
54+
| targetScript | name translation, transliteration | No |
5355
| targetScheme | name translation | No |
5456
| options | relationships | No |
5557
| accuracyMode | relationships | Yes |
56-
| linkEntities | entities | No |
5758
| explain | sentiment | No |
5859
| morphology | morphology | Yes |
5960

examples/name_deduplication.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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: "Deduplicate a list of names"
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 = "nameDeduplication";
15+
16+
var name_dedupe_data = "John Smith,Johnathon Smith,Fred Jones";
17+
18+
api.parameters.names = name_dedupe_data.split(",").map(function(name) {
19+
return {"text": name, "language": "eng", "entityType": "PERSON"}
20+
});
21+
api.parameters.threshold = 0.75;
22+
23+
api.rosette(endpoint, function(err, res){
24+
if(err){
25+
console.log(err);
26+
} else {
27+
console.log(JSON.stringify(res, null, 2));
28+
}
29+
});

examples/syntax_dependencies.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ var endpoint = "syntax_dependencies";
1616
var syntax_dependencies_data = "Yoshinori Ohsumi, a Japanese cell biologist, was awarded the Nobel Prize in Physiology or Medicine on Monday.";
1717

1818
api.parameters.content = syntax_dependencies_data;
19-
api.parameters.genre = "social-media";
2019
api.rosette(endpoint, function(err, res){
2120
if(err){
2221
console.log(err);

examples/transliteration.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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: "Get the transliteration from 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+
14+
var api = new Api(args.key, args.url);
15+
var endpoint = "transliteration";
16+
17+
var transliteration_data = "Bill Gates, Microsoft's former CEO, is a philanthropist.";
18+
19+
api.parameters.content = transliteration_data;
20+
21+
api.rosette(endpoint, function(err, res) {
22+
if (err) {
23+
console.log(err);
24+
} else {
25+
console.log(JSON.stringify(res, null, 2));
26+
}
27+
});

lib/Api.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Rosette API.
33
*
4-
* @copyright 2014-2015 Basis Technology Corporation.
4+
* @copyright 2016-2017 Basis Technology Corporation.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
77
* with the License. You may obtain a copy of the License at
@@ -26,6 +26,7 @@ var entities = require("./entities");
2626
var info = require("./info");
2727
var language = require("./language");
2828
var matchedName = require("./nameSimilarity");
29+
var nameDeduplication = require("./nameDeduplication");
2930
var morphology = require("./morphology");
3031
var ping = require("./ping");
3132
var relationships = require("./relationships");
@@ -35,6 +36,7 @@ var textEmbedding = require("./textEmbedding");
3536
var translatedName = require("./nameTranslation");
3637
var tokens = require("./tokens");
3738
var syntax_dependencies = require("./syntax_dependencies");
39+
var transliteration = require("./transliteration");
3840

3941
/**
4042
* @class
@@ -44,7 +46,7 @@ var syntax_dependencies = require("./syntax_dependencies");
4446
* Api server endpoints.
4547
*
4648
* @example var api = new API(userKey, serviceUrl);
47-
* @copyright 2014-2015 Basis Technology Corporation.
49+
* @copyright 2016-2017 Basis Technology Corporation.
4850
* @license http://www.apache.org/licenses/LICENSE-2.0
4951
*/
5052
function Api(userKey, serviceURL) {

lib/categories.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Rosette API.
33
*
4-
* @copyright 2014-2015 Basis Technology Corporation.
4+
* @copyright 2016-2017 Basis Technology Corporation.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
77
* with the License. You may obtain a copy of the License at
@@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest");
2222
/**
2323
* @class
2424
*
25-
* @copyright 2014-2015 Basis Technology Corporation.
25+
* @copyright 2016-2017 Basis Technology Corporation.
2626
* @license http://www.apache.org/licenses/LICENSE-2.0
2727
*/
2828
function categories() {

lib/entities.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Rosette API.
33
*
4-
* @copyright 2014-2015 Basis Technology Corporation.
4+
* @copyright 2016-2017 Basis Technology Corporation.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
77
* with the License. You may obtain a copy of the License at
@@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest");
2222
/**
2323
* @class
2424
*
25-
* @copyright 2014-2015 Basis Technology Corporation.
25+
* @copyright 2016-2017 Basis Technology Corporation.
2626
* @license http://www.apache.org/licenses/LICENSE-2.0
2727
*/
2828
function entities() {
@@ -50,10 +50,10 @@ entities.prototype.getResults = function(parameters, userKey, protocol, serviceU
5050
} else {
5151
// configure URL
5252
var urlParts = URL.parse(serviceURL + "entities");
53-
53+
5454
var req = new rosetteRequest();
5555
req.makeRequest('POST', userKey, protocol, urlParts, parameters, callback);
56-
56+
5757
}
5858
}
5959

lib/info.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Rosette API.
33
*
4-
* @copyright 2014-2015 Basis Technology Corporation.
4+
* @copyright 2016-2017 Basis Technology Corporation.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
77
* with the License. You may obtain a copy of the License at
@@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest");
2222
/**
2323
* @class
2424
*
25-
* @copyright 2014-2015 Basis Technology Corporation.
25+
* @copyright 2016-2017 Basis Technology Corporation.
2626
* @license http://www.apache.org/licenses/LICENSE-2.0
2727
*/
2828
function info() {

lib/language.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Rosette API.
33
*
4-
* @copyright 2014-2015 Basis Technology Corporation.
4+
* @copyright 2016-2017 Basis Technology Corporation.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
77
* with the License. You may obtain a copy of the License at
@@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest");
2222
/**
2323
* @class
2424
*
25-
* @copyright 2014-2015 Basis Technology Corporation.
25+
* @copyright 2016-2017 Basis Technology Corporation.
2626
* @license http://www.apache.org/licenses/LICENSE-2.0
2727
*/
2828
function language() {

lib/morphology.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Rosette API.
33
*
4-
* @copyright 2014-2015 Basis Technology Corporation.
4+
* @copyright 2016-2017 Basis Technology Corporation.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
77
* with the License. You may obtain a copy of the License at
@@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest");
2222
/**
2323
* @class
2424
*
25-
* @copyright 2014-2015 Basis Technology Corporation.
25+
* @copyright 2016-2017 Basis Technology Corporation.
2626
* @license http://www.apache.org/licenses/LICENSE-2.0
2727
*/
2828
function morphology() {

lib/nameDeduplication.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* Rosette API.
3+
*
4+
* @copyright 2016-2017 Basis Technology Corporation.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
7+
* with the License. You may obtain a copy of the License at
8+
* @license http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software distributed under the License is
11+
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and limitations under the License.
13+
**/
14+
"use strict";
15+
16+
var URL = require("url");
17+
18+
var rosetteConstants = require("./rosetteConstants");
19+
var RosetteException = require("./rosetteExceptions");
20+
var rosetteRequest = require("./rosetteRequest");
21+
22+
/**
23+
* @class
24+
*
25+
* @copyright 2016-2017 Basis Technology Corporation.
26+
* @license http://www.apache.org/licenses/LICENSE-2.0
27+
*/
28+
function nameDeduplication() {
29+
30+
};
31+
32+
/**
33+
* Makes an HTTP request to the specified Rosette API endpoint and returns the result
34+
* @param {string} parameters - The Rosette API endpoint parameters
35+
* @param {string} userKey - The Rosette API user access key
36+
* @param {string} serviceURL - The base service URL to be used to access the Rosette API
37+
* @param {function} callback - Callback function to be exectuted after the function to which it is passed is complete
38+
*/
39+
nameDeduplication.prototype.getResults = function(parameters, userKey, protocol, serviceURL, callback) {
40+
41+
if (parameters.documentFile != null) {
42+
return callback(new RosetteException("badArgument", "nameDeduplication does not support documentFile"));
43+
} else {
44+
// validate parameters
45+
if (parameters.loadParams().names == null) {
46+
return callback(new RosetteException("badArgument", "Must supply a list of names for deduplication"));
47+
} else {
48+
// configure URL
49+
var urlParts = URL.parse(serviceURL + "name-deduplication");
50+
var req = new rosetteRequest();
51+
req.makeRequest('POST', userKey, protocol, urlParts, parameters, callback);
52+
}
53+
}
54+
55+
};
56+
57+
module.exports = nameDeduplication;

lib/nameSimilarity.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Rosette API.
33
*
4-
* @copyright 2014-2015 Basis Technology Corporation.
4+
* @copyright 2016-2017 Basis Technology Corporation.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
77
* with the License. You may obtain a copy of the License at
@@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest");
2222
/**
2323
* @class
2424
*
25-
* @copyright 2014-2015 Basis Technology Corporation.
25+
* @copyright 2016-2017 Basis Technology Corporation.
2626
* @license http://www.apache.org/licenses/LICENSE-2.0
2727
*/
2828
function nameSimilarity() {
@@ -39,7 +39,7 @@ function nameSimilarity() {
3939
nameSimilarity.prototype.getResults = function(parameters, userKey, protocol, serviceURL, callback) {
4040

4141
if (parameters.documentFile != null) {
42-
parameters.loadFile(parameters.documentFile, parameters, userKey, protocol, serviceURL, "name-similarity", callback);
42+
return callback(new RosetteException("badArgument", "Name similarity does not support documentFile", "bad arguments"));
4343
} else {
4444

4545
// validate parameters

lib/nameTranslation.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Rosette API.
33
*
4-
* @copyright 2014-2015 Basis Technology Corporation.
4+
* @copyright 2016-2017 Basis Technology Corporation.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
77
* with the License. You may obtain a copy of the License at
@@ -22,7 +22,7 @@ var rosetteRequest = require("./rosetteRequest");
2222
/**
2323
* @class
2424
*
25-
* @copyright 2014-2015 Basis Technology Corporation.
25+
* @copyright 2016-2017 Basis Technology Corporation.
2626
* @license http://www.apache.org/licenses/LICENSE-2.0
2727
*/
2828
function nameTranslation() {
@@ -39,12 +39,12 @@ function nameTranslation() {
3939
nameTranslation.prototype.getResults = function(parameters, userKey, protocol, serviceURL, callback) {
4040

4141
if (parameters.documentFile != null) {
42-
parameters.loadFile(parameters.documentFile, parameters, userKey, protocol, serviceURL, "name-translation", callback);
42+
return callback(new RosetteException("badArgument", "Name translation does not support documentFile", "bad arguments"));
4343
} else {
4444

4545
// validate parameters
4646
if (parameters.loadParams().name == null) {
47-
return callback(new RosetteException("badArgument", "Must name parameter", "bad arguments"));
47+
return callback(new RosetteException("badArgument", "Must supply name parameter", "bad arguments"));
4848
} else if (parameters.loadParams().targetLanguage == null) {
4949
return callback(new RosetteException("badArgument", "Must supply target language parameter", "bad arguments"));
5050
} else {

0 commit comments

Comments
 (0)