A lightweight utility for common text preparation tasks in ML and NLP.
Project description
SimpleTextProcessor
A lightweight utility library for quick text preparation in machine learning and NLP tasks.
This package provides simple functions for
Cleaning Removing punctuation, converting to lowercase, and handling special characters.
Vectorization Creating a simple Bag-of-Words (BoW) vector representation from a list of documents.
Installation
Since this package is small, it only requires numpy as a dependency for the vectorization function.
pip install simple-text-processor
Usage
- Clean Text
from simple_text_processor import clean_text
text = Hello World! This is a Test sentence with some Numb3rs. cleaned_text = clean_text(text) print(cleaned_text)
Output hello world this is a test sentence with some numb rs
- Simple Bag-of-Words Vectorizer
from simple_text_processor import simple_vectorize
documents = [ The sun is shining brightly., A sunny day is a happy day., The moon is out tonight., ]
vectors, vocabulary = simple_vectorize(documents)
print(Vocabulary, vocabulary)
Output Vocabulary {'the' 0, 'sun' 1, 'is' 2, 'shining' 3, 'brightly' 4, 'a' 5, 'sunny' 6, 'day' 7, 'happy' 8, 'moon' 9, 'out' 10, 'tonight' 11}
print(nVectors (BoW)n, vectors)
Output (Numpy array of word counts)
[[1 1 1 1 1 0 0 0 0 0 0 0]
[0 0 1 0 0 1 1 2 1 0 0 0]
[1 0 1 0 0 0 0 0 0 1 1 1]]
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 simple_text_processor-0.1.0.tar.gz.
File metadata
- Download URL: simple_text_processor-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9be9bcfa399afa4b744a586b03e14510ad38b801257093fa695c67471e63a5af
|
|
| MD5 |
ec62b34c519c2e6234c37c4d249c5ab5
|
|
| BLAKE2b-256 |
0ee295af18c67d750585071855061434a7df99873224e2f3574a0417c6f16390
|
File details
Details for the file simple_text_processor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: simple_text_processor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08d465aa40a6191ec083c729dc5bfd24bf4ea6ce4ffe8c9a2595d82875996b95
|
|
| MD5 |
46e7f1041e17701d58fb91bd1f173821
|
|
| BLAKE2b-256 |
e605576d4921a378186299b0cdb1b0d96cfba14357de2fd3e4f6ff66f06b5e39
|