UNPKG

chonkie

Version:

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

46 lines (45 loc) • 1.74 kB
import { Sentence, SentenceData } from './sentence'; import { SentenceChunk } from './sentence'; /** * Represents a semantic sentence with metadata, including an embedding. * Extends the base Sentence class. */ export interface SemanticSentenceData extends SentenceData { embedding?: number[] | null; } export declare class SemanticSentence extends Sentence { /** The embedding vector for the sentence (array of numbers, or null if not present) */ embedding: number[] | null; constructor(data: SemanticSentenceData); /** Return the SemanticSentence as a dictionary-like object */ toDict(): SemanticSentenceData; /** Create a SemanticSentence object from a dictionary */ static fromDict(data: SemanticSentenceData): SemanticSentence; /** Return a string representation of the SemanticSentence */ toString(): string; } /** * Represents a semantic chunk with metadata, including a list of semantic sentences. * Extends the base SentenceChunk class. */ export interface SemanticChunkData { text: string; startIndex: number; endIndex: number; tokenCount: number; sentences: SemanticSentenceData[]; embedding?: number[]; } export declare class SemanticChunk extends SentenceChunk { /** List of SemanticSentence objects in the chunk */ sentences: SemanticSentence[]; constructor(data: SemanticChunkData & { sentences: SemanticSentence[]; }); /** Return the SemanticChunk as a dictionary-like object */ toDict(): SemanticChunkData; /** Create a SemanticChunk object from a dictionary */ static fromDict(data: SemanticChunkData): SemanticChunk; /** Return a string representation of the SemanticChunk */ toString(): string; }