Skip to content

Commit

Permalink
Merge pull request #17 from kawakamimoeki/fix_cursor
Browse files Browse the repository at this point in the history
Fix cursor
  • Loading branch information
moekiorg authored Mar 9, 2024
2 parents 7c69ea2 + fbd0988 commit 24bfa19
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/baran/text_splitter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def chunks(text, metadata: nil)
chunk = { text: chunk, cursor: cursor }
chunk[:metadata] = metadata if metadata
chunks << chunk
cursor += chunk.length
cursor += chunk[:text].length
end

chunks
Expand Down
1 change: 1 addition & 0 deletions test/test_text_splitter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_chunks

assert_equal 2, documents.size
assert_equal 'text', documents[0][:text]
assert_equal 4, documents[1][:cursor]
end

def test_chunks_with_metadata
Expand Down

0 comments on commit 24bfa19

Please sign in to comment.