Class: Boxcars::VectorStore::SplitText
- Inherits:
-
Object
- Object
- Boxcars::VectorStore::SplitText
- Includes:
- Boxcars::VectorStore
- Defined in:
- lib/boxcars/vector_store/split_text.rb
Overview
Split a text into chunks of a given size.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(separator: "Search", chunk_size: 7, chunk_overlap: 3, text: "") ⇒ SplitText
constructor
A new instance of SplitText.
Methods included from Boxcars::VectorStore
Constructor Details
#initialize(separator: "Search", chunk_size: 7, chunk_overlap: 3, text: "") ⇒ SplitText
Returns a new instance of SplitText.
13 14 15 16 17 18 19 20 |
# File 'lib/boxcars/vector_store/split_text.rb', line 13 def initialize(separator: "Search", chunk_size: 7, chunk_overlap: 3, text: "") validate_params(separator, chunk_size, chunk_overlap, text) @separator = separator @chunk_size = chunk_size @chunk_overlap = chunk_overlap @text = text end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 |
# File 'lib/boxcars/vector_store/split_text.rb', line 22 def call splits = text.split(separator) merged_splits = merge_splits(splits, separator) merged_splits&.sort end |