Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]
/**
* Text chunking — core/ version.
*
* The actual chunking logic is provided by the framework runtime
* (`runtime.channel.text.chunkMarkdownText`). This module exposes a
* registerable adapter so core/ modules can call `chunkText()` without
* importing the plugin-sdk runtime store.
*/
/** Maximum text length for a single QQ Bot message. */
export const TEXT_CHUNK_LIMIT = 5000;
/** Text chunker function signature. */
export type ChunkTextFn = (text: string, limit: number) => string[];
let _chunkText: ChunkTextFn | null = null;
/** Register the text chunker — called by the outer-layer startup. */
export function registerTextChunker(fn: ChunkTextFn): void {
_chunkText = fn;
}
/**
* Markdown-aware text chunking.
*
* Delegates to the registered chunker (framework runtime).
* Falls back to a naive split when no chunker is registered.
*/
export function chunkText(text: string, limit: number = TEXT_CHUNK_LIMIT): string[] {
if (_chunkText) {
return _chunkText(text, limit);
}
// Naive fallback: split by limit without markdown awareness.
const chunks: string[] = [];
for (let i = 0; i < text.length; i += limit) {
chunks.push(text.slice(i, i + limit));
}
return chunks.length > 0 ? chunks : [text];
}
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-04-27)
¤
*© Formatika GbR, Deutschland