ClassificationSpec

@ApiStatus.Experimental
class ClassificationSpec : DecisionSpec

A classification: one choice question that picks a category for some text. It is a decision spec with exactly one question, so a decision service can answer it and a decision response holds its result under question.

ClassificationSpec departments = ClassificationSpec.builder()
.asking("Which team should handle this?")
.category("billing", "Payments, invoicing, refunds")
.category("technical", "Bugs, outages, integrations")
.build();

It equals any decision spec that holds the same single question, and its JSON is the decision spec JSON.

Types

Link copied to clipboard
@ApiStatus.Experimental
class Builder

Collects the instructions and categories of a classification spec. Get one from ClassificationSpec.builder. A builder is not safe for use from several threads at once.

Link copied to clipboard
object Companion

Creates classification specs.

Properties

Link copied to clipboard

The categories to choose from, in declared order. The list cannot be modified.

Link copied to clipboard

What the model is asked.

Link copied to clipboard

The one choice question. Its answer is the classification result.

Link copied to clipboard

The questions in declared order. The list cannot be modified.

Functions

Link copied to clipboard
operator override fun equals(other: Any?): Boolean
Link copied to clipboard
override fun hashCode(): Int
Link copied to clipboard
fun question(name: String): Question<*>?

Returns the question with the given name.

Link copied to clipboard
fun selected(categoryId: String, provenance: ModelProvenance, confidence: Double? = null): ClassificationResult.Selected

Returns a selection of one of this spec's categories.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard

Checks that a result fits this spec. A selection must name one of the categories. Other outcomes always fit.