🧵 A lightweight Python module for text transformation, cleaning, and basic analysis —
beginner-friendly and open source.
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.
Install Textcraft using pip:
pip install textcraft-pyOr clone the repository:
git clone https://github.com/O-sama12/textcraftthen import the module directly:
import textcraftimport 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- 🔡
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
- 🧽
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
- 🧮
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
raw_text = " This text has extra spaces. "
clean_text = txt.normalize_spaces(raw_text) # "This text has extra spaces."title = "My Blog Post: An Introduction!"
slug = txt.slugify(title) # "my-blog-post-an-introduction"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"| 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" |
- 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
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.
This project is licensed under the
MIT License.