"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IntentsProcessor = void 0;
var object_tools_1 = require("./util/object-tools");
var IntentsProcessor = /** @class */ (function () {
    function IntentsProcessor(encoder, decoder) {
        this.encoder = encoder;
        this.decoder = decoder;
    }
    IntentsProcessor.fromDecoder = function (decoder) {
        return new IntentsProcessor(object_tools_1.flipObject(decoder), decoder);
    };
    IntentsProcessor.fromDataset = function (data) {
        var id = 0;
        var encoder = {};
        data.forEach(function (sample) {
            if (!(sample.label in encoder)) {
                encoder[sample.label] = id;
                id++;
            }
        });
        var decoder = object_tools_1.flipObject(encoder);
        return new IntentsProcessor(encoder, decoder);
    };
    Object.defineProperty(IntentsProcessor.prototype, "intentsCount", {
        get: function () {
            return Object.entries(this.encoder).length;
        },
        enumerable: false,
        configurable: true
    });
    IntentsProcessor.prototype.encode = function (intents) {
        return this.encoder[intents];
    };
    IntentsProcessor.prototype.decode = function (intentId) {
        return this.decoder[intentId];
    };
    return IntentsProcessor;
}());
exports.IntentsProcessor = IntentsProcessor;
//# sourceMappingURL=intents-processor.js.map