Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python splitters optionally provide chunk char offsets #135

Merged
merged 3 commits into from
Apr 4, 2024

Conversation

benbrandt
Copy link
Owner

It can be helpful to know where a given chunk falls within the entire text. On the Rust side, you can get the chunk along with its corresponding byte offset. But there wasn't a comparable method for the Python package.

Because Rust byte offsets aren't useful in Python, these are mapped to the corresponding character index of the beginning of the chunk. Since string indexing in Python is normally done with character indexes, this should allow for different string comparison and matching operations with this number.

Closes #133

It can be helpful to know where a given chunk falls within the entire text. On the Rust side, you can get the chunk along with its corresponding byte offset. But there wasn't a comparable method for the Python package.

Because Rust byte offsets aren't useful in Python, these are mapped to the corresponding character index of the beginning of the chunk. Since string indexing in Python is normally done with character indexes, this should allow for different string comparison and matching operations with this number.
@benbrandt benbrandt self-assigned this Apr 4, 2024
@benbrandt benbrandt merged commit 17bc95a into main Apr 4, 2024
21 checks passed
@benbrandt benbrandt deleted the 133-char-indices branch April 4, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python: Optionally return char offsets
1 participant