Class MibChunkFormatter
java.lang.Object
org.snmp4j.mcp.tool.mib.semantic.MibChunkFormatter
Converts a
SmiObject into one or more plain-text chunks suitable for embedding.
Uses the object's DESCRIPTION text. Short descriptions (≤ DEFAULT_MAX_WORDS
words) are returned as a single chunk. Longer descriptions are split into paragraph-aligned
chunks, each below the word limit, with a sliding overlap between consecutive chunks so that
relevant context is not lost at chunk boundaries.
Chunking strategy:
- Split the text on blank-line paragraph separators. If only one paragraph results, fall back to sentence-level splits.
- Greedily pack paragraphs into a chunk while the running word count stays below
DEFAULT_MAX_WORDS. - Start the next chunk with the trailing ~30% of words of the previous chunk
(within the [
DEFAULT_MIN_OVERLAP_RATIO,DEFAULT_MAX_OVERLAP_RATIO] range) before appending further paragraphs.
- Since:
- 0.1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleMaximum overlap ratio between consecutive chunks.static final intMaximum words per chunk (exclusive upper bound).static final doubleMinimum overlap ratio between consecutive chunks. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a formatter with default chunk size and overlap.MibChunkFormatter(int maxWords, double minOverlapRatio, double maxOverlapRatio) Creates a formatter with custom chunk size and overlap window. -
Method Summary
-
Field Details
-
DEFAULT_MAX_WORDS
public static final int DEFAULT_MAX_WORDSMaximum words per chunk (exclusive upper bound).- See Also:
-
DEFAULT_MIN_OVERLAP_RATIO
public static final double DEFAULT_MIN_OVERLAP_RATIOMinimum overlap ratio between consecutive chunks.- See Also:
-
DEFAULT_MAX_OVERLAP_RATIO
public static final double DEFAULT_MAX_OVERLAP_RATIOMaximum overlap ratio between consecutive chunks.- See Also:
-
-
Constructor Details
-
MibChunkFormatter
public MibChunkFormatter()Creates a formatter with default chunk size and overlap. -
MibChunkFormatter
public MibChunkFormatter(int maxWords, double minOverlapRatio, double maxOverlapRatio) Creates a formatter with custom chunk size and overlap window.- Parameters:
maxWords- hard upper bound on words per chunk (must be> 1)minOverlapRatio- minimum overlap ratio in(0, 0.5)maxOverlapRatio- maximum overlap ratio in(0, 0.5); must be≥ minOverlapRatio
-
-
Method Details
-
format
Splits the object's DESCRIPTION text into embeddable chunks.- Parameters:
obj- the MIB object to format (non-null)- Returns:
- one chunk for short descriptions, multiple paragraph-aligned chunks for longer ones, or an empty list when the description is missing or blank
-