-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
364 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.