Package dev.langchain4j.data.segment
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 TypeMethodDescriptionboolean
static TextSegment
Creates a new text segment.static TextSegment
Creates a new text segment.int
hashCode()
metadata()
Returns the metadata.text()
Returns the text.static TextSegment
textSegment
(String text) Creates a new text segment.static TextSegment
textSegment
(String text, Metadata metadata) Creates a new text segment.toString()
-
Constructor Details
-
TextSegment
Creates a new text segment.- Parameters:
text
- the text.metadata
- the metadata.
-
-
Method Details
-
text
Returns the text.- Returns:
- the text.
-
metadata
Returns the metadata.- Returns:
- the metadata.
-
equals
-
hashCode
public int 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.
-