SplitDocuments splits documents using a textsplitter.
(textSplitter TextSplitter, documents []schema.Document)
| 15 | |
| 16 | // SplitDocuments splits documents using a textsplitter. |
| 17 | func SplitDocuments(textSplitter TextSplitter, documents []schema.Document) ([]schema.Document, error) { |
| 18 | texts := make([]string, 0) |
| 19 | metadatas := make([]map[string]any, 0) |
| 20 | for _, document := range documents { |
| 21 | texts = append(texts, document.PageContent) |
| 22 | metadatas = append(metadatas, document.Metadata) |
| 23 | } |
| 24 | |
| 25 | return CreateDocuments(textSplitter, texts, metadatas) |
| 26 | } |
| 27 | |
| 28 | // CreateDocuments creates documents from texts and metadatas with a text splitter. If |
| 29 | // the length of the metadatas is zero, the result documents will contain no metadata. |
no test coverage detected
searching dependent graphs…