feat: add stringutils module with word_count function and tests

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
wralto-user-1
2026-11-02 22:14:51 +01:00
commit 0b6fe9d244
3 changed files with 65 additions and 0 deletions

14
stringutils.py Normal file
View File

@ -0,0 +1,14 @@
def word_count(text: str) -> int:
"""Count the number of words in a string.
Words are defined as non-empty sequences separated by whitespace.
Args:
text: The input string to count words in.
Returns:
The number of words in the string.
"""
if not text.strip():
return 0
return len(text.split())