Skip to main content

split_text_by_ratio

Function split_text_by_ratio 

Source
pub fn split_text_by_ratio(text: &str, ratios: &[f32]) -> Vec<String>
Expand description

Splits text into parts based on given ratios.

This function attempts to split text at word boundaries when possible, distributing characters roughly according to the specified ratios.

§Arguments

  • text - The text to split.
  • ratios - Slice of ratios (should sum to ~1.0).

§Returns

Vector of text parts, one for each ratio.