Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

textsplitter-1.0.1.tar.gz (1.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

textsplitter-1.0.1-py3-none-any.whl (1.7 kB view details)

Uploaded Python 3

File details

Details for the file textsplitter-1.0.1.tar.gz.

File metadata

  • Download URL: textsplitter-1.0.1.tar.gz
  • Upload date:
  • Size: 1.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for textsplitter-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f2d5fa4c81484e7ba3b7474d9f523e64934317b6a13aeb18d1b69d8640257bdd
MD5 6401eff37ea6898743cedc89da0c2bb3
BLAKE2b-256 fffcb31914c2bc9ad55d2408c63ad95619e5910e6656fa19d1318c08066f08d7

See more details on using hashes here.

File details

Details for the file textsplitter-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: textsplitter-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 1.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for textsplitter-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ba55cbce02b23327c38f89d037bddf1a1b45b436ac6f749bb45aa940d566b63e
MD5 23d7614b186e43186525b137ab1122e5
BLAKE2b-256 2c37a16e77f5fafbfec58a4c4429abac89c6cd2d3690dde14786d90b3b2fce41

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page