Package dev.langchain4j.data.segment
Interface TextSegmentTransformer
public interface TextSegmentTransformer
Defines the interface for transforming a
TextSegment
.
Implementations can perform a variety of tasks such as transforming, filtering, enriching, etc.-
Method Summary
Modifier and TypeMethodDescriptiontransform
(TextSegment segment) Transforms a provided segment.default List
<TextSegment> transformAll
(List<TextSegment> segments) Transforms all the provided segments.
-
Method Details
-
transform
Transforms a provided segment.- Parameters:
segment
- The segment to be transformed.- Returns:
- The transformed segment, or null if the segment should be filtered out.
-
transformAll
Transforms all the provided segments.- Parameters:
segments
- A list of segments to be transformed.- Returns:
- A list of transformed segments. The length of this list may be shorter or longer than the original list. Returns an empty list if all segments were filtered out.
-