Class TextSegment
java.lang.Object
dev.langchain4j.data.segment.TextSegment
Represents a semantically meaningful segment (chunk/piece/fragment) of a larger entity such as a document or chat conversation.
This might be a sentence, a paragraph, or any other discrete unit of text that carries meaning.
This class encapsulates a piece of text and its associated metadata.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic TextSegmentCreates a new text segment.static TextSegmentCreates a new text segment.inthashCode()metadata()Returns the metadata.text()Returns the text.static TextSegmenttextSegment(String text) Creates a new text segment.static TextSegmenttextSegment(String text, Metadata metadata) Creates a new text segment.toString()
-
Constructor Details
-
TextSegment
-
-
Method Details
-
text
-
metadata
-
equals
-
hashCode
-
toString
-
from
Creates a new text segment.- Parameters:
text- the text.- Returns:
- the text segment.
-
from
Creates a new text segment.- Parameters:
text- the text.metadata- the metadata.- Returns:
- the text segment.
-
textSegment
Creates a new text segment.- Parameters:
text- the text.- Returns:
- the text segment.
-
textSegment
Creates a new text segment.- Parameters:
text- the text.metadata- the metadata.- Returns:
- the text segment.
-