Files
mindfulness/client/src/features/textWrap/breakpoints/enCandidates.ts
2026-02-10 11:39:33 +08:00

23 lines
573 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { Breakpoint } from './types';
import type { Token } from '../core/types';
/**
* EN 候选断点生成(极简派)
*
* 口径:
* - tokens 仅为 WORD不包含 SPACE token
* - 候选断点只生成在 `pos ∈ [1, N-1]`
* - kind 固定为 SPACEpriority 固定为 10
*/
export function generateEnCandidates(tokens: Token[]): Breakpoint[] {
const n = tokens.length;
if (n <= 1) return [];
const out: Breakpoint[] = [];
for (let pos = 1; pos <= n - 1; pos++) {
out.push({ pos, kind: 'SPACE', priority: 10 });
}
return out;
}