orchestrator-core
Advanced tools
Comparing version 4.12.0-rc1.preview to 4.13.0-dev.20210223.19be149
@@ -118,2 +118,46 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Add batch | ||
var batch_json = ` | ||
{ | ||
"examples": | ||
[ | ||
{ | ||
"text": "Is Not Time to Be Young showing at AMC threaters", | ||
"intents": | ||
[ | ||
{ | ||
"name": "movie", | ||
"offset" : 0, | ||
"length": 0 | ||
}, | ||
{ | ||
"name": "question", | ||
"offset": 0, | ||
"length": 0 | ||
} | ||
], | ||
"entities": | ||
[ | ||
{ | ||
"name": "movie_name", | ||
"offset": 3, | ||
"length": 20 | ||
}, | ||
{ | ||
"name": "location_name", | ||
"offset": 35, | ||
"length": 13 | ||
} | ||
] | ||
} | ||
] | ||
}` | ||
var num_new_elems = labeler.addBatch(batch_json); | ||
console.log('---- Add Batch returned ' + num_new_elems) | ||
var exles = labeler.getExamples(); | ||
console.log(util.inspect(exles, true, null, true /* enable colors */)); | ||
// | ||
@@ -126,2 +170,7 @@ // Score | ||
console.log('---- Scoring Batch') | ||
var batch_text = [ 'hey', 'what is my schedule?', 'book a flight' ]; | ||
var batch_results = labeler.scoreBatch(batch_text, 1); | ||
console.log(util.inspect(batch_results, true, null, true /* enable colors */)); | ||
// | ||
@@ -128,0 +177,0 @@ // Score |
@@ -5,3 +5,3 @@ { | ||
"description": "Orchestrator for Node.js", | ||
"version": "4.12.0-rc1.preview", | ||
"version": "4.13.0-dev.20210223.19be149", | ||
"os": [ | ||
@@ -8,0 +8,0 @@ "darwin", |
@@ -8,2 +8,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved. | ||
require('fast-text-encoding'); | ||
const util = require('util') | ||
@@ -420,3 +421,74 @@ // Finds onnx model | ||
}); | ||
it('13) Add batch.', function () { | ||
// Arrange | ||
var labeler = this.orchestrator.createLabelResolver(); | ||
// Add batch | ||
var batch_json = ` | ||
{ | ||
"examples": | ||
[ | ||
{ | ||
"text": "Is Not Time to Be Young showing at AMC threaters", | ||
"intents": | ||
[ | ||
{ | ||
"name": "movie", | ||
"offset" : 0, | ||
"length": 0 | ||
}, | ||
{ | ||
"name": "question", | ||
"offset": 0, | ||
"length": 0 | ||
} | ||
], | ||
"entities": | ||
[ | ||
{ | ||
"name": "movie_name", | ||
"offset": 3, | ||
"length": 20 | ||
}, | ||
{ | ||
"name": "location_name", | ||
"offset": 35, | ||
"length": 13 | ||
} | ||
] | ||
} | ||
] | ||
}` | ||
// Test | ||
var num_new_elems = labeler.addBatch(batch_json); | ||
// Assert | ||
assert.strictEqual(num_new_elems, 1, 'Failed to add batch'); | ||
var exles = labeler.getExamples(); | ||
assert.strictEqual(exles[0].text, 'Is Not Time to Be Young showing at AMC threaters', 'text not correct'); | ||
}); | ||
it('14) Batch score.', function () { | ||
// Arrange | ||
var labeler = this.orchestrator.createLabelResolver(); | ||
const example = { | ||
label: 'travel', | ||
text: 'book a flight to miami.', | ||
}; | ||
const result = labeler.addExample(example); | ||
// Act | ||
var batch_text = [ 'hey', 'what is my schedule?', 'book a flight' ]; | ||
var batch_results = labeler.scoreBatch(batch_text, 1); | ||
// Assert | ||
// console.log(util.inspect(batch_results, true, null, true /* enable colors */)); | ||
assert.strictEqual(batch_results.length, 3, 'Not all results came back from batch score'); | ||
assert.strictEqual(batch_results[0][0].score == batch_results[1][0].score, false, 'Results should not be equal'); | ||
}); | ||
}); | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
836436
789