Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port: Prevent duplicate None labels from being added twice #3952

Merged
merged 2 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ export class OrchestratorRecognizer extends AdaptiveRecognizer implements Orches

// if top scoring intent is less than threshold, return None
if (topScore < this.unknownIntentFilterScore) {
// add all scores
recognizerResult.intents = results.reduce(function (
intents: { [index: string]: { score: number } },
result
) {
intents[result.label.name] = { score: result.score };
return intents;
},
{});

recognizerResult.intents.None = { score: 1.0 };
} else {
// add all scores
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,42 @@ describe('OrchestratorAdpativeRecognizer tests', function () {
});
});

it('Test none intent recognition', async function () {
const result = [
{
score: 0.3,
label: {
name: 'mockLabel',
},
},
{
score: 0.8,
label: {
name: 'None',
},
},
{
score: 0.6,
label: {
name: 'mockLabel2',
},
},
];
const mockResolver = new MockResolver(result);
const testPaths = 'test';
const rec = new OrchestratorRecognizer(testPaths, testPaths, mockResolver);
rec.modelFolder = new StringExpression(testPaths);
rec.snapshotFile = new StringExpression(testPaths);
const { dc, activity } = createTestDcAndActivity('hey hey');

const res = await rec.recognize(dc, activity);
strictEqual(res.text, 'hey hey');
strictEqual(Object.keys(res.intents).length, 3);
strictEqual(res.intents.mockLabel.score, 0.3);
strictEqual(res.intents.mockLabel2.score, 0.6);
strictEqual(res.intents.None.score, 1.0);
});

it('Test intent recognition', async function () {
const result = [
{
Expand Down