UNPKG

chonkie

Version:

🦛 CHONK your texts in TS with Chonkie!✨The no-nonsense lightweight and efficient chunking library.

54 lines • 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LateChunk = void 0; const recursive_1 = require("./recursive"); /** Class to represent the late chunk * * @class LateChunk */ class LateChunk extends recursive_1.RecursiveChunk { constructor(data) { var _a; super(data); this.embedding = (_a = data.embedding) !== null && _a !== void 0 ? _a : undefined; } /** * Return a string representation of the LateChunk * * @returns {string} The string representation of the LateChunk. */ toString() { return `LateChunk(text=${this.text}, startIndex=${this.startIndex}, endIndex=${this.endIndex}, tokenCount=${this.tokenCount}, embedding=${this.embedding})`; } /** * Return the LateChunk as a dictionary-like object * * @returns {LateChunkData} The dictionary-like object. */ toDict() { return { text: this.text, startIndex: this.startIndex, endIndex: this.endIndex, tokenCount: this.tokenCount, embedding: this.embedding, }; } /** * Create a LateChunk object from a dictionary-like object. * * @param {LateChunkData} data - The dictionary-like object. * @returns {LateChunk} The LateChunk object. */ static fromDict(data) { return new LateChunk({ text: data.text, startIndex: data.startIndex, endIndex: data.endIndex, tokenCount: data.tokenCount, embedding: data.embedding, }); } } exports.LateChunk = LateChunk; //# sourceMappingURL=late.js.map