Skip to content

Commit 4e22a8e

Browse files
committed
Unified entities and entities/linked
1 parent fac2d38 commit 4e22a8e

File tree

7 files changed

+10
-107
lines changed

7 files changed

+10
-107
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ api.rosette(endpoint, function(err, res){
4444
| targetScheme | name translation | No |
4545
| options | relationships | No |
4646
| accuracyMode | relationships | Yes |
47-
| linked | entities | No |
47+
| linkEntities | entities | No |
4848
| explain | sentiment | No |
4949
| morphology | morphology | Yes |
5050

examples/entities.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ var api = new Api(args.key, args.url);
1515
var endpoint = "entities";
1616

1717
api.parameters.content = "Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS";
18-
18+
api.parameters.genre = "social-media";
19+
// to improve performance, and if you don't need the QID, set this option
20+
// api.parameters.options = { "linkEntities": false };
1921
api.rosette(endpoint, function(err, res){
2022
if(err){
2123
console.log(err);

examples/entities_linked.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

lib/entities.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,8 @@ function entities() {
3939
entities.prototype.getResults = function(parameters, userKey, serviceURL, callback) {
4040

4141
if (parameters.loadParams().documentFile != null) {
42-
if (parameters.loadParams().linked == true) {
43-
parameters.loadFile(parameters.loadParams().documentFile, parameters, userKey, serviceURL, "entities/linked", callback);
44-
} else {
45-
parameters.loadFile(parameters.loadParams().documentFile, parameters, userKey, serviceURL, "entities", callback);
46-
}
47-
42+
parameters.loadFile(parameters.loadParams().documentFile, parameters, userKey, serviceURL, "entities", callback);
43+
4844
} else {
4945

5046
// validate parameters
@@ -54,11 +50,8 @@ entities.prototype.getResults = function(parameters, userKey, serviceURL, callba
5450
return callback(new RosetteException("badArgument", "Cannot supply both Content and ContentUri", "bad arguments"));
5551
} else {
5652
// configure URL
57-
if (parameters.loadParams().linked == true) {
58-
var urlParts = URL.parse(serviceURL + "entities/linked");
59-
} else {
60-
urlParts = URL.parse(serviceURL + "entities");
61-
}
53+
var urlParts = URL.parse(serviceURL + "entities");
54+
6255
var req = new rosetteRequest();
6356
req.makeRequest('POST', userKey, urlParts, parameters, callback);
6457
}

lib/parameters.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ function parameters() {
6363
this.options = null;
6464
this.accuracyMode = null;
6565

66-
//entities parameters
67-
this.linked = null;
68-
6966
//sentiment parameters
7067
this.explain = null;
7168
this.shortString = null;
@@ -101,7 +98,6 @@ parameters.prototype.loadParams = function() {
10198
"targetScript": this.targetScript,
10299
"targetScheme": this.targetScheme,
103100
"options": this.options,
104-
"linked": this.linked,
105101
"explain": this.explain,
106102
"short-string": this.shortString,
107103
"morphology": this.morphology,

lib/rosetteRequest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ rosetteRequest.prototype.makeRequest = function(requestType, userKey, urlParts,
7575
headers["X-RosetteAPI-Key"] = userKey;
7676
}
7777

78-
if(parameters.customHeaders != null){
79-
parameters.customHeaders.forEach( function(element, index) {
78+
if (parameters.customHeaders != null) {
79+
parameters.customHeaders.forEach(function(element, index) {
8080
headers[element[0]] = element[1];
8181
});
8282

tests/unittests.js

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -421,68 +421,6 @@ describe("Entities Endpoint", function() {
421421

422422
});
423423

424-
describe("Entities Linked Endpoint", function() {
425-
beforeEach(function(done) {
426-
var mockResponse = JSON.stringify({'name':'Rosette API', 'versionChecked':true});
427-
428-
nock('https://api.rosette.com', {"encodedQueryParams": true })
429-
.post('/rest/v1/info')
430-
.query({"clientVersion":"1.1"})
431-
.reply(200, JSON.parse(mockResponse));
432-
433-
nock('https://api.rosette.com', {"encodedQueryParams": true })
434-
.post('/rest/v1/entities/linked')
435-
.query({"clientVersion":"1.1"})
436-
.reply(200, JSON.parse(mockResponse));
437-
done();
438-
});
439-
440-
afterEach(function(done) {
441-
nock.cleanAll();
442-
done();
443-
});
444-
445-
it("successfully calls the entities linked endpoint", function(done) {
446-
var api = new Api('123456789', 'https://api.rosette.com/rest/v1');
447-
api.parameters.content = "Some Content";
448-
api.parameters.linked = true;
449-
450-
api.rosette("entities", function(err, res) {
451-
chai.expect(err).to.be.null;
452-
chai.expect(res.name).to.equal('Rosette API');
453-
done();
454-
});
455-
456-
});
457-
458-
it("detects content and contentUri are defined", function(done) {
459-
var api = new Api('123456789', 'https://api.rosette.com/rest/v1');
460-
api.parameters.content = "Sample Content";
461-
api.parameters.contentUri = "http://some.url.com";
462-
api.parameters.linked = true;
463-
464-
api.rosette("entities", function(err, res) {
465-
chai.expect(err).to.not.be.null;
466-
chai.expect(err.name).to.equal('RosetteException');
467-
chai.expect(err.message).to.contain('badArgument');
468-
done();
469-
});
470-
});
471-
472-
it("detects neither content nor contentUri are defined", function(done) {
473-
var api = new Api('123456789', 'https://api.rosette.com/rest/v1');
474-
api.parameters.linked = true;
475-
476-
api.rosette("entities", function(err, res) {
477-
chai.expect(err).to.not.be.null;
478-
chai.expect(err.name).to.equal('RosetteException');
479-
chai.expect(err.message).to.contain('badArgument');
480-
done();
481-
});
482-
});
483-
484-
});
485-
486424
describe("Morphology Endpoint (suite covers all features)", function() {
487425
beforeEach(function(done) {
488426
var mockResponse = JSON.stringify({'name':'Rosette API', 'versionChecked':true});

0 commit comments

Comments
 (0)