Skip to content

Commit

Permalink
better documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fibii committed Dec 26, 2024
1 parent a4385a9 commit bb1b499
Showing 1 changed file with 30 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,38 @@ hide_table_of_contents: true

# Docx files

This example goes over how to load data from docx files.
The `DocxLoader` allows you to extract text data from Microsoft Word documents. It supports both the modern `.docx` format and the legacy `.doc` format. Depending on the file type, additional dependencies are required.

# Setup
---

## Setup

To use `DocxLoader`, you'll need the `@langchain/community` integration along with either `mammoth` or `word-extractor` package:

- **`mammoth`**: For processing `.docx` files.
- **`word-extractor`**: For handling `.doc` files.

### Installation

#### For `.docx` Files

```bash npm2yarn
npm install @langchain/community @langchain/core mammoth
```

# Usage
#### For `.doc` Files

```bash npm2yarn
npm install @langchain/community @langchain/core word-extractor
```

## Usage

```typescript
### Loading `.docx` Files

For `.docx` files, there is no need to explicitly specify any parameters when initializing the loader:

```javascript
import { DocxLoader } from "@langchain/community/document_loaders/fs/docx";

const loader = new DocxLoader(
Expand All @@ -24,27 +45,19 @@ const loader = new DocxLoader(
const docs = await loader.load();
```

### Loading `.doc` Files

# Doc files

This example goes over how to load data from doc files.

# Setup

```bash npm2yarn
npm install @langchain/community @langchain/core word-extractor
```
For `.doc` files, you must explicitly specify the `type` as `doc` when initializing the loader:

# Usage

```typescript
```javascript
import { DocxLoader } from "@langchain/community/document_loaders/fs/docx";

const loader = new DocxLoader(
"src/document_loaders/tests/example_data/attentio.docx",
"src/document_loaders/tests/example_data/attention.doc",
{
type: "doc",
}
);

const docs = await loader.load();
```

0 comments on commit bb1b499

Please sign in to comment.