Member Junction
    Preparing search index...

    Splits text toward a target size, closing on the best available natural boundary near that target rather than cutting at a fixed offset.

    A fixed window cuts wherever the budget runs out, which routinely lands mid-paragraph — the chunk then straddles two ideas and matches neither query well. This segmenter treats the target as a goal with a tolerance band and escalates through boundary quality as it goes:

    1. Once within UndershootPercent of target, close on a paragraph break.
    2. Past target, accept a sentence break.
    3. Past OvershootPercent, accept a word break.
    4. Failing all of those, cut at the hard MaxSegmentTokens ceiling.

    Segment sizes therefore vary — deliberately. A slightly short segment that ends at a paragraph is worth more at retrieval time than an exactly-sized one that ends mid-clause.

    It also declines to split at all when the whole text is only modestly over target (NoSplitPercent), which avoids the common pathology of one full-size chunk followed by a runt carrying two sentences and no context.

    This is the recommended default for prose when document structure isn't available; prefer StructuralText when the content has headings, since an authored boundary beats an inferred one.

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get Key(): string

      The registration key for this segmenter. Must match the key passed to @RegisterClass so metadata-driven resolution round-trips.

      Returns string

    Methods

    • Estimated tokens for a string — exposed for callers reasoning about sizing.

      Parameters

      • text: string

      Returns number

    • Resolve a registered segmenter by key via the MJ class factory. Returns null when no segmenter is registered under that key.

      Uses TryCreateInstance rather than CreateInstance deliberately: the latter never returns null for an unregistered key — it falls back to new BaseSegmenter(), a hollow object whose abstract Key/SegmentCore are undefined. That failure stays invisible until something calls it, so an unresolvable key must be reported as such here.

      Parameters

      • key: string

      Returns BaseSegmenter