(chunk_size: usize, chunk_overlap: usize, split_by_headers: bool)
| 171 | #[staticmethod] |
| 172 | #[pyo3(signature = (chunk_size, chunk_overlap=0, split_by_headers=true))] |
| 173 | fn markdown(chunk_size: usize, chunk_overlap: usize, split_by_headers: bool) -> PyResult<Self> { |
| 174 | if chunk_size == 0 { |
| 175 | return Err(PyErr::new::<pyo3::exceptions::PyValueError, _>( |
| 176 | "Chunk size must be greater than 0", |
| 177 | )); |
| 178 | } |
| 179 | |
| 180 | Ok(Self { |
| 181 | inner: CoreTextSplitterConfig { |
| 182 | strategy: CoreSplitterStrategy::Markdown { |
| 183 | chunk_size, |
| 184 | chunk_overlap, |
| 185 | split_by_headers, |
| 186 | }, |
| 187 | preserve_word_boundaries: true, |
| 188 | trim_whitespace: true, |
| 189 | include_metadata: true, |
| 190 | extra_params: HashMap::new(), |
| 191 | }, |
| 192 | }) |
| 193 | } |
| 194 | |
| 195 | /// Create a code splitter configuration |
| 196 | #[staticmethod] |
no outgoing calls