|
1 | | -/** |
2 | | - * Rosette API. |
3 | | - * |
4 | | - * @copyright 2014-2015 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 2014-2015 Basis Technology Corporation. |
26 | | - * @license http://www.apache.org/licenses/LICENSE-2.0 |
27 | | - */ |
28 | | -function nameSimilarity() { |
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 | | -nameSimilarity.prototype.getResults = function(parameters, userKey, serviceURL, callback) { |
40 | | - |
41 | | - if (parameters.loadParams().documentFile != null) { |
42 | | - parameters.loadFile(parameters.loadParams().documentFile, parameters, userKey, serviceURL, "name-similarity", callback); |
43 | | - } else { |
44 | | - |
45 | | - // validate parameters |
46 | | - if (parameters.loadParams().name1 == null || parameters.loadParams().name2 == null) { |
47 | | - return callback( new RosetteException("badArgument", "Must supply both name1 and name2 parameters to be matched.")); |
48 | | - } else { |
49 | | - // configure URL |
50 | | - var urlParts = URL.parse(serviceURL + "name-similarity"); |
51 | | - var req = new rosetteRequest(); |
52 | | - req.makeRequest('POST', userKey, urlParts, parameters, callback); |
53 | | - } |
54 | | - } |
55 | | - |
56 | | -}; |
57 | | - |
58 | | -module.exports = nameSimilarity; |
| 1 | +/** |
| 2 | + * Rosette API. |
| 3 | + * |
| 4 | + * @copyright 2014-2015 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 2014-2015 Basis Technology Corporation. |
| 26 | + * @license http://www.apache.org/licenses/LICENSE-2.0 |
| 27 | + */ |
| 28 | +function nameSimilarity() { |
| 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 | +nameSimilarity.prototype.getResults = function(parameters, userKey, serviceURL, callback) { |
| 40 | + |
| 41 | + if (parameters.loadParams().documentFile != null) { |
| 42 | + parameters.loadFile(parameters.loadParams().documentFile, parameters, userKey, serviceURL, "name-similarity", callback); |
| 43 | + } else { |
| 44 | + |
| 45 | + // validate parameters |
| 46 | + if (parameters.loadParams().name1 == null || parameters.loadParams().name2 == null) { |
| 47 | + return callback(new RosetteException("badArgument", "Must supply both name1 and name2 parameters to be matched.")); |
| 48 | + } else { |
| 49 | + // configure URL |
| 50 | + var urlParts = URL.parse(serviceURL + "name-similarity"); |
| 51 | + var req = new rosetteRequest(); |
| 52 | + req.makeRequest('POST', userKey, urlParts, parameters, callback); |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | +}; |
| 57 | + |
| 58 | +module.exports = nameSimilarity; |
0 commit comments