You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add constructor with configurable chunk size and overlap to TextSplitTransformer
- Add constructor to TextSplitTransformer with default values (chunkSize=1000, overlap=200)
- Add validation that overlap must be non-negative and less than chunk size
- Use constructor parameters as defaults when no options are provided in transform method
- Add comprehensive tests for constructor parameter validation
- Fix code style with PHP CS Fixer
Copy file name to clipboardExpand all lines: src/store/src/Document/Transformer/TextSplitTransformer.php
+11-2Lines changed: 11 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -29,13 +29,22 @@
29
29
publicconstOPTION_CHUNK_SIZE = 'chunk_size';
30
30
publicconstOPTION_OVERLAP = 'overlap';
31
31
32
+
publicfunction__construct(
33
+
privateint$chunkSize = 1000,
34
+
privateint$overlap = 200,
35
+
) {
36
+
if ($this->overlap < 0 || $this->overlap >= $this->chunkSize) {
37
+
thrownewInvalidArgumentException(\sprintf('Overlap must be non-negative and less than chunk size. Got chunk size: %d, overlap: %d', $this->chunkSize, $this->overlap));
0 commit comments