langchain_community.document_loaders.email
.UnstructuredEmailLoader¶
- class langchain_community.document_loaders.email.UnstructuredEmailLoader(file_path: Union[str, Path], mode: str = 'single', **unstructured_kwargs: Any)[source]¶
使用`Unstructured`加载电子邮件文件。
适用于`.eml`和`.msg`文件。您可以通过将`process_attachments=True`传递给加载器的构造函数,处理附件以及电子邮件消息本身。默认情况下,附件将使用非结构化分区函数进行处理。如果您已经知道附件的文档类型,可以使用`attachment partitioner`关键字参数指定另一个分区函数。
```python from langchain_community.document_loaders import UnstructuredEmailLoader
loader = UnstructuredEmailLoader(“example_data/fake-email.eml”, mode=”elements”) loader.load() ```
```python from langchain_community.document_loaders import UnstructuredEmailLoader
- loader = UnstructuredEmailLoader(
“example_data/fake-email-attachment.eml”, mode=”elements”, process_attachments=True,
使用文件路径进行初始化。
Methods
__init__
(file_path[, mode])使用文件路径进行初始化。
一个用于文档的惰性加载器。
aload
()将数据加载到文档对象中。
加载文件。
load
()将数据加载到文档对象中。
load_and_split
([text_splitter])加载文档并分割成块。块作为文档返回。
- Parameters
file_path (Union[str, Path]) –
mode (str) –
unstructured_kwargs (Any) –
- __init__(file_path: Union[str, Path], mode: str = 'single', **unstructured_kwargs: Any)[source]¶
使用文件路径进行初始化。
- Parameters
file_path (Union[str, Path]) –
mode (str) –
unstructured_kwargs (Any) –
- load_and_split(text_splitter: Optional[TextSplitter] = None) List[Document] ¶
加载文档并分割成块。块作为文档返回。
不要覆盖此方法。应该被视为已弃用!
- 参数:
- text_splitter: 用于分割文档的TextSplitter实例。
默认为RecursiveCharacterTextSplitter。
- 返回:
文档列表。
- Parameters
text_splitter (Optional[TextSplitter]) –
- Return type
List[Document]