类 Document
java.lang.Object
dev.langchain4j.data.document.Document
Represents 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.
-
字段概要
字段修饰符和类型字段说明static final StringCommon metadata key for the absolute path of the directory from which the document was loaded.static final StringCommon metadata key for the name of the file from which the document was loaded.static final StringCommon metadata key for the URL from which the document was loaded. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static DocumentCreates a new Document from the given text.static DocumentCreates a new Document from the given text.booleanstatic DocumentCreates a new Document from the given text.static DocumentCreates a new Document from the given text.inthashCode()metadata()Returns the metadata associated with this document.已过时。text()Returns the text of this document.toString()Builds a TextSegment from this document.
-
字段详细资料
-
FILE_NAME
Common metadata key for the name of the file from which the document was loaded.- 另请参阅:
-
ABSOLUTE_DIRECTORY_PATH
Common metadata key for the absolute path of the directory from which the document was loaded.- 另请参阅:
-
URL
Common metadata key for the URL from which the document was loaded.- 另请参阅:
-
-
构造器详细资料
-
Document
Creates a new Document from the given text.The created document will have empty metadata.
- 参数:
text- the text of the document.
-
Document
Creates a new Document from the given text.- 参数:
text- the text of the document.metadata- the metadata of the document.
-
-
方法详细资料
-
text
Returns the text of this document.- 返回:
- the text.
-
metadata
Returns the metadata associated with this document.- 返回:
- the metadata.
-
metadata
已过时。as of 0.31.0, usemetadata()and thenMetadata.getString(String),Metadata.getInteger(String),Metadata.getLong(String),Metadata.getFloat(String),Metadata.getDouble(String)instead.Looks up the metadata value for the given key.- 参数:
key- the key to look up.- 返回:
- the metadata value for the given key, or null if the key is not present.
-
toTextSegment
Builds a TextSegment from this document.- 返回:
- a TextSegment.
-
equals
-
hashCode
public int hashCode() -
toString
-
from
Creates a new Document from the given text.The created document will have empty metadata.
- 参数:
text- the text of the document.- 返回:
- a new Document.
-
from
Creates a new Document from the given text.- 参数:
text- the text of the document.metadata- the metadata of the document.- 返回:
- a new Document.
-
document
Creates a new Document from the given text.The created document will have empty metadata.
- 参数:
text- the text of the document.- 返回:
- a new Document.
-
document
Creates a new Document from the given text.- 参数:
text- the text of the document.metadata- the metadata of the document.- 返回:
- a new Document.
-
metadata()and thenMetadata.getString(String),Metadata.getInteger(String),Metadata.getLong(String),Metadata.getFloat(String),Metadata.getDouble(String)instead.