com.kotlinnlp.frameextractor.objects.Distribution.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of frameextractor Show documentation
Show all versions of frameextractor Show documentation
FrameExtractor is a module for semantic frame parsing that performs intent detection and slot filling.
/* 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