Package dev.langchain4j.classification
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 Summary
Modifier and TypeMethodDescriptionClassifies the givenDocument
.classify
(TextSegment textSegment) Classifies the givenTextSegment
.Classifies the given text.default ClassificationResult
<L> classifyWithScores
(Document document) Classifies the givenDocument
and returns labels with scores.default ClassificationResult
<L> classifyWithScores
(TextSegment textSegment) Classifies the givenTextSegment
and returns labels with scores.classifyWithScores
(String text) Classifies the given text and returns labels with scores.
-
Method Details
-
classify
Classifies the given text.- Parameters:
text
- Text to classify.- Returns:
- A list of labels. Can contain zero, one, or multiple labels.
-
classify
Classifies the givenTextSegment
.- Parameters:
textSegment
-TextSegment
to classify.- Returns:
- A list of labels. Can contain zero, one, or multiple labels.
-
classify
Classifies the givenDocument
.- Parameters:
document
-Document
to classify.- Returns:
- A list of labels. Can contain zero, one, or multiple labels.
-
classifyWithScores
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
Classifies the givenTextSegment
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
Classifies the givenDocument
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.
-