A Python library to split large text into smaller chunks based on the maximum token size and other criteria
Project description
Text Splitter
A Python library to split large text into smaller chunks based on the maximum token size and other criteria.
Features
- Split text into smaller chunks based on maximum token size
- End chunks at sentence boundaries
- Preserve formatting
- Remove URLs
- Replace entities
- Remove stopwords
Installation
To install the library, run the following command:
pip install textsplitter
Usage
Here's a simple example of how to use the TextSplitter:
from textsplitter import TextSplitter
sample_text = "Your sample text goes here..."
text_splitter = TextSplitter(max_token_size=20, end_sentence=True, preserve_formatting=True,
remove_urls=True, replace_entities=True, remove_stopwords=True, language='english')
chunks = text_splitter.split_text(sample_text)
for i, chunk in enumerate(chunks):
print(f"Chunk {i + 1}:\n{chunk}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file textsplitter-1.0.3.tar.gz.
File metadata
- Download URL: textsplitter-1.0.3.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35a2c47d22a67a85674f82e9fcbc884926523cdaa29a8d3817637d31b6e47851
|
|
| MD5 |
8afac984b0fd317ea63e704ec4119009
|
|
| BLAKE2b-256 |
848c682f1a35449b2268e3e4a5d23c0ec415fbab6d2b137281236475739b3ead
|
File details
Details for the file textsplitter-1.0.3-py3-none-any.whl.
File metadata
- Download URL: textsplitter-1.0.3-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efeca488d2c74112490dc6126f3e8f6cc4f977cd8e92fda5282bb801d1ac079c
|
|
| MD5 |
de0796845e50ba87e96e4f0cc046a3be
|
|
| BLAKE2b-256 |
807534f8d669e2c06bfdb36d95ae7295ba61ae927cd2f5916dcd740c362566a2
|