| 586 | 586 | const delimiters = getChunkDelimiters(); |
| 587 | 587 | // Overlap should not be included in chunk size. It will be later compensated by overlapChunks |
| 588 | 588 | chunkSize = overlapSize > 0 ? (chunkSize - overlapSize) : chunkSize; |
| 589 | + const applyOverlap = (x, y, z) => overlapSize > 0 ? overlapChunks(x, y, z, overlapSize) : x; |
| 589 | 590 | const chunks = settings.only_custom_boundary && settings.force_chunk_delimiter |
| 590 | 591 | ? fileText.split(settings.force_chunk_delimiter).map(applyOverlap) |
| 591 | | - : splitRecursive(fileText, chunkSize, delimiters).map((x, y, z) => overlapSize > 0 ? overlapChunks(x, y, z, overlapSize) : x); |
| 592 | + : splitRecursive(fileText, chunkSize, delimiters).map(applyOverlap); |
| 592 | 593 | console.debug(`Vectors: Split file ${fileName} into ${chunks.length} chunks with ${overlapPercent}% overlap`, chunks); |
| 593 | 594 | |
| 594 | 595 | const items = chunks.map((chunk, index) => ({ hash: getStringHash(chunk), text: chunk, index: index })); |