Small Python package for text utilities — group assignment
• Jad Zoghaib (@jadzoghaib) - Repository Owner • Miguel de Faria (@marinmiguel) • Ana Petrescu (@anaapetrescu) • Jan Philipp Gnau (@Thisisntevenmyfinale)
Our package includes the following text utility functions:
• slugify(text) — convert text to lowercase, hyphen-separated safe string • entence_count(text) — count number of sentences in text • word_count(text) — case-insensitive counts • is_palindrome(text) — check if text reads the same backwards (ignore case and spaces) • count_vowels(text) — count vowels in the given text
Create new public repository on Github (textutils-team12)
- Add a
.gitignorefor Python and a short description like:
git clone https://github.com/ayush/textutils-2.git cd textutils-team12
micromamba create -f textutils.yml -y micromamba activate textutils
pip install -e
Running all tests: pytest
To see detailed coverage information: pytest --cov=src/textutils --cov-report=term-missing
import re import unicodedata from collections import Counter
def slugify(text): text = unicodedata.normalize('NFD', text) text = ''.join(c for c in text if unicodedata.category(c) != 'Mn') text = text.lower() text = re.sub(r'&', 'and', text) text = re.sub(r'[^a-z0-9]+', '-', text) return text.strip('-')
def sentence_count(text): sentences = re.split(r'[.!?]+', text.strip()) return len([s for s in sentences if s.strip()])
def word_count(text): words = text.lower().split() return dict(Counter(words))
def is_palindrome(text): cleaned = text.lower().replace(" ", "") return cleaned == cleaned[::-1]
def count_vowels(text): vowels = "aeiou" return sum(1 for char in text.lower() if char in vowels)
This assignment was developed as a collaboratively using: • Test-Driven Development • Seperate branch workflows for each functionality • Git version control • Continuous testing with pytest
This package was submitted as a collaborative assignment. We divided the work by implementing different features on separate branches, then resolved the merge conflicts as everything was brought together into the main branch. After completing development, we moved on to testing to ensure that all components functioned properly on both macOS and Windows.