Skip to content

Commit cf2d7ca

Browse files
DEVOPS-247: support address-similarity
1 parent 22f6232 commit cf2d7ca

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

lib/Api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var rosetteConstants = require("./rosetteConstants");
2121
var RosetteException = require("./rosetteExceptions");
2222
var paramObj = require("./parameters");
2323

24+
var addressSimilarity = require("./addressSimilarity")
2425
var categories = require("./categories");
2526
var entities = require("./entities");
2627
var info = require("./info");

lib/addressSimilarity.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Rosette API.
3+
*
4+
* @copyright 2016-2018 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-2018 Basis Technology Corporation.
26+
* @license http://www.apache.org/licenses/LICENSE-2.0
27+
*/
28+
function addressSimilarity() {
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+
addressSimilarity.prototype.getResults = function(parameters, userKey, protocol, serviceURL, callback) {
40+
41+
if (parameters.documentFile != null) {
42+
return callback(new RosetteException("badArgument", "Address similarity does not support documentFile", "bad arguments"));
43+
} else {
44+
// validate parameters
45+
if (!parameters.loadParams().address1 || !parameters.loadParams().address2) {
46+
return callback(new RosetteException("badArgument", "Must supply both address1 and address2 parameters to be matched."));
47+
} else {
48+
// configure URL
49+
var urlParts = URL.parse(serviceURL + "address-similarity");
50+
var req = new rosetteRequest();
51+
req.makeRequest('POST', userKey, protocol, urlParts, parameters, callback);
52+
}
53+
}
54+
};
55+
56+
module.exports = addressSimilarity;

lib/parameters.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ function parameters() {
4848
this.genre = null;
4949
this.options = null;
5050

51+
// address similarity parameters
52+
this.address1 = null;
53+
this.address2 = null;
54+
5155
// name matching parameters
5256
this.name1 = null;
5357
this.name2 = null;

0 commit comments

Comments
 (0)