@microsoft/bf-dispatcher
Advanced tools
Comparing version 4.11.0-beta.20200818.8213b2a to 4.11.0-beta.20200821.21f8e76
import { Label } from "./Label"; | ||
import { ScoreEntity } from "./ScoreEntity"; | ||
import { ScoreIntent } from "./ScoreIntent"; | ||
export declare class LabelStructureUtility { | ||
static getJsonIntentsEntitiesUtterances(jsonObjectArray: any, hierarchicalLabel: string, utteranceLabelsMap: { | ||
[id: string]: string[]; | ||
}, utteranceLabelDuplicateMap: Map<string, Set<string>>, utteranceEntityLabelsMap: { | ||
[id: string]: Label[]; | ||
}, utteranceEntityLabelDuplicateMap: Map<string, Label[]>): boolean; | ||
static getJsonScoresUtterances(jsonObjectArray: any, utteranceLabelScoresMap: { | ||
[id: string]: ScoreIntent[]; | ||
}, utteranceEntityLabelScoresMap: { | ||
[id: string]: ScoreEntity[]; | ||
}): boolean; | ||
static insertStringPairToStringIdStringSetNativeMap(key: string, value: string, stringKeyStringSetMap: Map<string, Set<string>>): Map<string, Set<string>>; | ||
@@ -4,0 +16,0 @@ static insertStringLabelPairToStringIdLabelSetNativeMap(key: string, value: Label, stringKeyLabelSetMap: Map<string, Label[]>): Map<string, Label[]>; |
@@ -10,4 +10,69 @@ "use strict"; | ||
const LabelType_1 = require("./LabelType"); | ||
const ScoreEntity_1 = require("./ScoreEntity"); | ||
const ScoreIntent_1 = require("./ScoreIntent"); | ||
const Span_1 = require("./Span"); | ||
class LabelStructureUtility { | ||
// eslint-disable-next-line max-params | ||
static getJsonIntentsEntitiesUtterances(jsonObjectArray, hierarchicalLabel, utteranceLabelsMap, utteranceLabelDuplicateMap, utteranceEntityLabelsMap, utteranceEntityLabelDuplicateMap) { | ||
try { | ||
if (jsonObjectArray.length > 0) { | ||
jsonObjectArray.forEach((jsonObject) => { | ||
const utterance = jsonObject.text.trim(); | ||
// eslint-disable-next-line no-prototype-builtins | ||
if (jsonObject.hasOwnProperty("intents")) { | ||
const labels = jsonObject.intents; | ||
labels.forEach((label) => { | ||
LabelStructureUtility.addNewLabelUtterance(utterance, label, hierarchicalLabel, utteranceLabelsMap, utteranceLabelDuplicateMap); | ||
}); | ||
} | ||
// eslint-disable-next-line no-prototype-builtins | ||
if (jsonObject.hasOwnProperty("entities")) { | ||
const entities = jsonObject.entities; | ||
entities.forEach((entityEntry) => { | ||
LabelStructureUtility.addNewEntityLabelUtterance(utterance, entityEntry, utteranceEntityLabelsMap, utteranceEntityLabelDuplicateMap); | ||
}); | ||
} | ||
}); | ||
return true; | ||
} | ||
} | ||
catch (error) { | ||
return false; | ||
} | ||
return false; | ||
} | ||
static getJsonScoresUtterances(jsonObjectArray, utteranceLabelScoresMap, utteranceEntityLabelScoresMap) { | ||
try { | ||
if (jsonObjectArray.length > 0) { | ||
jsonObjectArray.forEach((jsonObject) => { | ||
const utterance = jsonObject.text.trim(); | ||
// eslint-disable-next-line no-prototype-builtins | ||
if (jsonObject.hasOwnProperty("intent_scores")) { | ||
const intentScores = jsonObject.intent_scores; | ||
utteranceLabelScoresMap[utterance] = intentScores.map((intentScore) => { | ||
const intent = intentScore.intent; | ||
const score = intentScore.score; | ||
return ScoreIntent_1.ScoreIntent.newScoreIntent(intent, score); | ||
}); | ||
} | ||
// eslint-disable-next-line no-prototype-builtins | ||
if (jsonObject.hasOwnProperty("entity_scores")) { | ||
const entityScores = jsonObject.entity_scores; | ||
utteranceEntityLabelScoresMap[utterance] = entityScores.map((entityScore) => { | ||
const entity = entityScore.entity; | ||
const startPos = entityScore.startPos; | ||
const endPos = entityScore.endPos; | ||
const score = entityScore.score; | ||
return ScoreEntity_1.ScoreEntity.newScoreEntityByPosition(entity, score, startPos, endPos); | ||
}); | ||
} | ||
}); | ||
return true; | ||
} | ||
} | ||
catch (error) { | ||
return false; | ||
} | ||
return false; | ||
} | ||
static insertStringPairToStringIdStringSetNativeMap(key, value, stringKeyStringSetMap) { | ||
@@ -14,0 +79,0 @@ if (!stringKeyStringSetMap) { |
@@ -7,2 +7,3 @@ import { Label } from "./Label"; | ||
constructor(label: Label, score: number, closesttext: string); | ||
equals(other: Result): boolean; | ||
toObject(): { | ||
@@ -20,2 +21,12 @@ "label": { | ||
}; | ||
toScoreEntityObject(): { | ||
"entity": string; | ||
"startPos": number; | ||
"endPos": number; | ||
"score": number; | ||
}; | ||
toScoreIntentObject(): { | ||
"intent": string; | ||
"score": number; | ||
}; | ||
} |
@@ -8,2 +8,4 @@ "use strict"; | ||
exports.Result = void 0; | ||
const LabelType_1 = require("./LabelType"); | ||
const Utility_1 = require("../utility/Utility"); | ||
class Result { | ||
@@ -15,2 +17,24 @@ constructor(label, score, closesttext) { | ||
} | ||
equals(other) { | ||
if (other) { | ||
if (this.label) { | ||
if (!this.label.equals(other.label)) { | ||
return false; | ||
} | ||
} | ||
else { | ||
if (other.label) { | ||
return false; | ||
} | ||
} | ||
if (other.score !== this.score) { | ||
return false; | ||
} | ||
if (other.closesttext !== this.closesttext) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
toObject() { | ||
@@ -23,4 +47,24 @@ return { | ||
} | ||
toScoreEntityObject() { | ||
if (this.label.labeltype !== LabelType_1.LabelType.Entity) { | ||
Utility_1.Utility.debuggingThrow(`this.label.labeltype|${this.label.labeltype}| !== LabelType.Entity|${LabelType_1.LabelType.Entity}|`); | ||
} | ||
return { | ||
entity: this.label.name, | ||
startPos: this.label.span.offset, | ||
endPos: (this.label.span.offset + this.label.span.length - 1), | ||
score: this.score, | ||
}; | ||
} | ||
toScoreIntentObject() { | ||
if (this.label.labeltype !== LabelType_1.LabelType.Intent) { | ||
Utility_1.Utility.debuggingThrow(`this.label.labeltype|${this.label.labeltype}| !== LabelType.Intent|${LabelType_1.LabelType.Intent}|`); | ||
} | ||
return { | ||
intent: this.label.name, | ||
score: this.score, | ||
}; | ||
} | ||
} | ||
exports.Result = Result; | ||
//# sourceMappingURL=Result.js.map |
@@ -77,2 +77,4 @@ "use strict"; | ||
} | ||
Utility_1.Utility.debuggingLog("micro-quantile metrics = " + confusionMatrix.getMicroQuantileMetrics()); | ||
Utility_1.Utility.debuggingLog("macro-quantile metrics = " + confusionMatrix.getMacroQuantileMetrics()); | ||
Utility_1.Utility.debuggingLog("micro-average metrics = " + confusionMatrix.getMicroAverageMetrics()); | ||
@@ -246,2 +248,4 @@ Utility_1.Utility.debuggingLog("summation-micro-average metrics = " + confusionMatrix.getSummationMicroAverageMetrics()); | ||
} | ||
Utility_1.Utility.debuggingLog("micro-quantile metrics = " + confusionMatrix.getMicroQuantileMetrics()); | ||
Utility_1.Utility.debuggingLog("macro-quantile metrics = " + confusionMatrix.getMacroQuantileMetrics()); | ||
Utility_1.Utility.debuggingLog("micro-average metrics = " + confusionMatrix.getMicroAverageMetrics()); | ||
@@ -248,0 +252,0 @@ Utility_1.Utility.debuggingLog("summation-micro-average metrics = " + confusionMatrix.getSummationMicroAverageMetrics()); |
@@ -1,1 +0,1 @@ | ||
{"version":"4.11.0-beta.20200818.8213b2a","commands":{}} | ||
{"version":"4.11.0-beta.20200821.21f8e76","commands":{}} |
{ | ||
"name": "@microsoft/bf-dispatcher", | ||
"description": "Dispatcher contains a Softmax learner initially used for auto-active-learning down-sampling and a ML confusion-matrix evaluator on intent classification models.", | ||
"version": "4.11.0-beta.20200818.8213b2a", | ||
"version": "4.11.0-beta.20200821.21f8e76", | ||
"author": "Microsoft", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/microsoft/botframework-cli/issues", |
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
1854878
345
22027