All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kotlinnlp.frameextractor.objects.Distribution.kt Maven / Gradle / Ivy

Go to download

FrameExtractor is a module for semantic frame parsing that performs intent detection and slot filling.

There is a newer version: 0.4.7
Show newest version
/* Copyright 2018-present The KotlinNLP Authors. All Rights Reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, you can obtain one at http://mozilla.org/MPL/2.0/.
 * ------------------------------------------------------------------*/

package com.kotlinnlp.frameextractor.objects

import com.beust.klaxon.JsonArray
import com.beust.klaxon.JsonObject
import com.beust.klaxon.json

/**
 * The distribution of the prediction scores used to select a class during its generation.
 *
 * @property map a map of class names associated to the related prediction scores
 */
data class Distribution(val map: Map) {

  /**
   * @return a JSON representation of this distribution
   */
  fun toJSON(): JsonArray = json {
    @Suppress("UNCHECKED_CAST")
    array(
      [email protected]
        .sortedByDescending { it.value }
        .map { obj("score" to it.value, "name" to it.key) }
    ) as JsonArray
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy