Class Document
-
- All Implemented Interfaces:
public class DocumentRepresents an unstructured piece of text that usually corresponds to a content of a single file. This text could originate from various sources such as a text file, PDF, DOCX, or a web page (HTML). Each document may have associated metadata including its source, owner, creation date, etc.
-
-
Method Summary
Modifier and Type Method Description Stringtext()Returns the text of this document. Metadatametadata()Returns the metadata associated with this document. Stringmetadata(String key)Looks up the metadata value for the given key. TextSegmenttoTextSegment()Builds a TextSegment from this document. booleanequals(Object o)inthashCode()StringtoString()static Documentfrom(String text)Creates a new Document from the given text. static Documentfrom(String text, Metadata metadata)Creates a new Document from the given text. static Documentdocument(String text)Creates a new Document from the given text. static Documentdocument(String text, Metadata metadata)Creates a new Document from the given text. -
-
Constructor Detail
-
Document
Document(String text)
Creates a new Document from the given text.- Parameters:
text- the text of the document.
-
-
Method Detail
-
metadata
Metadata metadata()
Returns the metadata associated with this document.
- Returns:
the metadata.
-
metadata
@Deprecated(forRemoval = true) String metadata(String key)
Looks up the metadata value for the given key.
- Parameters:
key- the key to look up.- Returns:
the metadata value for the given key, or null if the key is not present.
-
toTextSegment
TextSegment toTextSegment()
Builds a TextSegment from this document.
- Returns:
a TextSegment.
-
hashCode
int hashCode()
-
from
static Document from(String text)
Creates a new Document from the given text.
The created document will have empty metadata.
- Parameters:
text- the text of the document.- Returns:
a new Document.
-
from
static Document from(String text, Metadata metadata)
Creates a new Document from the given text.
- Parameters:
text- the text of the document.metadata- the metadata of the document.- Returns:
a new Document.
-
document
static Document document(String text)
Creates a new Document from the given text.
The created document will have empty metadata.
- Parameters:
text- the text of the document.- Returns:
a new Document.
-
-
-
-