Enum Class SplitStrategy

java.lang.Object
java.lang.Enum<SplitStrategy>
io.agentscope.core.rag.reader.SplitStrategy
All Implemented Interfaces:
Serializable, Comparable<SplitStrategy>, Constable

public enum SplitStrategy extends Enum<SplitStrategy>
Strategy for splitting text into chunks.

Different strategies are suitable for different types of content:

  • CHARACTER: Split by character count (simple, fast, may break words)
  • PARAGRAPH: Split by paragraphs (preserves semantic units)
  • TOKEN: Split by token count (approximates LLM token limits)
  • SEMANTIC: Split by semantic boundaries (requires NLP, not yet implemented)
  • Enum Constant Details

    • CHARACTER

      public static final SplitStrategy CHARACTER
      Split text by character count.

      This is the simplest strategy - it splits text into fixed-size chunks based on character count. May break words in the middle.

    • PARAGRAPH

      public static final SplitStrategy PARAGRAPH
      Split text by paragraphs.

      This strategy splits text at paragraph boundaries (double newlines), preserving semantic units. Chunks may vary in size.

    • TOKEN

      public static final SplitStrategy TOKEN
      Split text by token count (approximate).

      This strategy attempts to split text based on approximate token count, which is useful for LLM context limits. Uses a simple heuristic: ~4 characters per token.

    • SEMANTIC

      public static final SplitStrategy SEMANTIC
      Split text by semantic boundaries.

      This strategy would split text at semantic boundaries (sentences, clauses, etc.) to preserve meaning. Currently not implemented and falls back to PARAGRAPH strategy.

  • Method Details

    • values

      public static SplitStrategy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static SplitStrategy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null