Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
A Python class that takes in long text as input and divides it into shorter chunks no longer than a specified length.
TextChunker is a Python class that takes in long text as input and divides it into shorter chunks no longer than a specified length. The purpose of this project is to provide a simple and useful tool for data processing tasks such as natural language processing and information extraction.
pip intsll text_chunker
You can use the TextChunker
class in your Python code as follows:
from text_chunker import TextChunker
# Create a new TextChunker object with a maximum chunk length of 50 characters
chunker = TextChunker(maxlen=1000)
# Chunk a long text string into smaller chunks
text = "This is a long text string..."
for chunk in chunker.chunk(text):
print(chunk)
The chunk
method attempts to split paragraphs first while keeping chunk length below maxlen
. If a paragraph is longer than maxlen
, the method attempts to split the paragraph into sentences. If a sentence is longer than maxlen
, it is split into smaller chunks no longer than maxlen
.
There are also functions called paragraphs
and sentences
that divide the text into paragraphs and sentences, respectively.
from text_chunker import paragraphs
for p in paragraphs(text):
print(p)
from text_chunker import sentences
for s in sentences(text):
print(s)
The sentences
function utilizes a tokenizer from the nltk
library.
This project is distributed under the MIT license. See the LICENSE file for details.
FAQs
A Python class that takes in long text as input and divides it into shorter chunks no longer than a specified length.
We found that text-chunker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.