Interface TextClassifier<L>

Type Parameters:
L - The type of the label (e.g., String, Enum, etc.)
All Known Implementing Classes:
EmbeddingModelTextClassifier

public interface TextClassifier<L>
Classifies a given text based on a set of labels. It can return zero, one, or multiple labels for each classification.
  • Method Details

    • classify

      default List<L> classify(String text)
      Classifies the given text.
      Parameters:
      text - Text to classify.
      Returns:
      A list of labels. Can contain zero, one, or multiple labels.
    • classify

      default List<L> classify(TextSegment textSegment)
      Classifies the given TextSegment.
      Parameters:
      textSegment - TextSegment to classify.
      Returns:
      A list of labels. Can contain zero, one, or multiple labels.
    • classify

      default List<L> classify(Document document)
      Classifies the given Document.
      Parameters:
      document - Document to classify.
      Returns:
      A list of labels. Can contain zero, one, or multiple labels.
    • classifyWithScores

      ClassificationResult<L> classifyWithScores(String text)
      Classifies the given text and returns labels with scores.
      Parameters:
      text - Text to classify.
      Returns:
      a result object containing a list of labels with corresponding scores. Can contain zero, one, or multiple labels.
    • classifyWithScores

      default ClassificationResult<L> classifyWithScores(TextSegment textSegment)
      Classifies the given TextSegment and returns labels with scores.
      Parameters:
      textSegment - TextSegment to classify.
      Returns:
      a result object containing a list of labels with corresponding scores. Can contain zero, one, or multiple labels.
    • classifyWithScores

      default ClassificationResult<L> classifyWithScores(Document document)
      Classifies the given Document and returns labels with scores.
      Parameters:
      document - Document to classify.
      Returns:
      a result object containing a list of labels with corresponding scores. Can contain zero, one, or multiple labels.