A lightweight, beginner-friendly Python module for text transformation and analysis
Project description
✨ Textcraft
🧵 A lightweight Python module for text transformation, cleaning, and basic analysis —
beginner-friendly and open source.
📖 Overview
Textcraft is a simple Python library that provides common text manipulation functions. It's designed to be easy to use and understand, making it perfect for beginners and for quick text processing tasks.
📦 Installation
Install Textcraft using pip:
pip install textcraft-py
Or clone the repository:
git clone https://github.com/O-sama12/textcraft
then import the module directly:
import textcraft
🚀 Getting Started
Basic Usage
import textcraft as txt
# Example text to work with
text = "Hello World! This is a TextCraft example."
# Text Case & Format Conversion
print(txt.to_lowercase(text)) # hello world! this is a textcraft example.
print(txt.to_uppercase(text)) # HELLO WORLD! THIS IS A TEXTCRAFT EXAMPLE.
print(txt.to_snake_case(text)) # hello_world!_this_is_a_textcraft_example.
print(txt.to_kebab_case(text)) # hello-world!-this-is-a-textcraft-example.
print(txt.to_camel_case(text)) # helloWorld!ThisIsATextcraftExample.
# Text Cleaning
print(txt.remove_punctuation(text)) # Hello World This is a TextCraft example
print(txt.normalize_spaces(text)) # Hello World! This is a TextCraft example.
# Text Statistics
print(txt.word_count(text)) # 8
print(txt.char_count(text)) # 43 (without spaces: 35)
print(txt.sentence_count(text)) # 1
print(txt.slugify(text)) # hello-world-this-is-a-textcraft-example
🚀 Features
🔤 Text Case & Format Conversion
- 🔡
to_lowercase(text)- Convert text to lowercase - 🐫
to_uppercase(text)- Convert text to uppercase - 🐍
to_snake_case(text)- Transform text intosnake_case - 🔗
to_kebab_case(text)- Convert text intokebab-case - 🐪
to_camel_case(text)- Convert text intocamelCase
🧹 Text Cleaning Utilities
- 🧽
remove_punctuation(text)- Remove all punctuation characters from text - 📐
normalize_spaces(text)- Normalize multiple spaces into a single space - 🌐
slugify(text)- Generate URL-friendly slugs
📊 Basic Text Statistics
- 🧮
word_count(text)- Count number of words in text - 🔢
char_count(text, include_spaces=True/False)- Count characters (with or without spaces) - 📑
sentence_count(text)- Count number of sentences
🧪 Common Use Cases
1. Preparing text for processing
raw_text = " This text has extra spaces. "
clean_text = txt.normalize_spaces(raw_text) # "This text has extra spaces."
2. Creating URL-friendly strings
title = "My Blog Post: An Introduction!"
slug = txt.slugify(title) # "my-blog-post-an-introduction"
3. Formatting text for different contexts
function_name = "my function name"
snake_case = txt.to_snake_case(function_name) # "my_function_name"
kebab_case = txt.to_kebab_case(function_name) # "my-function-name"
📝 Examples with Input → Output
| Function | Input | Output |
|---|---|---|
to_lowercase() |
"Hello World!" |
"hello world!" |
to_uppercase() |
"Hello World!" |
"HELLO WORLD!" |
to_snake_case() |
"Hello World" |
"hello_world" |
to_camel_case() |
"hello world" |
"helloWorld" |
remove_punctuation() |
"Hello, World!" |
"Hello World" |
word_count() |
"Hello World" |
2 |
slugify() |
"Hello, World!" |
"hello-world" |
to_title_case() |
"Hello, World!" |
⚠️ Edge Cases & Notes
- Empty strings will return empty strings for most functions
to_camel_case()handles various separators and converts them appropriatelysentence_count()recognizes.,!, and?as sentence terminatorschar_count()can optionally include or exclude spacesslugify()removes punctuation and replaces spaces with hyphens
🤝 Contributing
This project is beginner-friendly and welcomes:
- 🐞 Bug reports
- 💡 Feature suggestions
- 🔧 Pull requests
Before contributing, please take a moment to read the CONTRIBUTING.md file.
📄 License
This project is licensed under the
MIT License.
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 textcraft_py-0.1.4.tar.gz.
File metadata
- Download URL: textcraft_py-0.1.4.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4ff447b7e188cefb890dbcc048f515aadc6ae7cfc0b17ad829cf3b1a95387fd
|
|
| MD5 |
749fa4288720a7ac2bf8286b3d3d9741
|
|
| BLAKE2b-256 |
fd6c8f304b0a9492fcb01b020907e7ca394148f5a6c1fc71ca4764b7b186fb1c
|
File details
Details for the file textcraft_py-0.1.4-py3-none-any.whl.
File metadata
- Download URL: textcraft_py-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
549d15880faca48eca4f09bf12601956f7194528ad32404ad12d3cdceda8e2a3
|
|
| MD5 |
d445e3bbc6fb121deb8ed05f5f7c29b6
|
|
| BLAKE2b-256 |
a94a7351425bef6e654b27e3ccbd9994084c02960dea151fa9532a8e1fc9ba69
|