textutils-nabil184 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,51 @@
1
+
2
+ # Changelog
3
+
4
+ All notable changes to this project will be documented in this file.
5
+
6
+ ## [Unreleased]
7
+
8
+ ## [0.2.1] - 2026-11-06
9
+
10
+ ### Added
11
+
12
+ - Word frequency utility contributed through a Pull Request
13
+ - Automated tests with pytest
14
+ - Parametrized tests for normal and edge cases
15
+ - Tests for expected exceptions
16
+ - Test coverage with pytest-cov
17
+ - Black and Ruff development tools
18
+ - NumPy-style docstrings for public functions
19
+ - Pre-commit hooks for Black and Ruff
20
+ - GitHub Actions continuous integration workflow
21
+ - Four CI environments using Ubuntu, macOS and Python 3.11/3.12
22
+ - Automated PyPI publishing through GitHub Actions and Trusted Publishing
23
+ - Release tag and package version consistency check
24
+ - Distribution metadata validation with Twine
25
+ - Quality checks and tests before publishing
26
+ - Changelog and test files included in the source distribution
27
+
28
+ ### Changed
29
+
30
+ - Improved word frequency handling of case and punctuation
31
+ - Exposed word_frequency through the public API
32
+ - Updated .gitignore for generated files
33
+ - Reorganized the library into subpackages
34
+ - Moved tests next to their corresponding modules
35
+ - Updated package discovery and pytest configuration
36
+ - Documented testing and CI workflows
37
+ - Renamed the distribution to textutils-nabil184 while keeping textutils imports
38
+ - Documented PyPI installation separately from local development
39
+ - Declared the MIT license explicitly in package metadata
40
+
41
+ ## [0.1.0] - 2026-10-01
42
+
43
+ ### Added
44
+
45
+ - Initial Python package structure
46
+ - word_count() utility
47
+ - character_count() utility
48
+ - reverse() utility
49
+ - capitalize_words() utility
50
+ - Project documentation
51
+ - MIT License
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 NABIL DAHMANI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ include CHANGELOG.md
2
+ recursive-include textutils test_*.py
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: textutils-nabil184
3
+ Version: 0.2.1
4
+ Summary: A lightweight Python library for common text-processing operations.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/nabil184/textutils
7
+ Project-URL: Repository, https://github.com/nabil184/textutils
8
+ Project-URL: Issues, https://github.com/nabil184/textutils/issues
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest<10,>=8; extra == "dev"
14
+ Requires-Dist: pytest-cov<8,>=5; extra == "dev"
15
+ Requires-Dist: black==25.1.0; extra == "dev"
16
+ Requires-Dist: ruff==0.9.7; extra == "dev"
17
+ Requires-Dist: pre-commit<5,>=3; extra == "dev"
18
+ Dynamic: license-file
19
+
20
+
21
+ # textutils
22
+
23
+ `textutils` is a lightweight Python library providing simple
24
+ utilities for common text-processing operations.
25
+
26
+ ## Features
27
+
28
+ The library currently provides:
29
+
30
+ - `word_count(text)` - Count the number of words in a text.
31
+ - `character_count(text)` - Count the number of characters.
32
+ - `reverse(text)` - Reverse a text.
33
+ - `capitalize_words(text)` - Capitalize each word.
34
+ - `word_frequency(text)` - Count how often each word appears.
35
+
36
+ ## Installation
37
+
38
+ Requires Python 3.10 or newer.
39
+
40
+ After the first PyPI release is published, install the package with:
41
+
42
+ ```bash
43
+ python -m pip install textutils-nabil184
44
+ ```
45
+
46
+ The distribution name on PyPI is `textutils-nabil184`,
47
+ while the Python import name remains `textutils`.
48
+
49
+ ## Usage
50
+
51
+ ```python
52
+ from textutils import (
53
+ word_count,
54
+ character_count,
55
+ reverse,
56
+ capitalize_words,
57
+ word_frequency,
58
+ )
59
+
60
+ text = "hello open source"
61
+
62
+ print(word_count(text))
63
+ print(character_count(text))
64
+ print(reverse(text))
65
+ print(capitalize_words(text))
66
+ print(word_frequency("Hello hello world!"))
67
+ ```
68
+
69
+ Expected output:
70
+
71
+ ```text
72
+ 3
73
+ 17
74
+ ecruos nepo olleh
75
+ Hello Open Source
76
+ {'hello': 2, 'world': 1}
77
+ ```
78
+
79
+ ## Development
80
+
81
+ Clone the repository and install the package with its development dependencies:
82
+
83
+ ```bash
84
+ git clone https://github.com/nabil184/textutils.git
85
+ cd textutils
86
+ python -m pip install -e ".[dev]"
87
+ ```
88
+
89
+ ### Running tests
90
+
91
+ Run the complete test suite:
92
+
93
+ ```bash
94
+ python -m pytest -v
95
+ ```
96
+
97
+ Run tests with coverage:
98
+
99
+ ```bash
100
+ python -m pytest --cov=textutils --cov-branch --cov-report=term-missing
101
+ ```
102
+
103
+ Tests are organized inside each subpackage, close to the corresponding implementation.
104
+
105
+ ### Code quality
106
+
107
+ Format the project with Black:
108
+
109
+ ```bash
110
+ python -m black .
111
+ ```
112
+
113
+ Check formatting without modifying files:
114
+
115
+ ```bash
116
+ python -m black --check .
117
+ ```
118
+
119
+ Check code quality with Ruff:
120
+
121
+ ```bash
122
+ python -m ruff check .
123
+ ```
124
+
125
+ ## Continuous Integration
126
+
127
+ This project uses GitHub Actions to automatically check
128
+ code quality and run the test suite.
129
+
130
+ The CI workflow runs on Pull Requests targeting `main`
131
+ and on pushes to `main`.
132
+
133
+ Four environments are tested:
134
+
135
+ - Ubuntu 22.04 with Python 3.11
136
+ - Ubuntu 22.04 with Python 3.12
137
+ - macOS 15 with Python 3.11
138
+ - macOS 15 with Python 3.12
139
+
140
+ Each CI job installs the project, checks Black and Ruff,
141
+ and executes pytest.
142
+
143
+ ## Pre-commit
144
+
145
+ The project uses pre-commit to run Black and Ruff
146
+ automatically before commits.
147
+
148
+ Install the development dependencies:
149
+
150
+ ```bash
151
+ python -m pip install -e ".[dev]"
152
+ ```
153
+
154
+ Install the Git hook:
155
+
156
+ ```bash
157
+ python -m pre_commit install
158
+ ```
159
+
160
+ Run all hooks manually:
161
+
162
+ ```bash
163
+ python -m pre_commit run --all-files
164
+ ```
165
+
166
+ ## Contributing
167
+
168
+ Contributions are welcome.
169
+
170
+ To contribute, create a branch, make your changes,
171
+ run the tests and open a Pull Request.
172
+
173
+ Please ensure that tests pass and that Black and Ruff
174
+ report no issues before submitting your changes.
175
+
176
+ ## License
177
+
178
+ This project is licensed under the MIT License.
179
+ See the `LICENSE` file for details.
@@ -0,0 +1,160 @@
1
+
2
+ # textutils
3
+
4
+ `textutils` is a lightweight Python library providing simple
5
+ utilities for common text-processing operations.
6
+
7
+ ## Features
8
+
9
+ The library currently provides:
10
+
11
+ - `word_count(text)` - Count the number of words in a text.
12
+ - `character_count(text)` - Count the number of characters.
13
+ - `reverse(text)` - Reverse a text.
14
+ - `capitalize_words(text)` - Capitalize each word.
15
+ - `word_frequency(text)` - Count how often each word appears.
16
+
17
+ ## Installation
18
+
19
+ Requires Python 3.10 or newer.
20
+
21
+ After the first PyPI release is published, install the package with:
22
+
23
+ ```bash
24
+ python -m pip install textutils-nabil184
25
+ ```
26
+
27
+ The distribution name on PyPI is `textutils-nabil184`,
28
+ while the Python import name remains `textutils`.
29
+
30
+ ## Usage
31
+
32
+ ```python
33
+ from textutils import (
34
+ word_count,
35
+ character_count,
36
+ reverse,
37
+ capitalize_words,
38
+ word_frequency,
39
+ )
40
+
41
+ text = "hello open source"
42
+
43
+ print(word_count(text))
44
+ print(character_count(text))
45
+ print(reverse(text))
46
+ print(capitalize_words(text))
47
+ print(word_frequency("Hello hello world!"))
48
+ ```
49
+
50
+ Expected output:
51
+
52
+ ```text
53
+ 3
54
+ 17
55
+ ecruos nepo olleh
56
+ Hello Open Source
57
+ {'hello': 2, 'world': 1}
58
+ ```
59
+
60
+ ## Development
61
+
62
+ Clone the repository and install the package with its development dependencies:
63
+
64
+ ```bash
65
+ git clone https://github.com/nabil184/textutils.git
66
+ cd textutils
67
+ python -m pip install -e ".[dev]"
68
+ ```
69
+
70
+ ### Running tests
71
+
72
+ Run the complete test suite:
73
+
74
+ ```bash
75
+ python -m pytest -v
76
+ ```
77
+
78
+ Run tests with coverage:
79
+
80
+ ```bash
81
+ python -m pytest --cov=textutils --cov-branch --cov-report=term-missing
82
+ ```
83
+
84
+ Tests are organized inside each subpackage, close to the corresponding implementation.
85
+
86
+ ### Code quality
87
+
88
+ Format the project with Black:
89
+
90
+ ```bash
91
+ python -m black .
92
+ ```
93
+
94
+ Check formatting without modifying files:
95
+
96
+ ```bash
97
+ python -m black --check .
98
+ ```
99
+
100
+ Check code quality with Ruff:
101
+
102
+ ```bash
103
+ python -m ruff check .
104
+ ```
105
+
106
+ ## Continuous Integration
107
+
108
+ This project uses GitHub Actions to automatically check
109
+ code quality and run the test suite.
110
+
111
+ The CI workflow runs on Pull Requests targeting `main`
112
+ and on pushes to `main`.
113
+
114
+ Four environments are tested:
115
+
116
+ - Ubuntu 22.04 with Python 3.11
117
+ - Ubuntu 22.04 with Python 3.12
118
+ - macOS 15 with Python 3.11
119
+ - macOS 15 with Python 3.12
120
+
121
+ Each CI job installs the project, checks Black and Ruff,
122
+ and executes pytest.
123
+
124
+ ## Pre-commit
125
+
126
+ The project uses pre-commit to run Black and Ruff
127
+ automatically before commits.
128
+
129
+ Install the development dependencies:
130
+
131
+ ```bash
132
+ python -m pip install -e ".[dev]"
133
+ ```
134
+
135
+ Install the Git hook:
136
+
137
+ ```bash
138
+ python -m pre_commit install
139
+ ```
140
+
141
+ Run all hooks manually:
142
+
143
+ ```bash
144
+ python -m pre_commit run --all-files
145
+ ```
146
+
147
+ ## Contributing
148
+
149
+ Contributions are welcome.
150
+
151
+ To contribute, create a branch, make your changes,
152
+ run the tests and open a Pull Request.
153
+
154
+ Please ensure that tests pass and that Black and Ruff
155
+ report no issues before submitting your changes.
156
+
157
+ ## License
158
+
159
+ This project is licensed under the MIT License.
160
+ See the `LICENSE` file for details.
@@ -0,0 +1,59 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0.3"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "textutils-nabil184"
7
+ version = "0.2.1"
8
+ description = "A lightweight Python library for common text-processing operations."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = []
12
+ license = "MIT"
13
+ license-files = ["LICENSE"]
14
+
15
+ [project.optional-dependencies]
16
+ dev = [
17
+ "pytest>=8,<10",
18
+ "pytest-cov>=5,<8",
19
+ "black==25.1.0",
20
+ "ruff==0.9.7",
21
+ "pre-commit>=3,<5",
22
+ ]
23
+
24
+ [project.urls]
25
+ Homepage = "https://github.com/nabil184/textutils"
26
+ Repository = "https://github.com/nabil184/textutils"
27
+ Issues = "https://github.com/nabil184/textutils/issues"
28
+
29
+ [tool.setuptools]
30
+ include-package-data = false
31
+
32
+ [tool.setuptools.packages.find]
33
+ where = ["."]
34
+ include = ["textutils", "textutils.*"]
35
+ exclude = ["*.tests", "*.tests.*"]
36
+ namespaces = false
37
+
38
+ [tool.pytest.ini_options]
39
+ testpaths = ["textutils"]
40
+ addopts = "-ra"
41
+
42
+ [tool.black]
43
+ line-length = 88
44
+ target-version = ["py310"]
45
+
46
+ [tool.ruff]
47
+ line-length = 88
48
+ target-version = "py310"
49
+
50
+ [tool.ruff.lint]
51
+ select = ["E4", "E7", "E9", "F"]
52
+
53
+ [tool.coverage.run]
54
+ branch = true
55
+ source = ["textutils"]
56
+ omit = ["*/tests/*"]
57
+
58
+ [tool.coverage.report]
59
+ show_missing = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,13 @@
1
+ """A lightweight Python library for text processing."""
2
+
3
+ from .casing import capitalize_words
4
+ from .counting import character_count, word_count, word_frequency
5
+ from .transform import reverse
6
+
7
+ __all__ = [
8
+ "word_count",
9
+ "character_count",
10
+ "reverse",
11
+ "capitalize_words",
12
+ "word_frequency",
13
+ ]
@@ -0,0 +1,5 @@
1
+ """Text capitalization utilities."""
2
+
3
+ from ._capitalize import capitalize_words
4
+
5
+ __all__ = ["capitalize_words"]
@@ -0,0 +1,23 @@
1
+ def capitalize_words(text: str) -> str:
2
+ """Capitalize the first letter of each word.
3
+
4
+ Parameters
5
+ ----------
6
+ text : str
7
+ The input text.
8
+
9
+ Returns
10
+ -------
11
+ str
12
+ Text with each word capitalized.
13
+
14
+ Examples
15
+ --------
16
+ >>> capitalize_words("hello world")
17
+ 'Hello World'
18
+ >>> capitalize_words("hello open source")
19
+ 'Hello Open Source'
20
+ >>> capitalize_words("")
21
+ ''
22
+ """
23
+ return text.title()
@@ -0,0 +1,18 @@
1
+ import pytest
2
+
3
+ from textutils import capitalize_words
4
+
5
+
6
+ @pytest.mark.parametrize(
7
+ "text, expected",
8
+ [
9
+ ("hello world", "Hello World"),
10
+ ("HELLO WORLD", "Hello World"),
11
+ ("multiple spaces", "Multiple Spaces"),
12
+ ("", ""),
13
+ ("123 hello", "123 Hello"),
14
+ ("école française", "École Française"),
15
+ ],
16
+ )
17
+ def test_capitalize_words(text, expected):
18
+ assert capitalize_words(text) == expected
@@ -0,0 +1,6 @@
1
+ """Word and character counting utilities."""
2
+
3
+ from ._count import character_count, word_count
4
+ from ._frequency import word_frequency
5
+
6
+ __all__ = ["word_count", "character_count", "word_frequency"]
@@ -0,0 +1,44 @@
1
+ def word_count(text: str) -> int:
2
+ """Count the number of words in a text.
3
+
4
+ Parameters
5
+ ----------
6
+ text : str
7
+ The input text.
8
+
9
+ Returns
10
+ -------
11
+ int
12
+ Number of words in the text.
13
+
14
+ Examples
15
+ --------
16
+ >>> word_count("Hello Open Source")
17
+ 3
18
+ >>> word_count("")
19
+ 0
20
+ """
21
+ return len(text.split())
22
+
23
+
24
+ def character_count(text: str) -> int:
25
+ """Count the number of characters in a text.
26
+
27
+ Parameters
28
+ ----------
29
+ text : str
30
+ The input text.
31
+
32
+ Returns
33
+ -------
34
+ int
35
+ Number of characters, including spaces.
36
+
37
+ Examples
38
+ --------
39
+ >>> character_count("Hello")
40
+ 5
41
+ >>> character_count("Hello World")
42
+ 11
43
+ """
44
+ return len(text)
@@ -0,0 +1,59 @@
1
+ """Utilities for counting word frequencies.
2
+
3
+ Original implementation inspired by:
4
+ https://www.geeksforgeeks.org/python/find-frequency-of-each-word-in-a-string-in-python/
5
+ """
6
+
7
+ import re
8
+ from collections import Counter
9
+
10
+
11
+ def word_frequency(s: str) -> dict[str, int]:
12
+ """Count the frequency of each word in a text.
13
+
14
+ The comparison is case-insensitive and punctuation is ignored.
15
+
16
+ Parameters
17
+ ----------
18
+ s : str
19
+ The input text.
20
+
21
+ Returns
22
+ -------
23
+ dict[str, int]
24
+ A dictionary containing each word and its frequency.
25
+
26
+ Raises
27
+ ------
28
+ TypeError
29
+ If the input is not a string.
30
+
31
+ Examples
32
+ --------
33
+ >>> word_frequency("Hello hello world!")
34
+ {'hello': 2, 'world': 1}
35
+ >>> word_frequency("")
36
+ {}
37
+ """
38
+ if not isinstance(s, str):
39
+ raise TypeError("Input must be a string")
40
+
41
+ words = s.split()
42
+
43
+ cleaned_words = []
44
+ for word in words:
45
+ cleaned_words.extend(re.findall(r"\b\w+\b", word.casefold()))
46
+
47
+ words = cleaned_words
48
+ freq = Counter(words)
49
+
50
+ result = {}
51
+ for w, c in freq.items():
52
+ result[w] = c
53
+
54
+ return result
55
+
56
+
57
+ # Usage example
58
+ if __name__ == "__main__":
59
+ print(word_frequency("hello hello there"))
@@ -0,0 +1,32 @@
1
+ import pytest
2
+
3
+ from textutils import character_count, word_count
4
+
5
+
6
+ @pytest.mark.parametrize(
7
+ "text, expected",
8
+ [
9
+ ("Hello world", 2),
10
+ ("", 0),
11
+ (" ", 0),
12
+ ("one two\nthree", 3),
13
+ ("bonjour le monde", 3),
14
+ ("it's a test", 3),
15
+ ],
16
+ )
17
+ def test_word_count(text, expected):
18
+ assert word_count(text) == expected
19
+
20
+
21
+ @pytest.mark.parametrize(
22
+ "text, expected",
23
+ [
24
+ ("", 0),
25
+ ("Hello", 5),
26
+ ("Hello World", 11),
27
+ ("é", 1),
28
+ ("\n\t", 2),
29
+ ],
30
+ )
31
+ def test_character_count(text, expected):
32
+ assert character_count(text) == expected
@@ -0,0 +1,35 @@
1
+ import pytest
2
+
3
+ from textutils import word_frequency
4
+
5
+
6
+ @pytest.mark.parametrize(
7
+ "text, expected",
8
+ [
9
+ ("Hello hello world!", {"hello": 2, "world": 1}),
10
+ ("Hi, hi!", {"hi": 2}),
11
+ ("", {}),
12
+ (" ", {}),
13
+ ("!!! ...", {}),
14
+ ("A b A", {"a": 2, "b": 1}),
15
+ ("hello\nHELLO", {"hello": 2}),
16
+ ("Python-python", {"python": 2}),
17
+ ("Café café", {"café": 2}),
18
+ ("one TWO two;one", {"one": 2, "two": 2}),
19
+ ],
20
+ )
21
+ def test_word_frequency(text, expected):
22
+ assert word_frequency(text) == expected
23
+
24
+
25
+ @pytest.mark.parametrize(
26
+ "invalid_input",
27
+ [
28
+ None,
29
+ 123,
30
+ ["hello"],
31
+ ],
32
+ )
33
+ def test_word_frequency_invalid_input(invalid_input):
34
+ with pytest.raises(TypeError):
35
+ word_frequency(invalid_input)
@@ -0,0 +1,5 @@
1
+ """Text transformation utilities."""
2
+
3
+ from ._reverse import reverse
4
+
5
+ __all__ = ["reverse"]
@@ -0,0 +1,21 @@
1
+ def reverse(text: str) -> str:
2
+ """Reverse the characters in a text.
3
+
4
+ Parameters
5
+ ----------
6
+ text : str
7
+ The input text.
8
+
9
+ Returns
10
+ -------
11
+ str
12
+ Text with its characters in reverse order.
13
+
14
+ Examples
15
+ --------
16
+ >>> reverse("Hello")
17
+ 'olleH'
18
+ >>> reverse("")
19
+ ''
20
+ """
21
+ return text[::-1]
@@ -0,0 +1,19 @@
1
+ """Tests for the reverse function."""
2
+
3
+ import pytest
4
+
5
+ from textutils import reverse
6
+
7
+
8
+ @pytest.mark.parametrize(
9
+ "text, expected",
10
+ [
11
+ ("", ""),
12
+ ("abc", "cba"),
13
+ ("Hello World", "dlroW olleH"),
14
+ ("12345", "54321"),
15
+ ("école", "elocé"),
16
+ ],
17
+ )
18
+ def test_reverse(text, expected):
19
+ assert reverse(text) == expected
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: textutils-nabil184
3
+ Version: 0.2.1
4
+ Summary: A lightweight Python library for common text-processing operations.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/nabil184/textutils
7
+ Project-URL: Repository, https://github.com/nabil184/textutils
8
+ Project-URL: Issues, https://github.com/nabil184/textutils/issues
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest<10,>=8; extra == "dev"
14
+ Requires-Dist: pytest-cov<8,>=5; extra == "dev"
15
+ Requires-Dist: black==25.1.0; extra == "dev"
16
+ Requires-Dist: ruff==0.9.7; extra == "dev"
17
+ Requires-Dist: pre-commit<5,>=3; extra == "dev"
18
+ Dynamic: license-file
19
+
20
+
21
+ # textutils
22
+
23
+ `textutils` is a lightweight Python library providing simple
24
+ utilities for common text-processing operations.
25
+
26
+ ## Features
27
+
28
+ The library currently provides:
29
+
30
+ - `word_count(text)` - Count the number of words in a text.
31
+ - `character_count(text)` - Count the number of characters.
32
+ - `reverse(text)` - Reverse a text.
33
+ - `capitalize_words(text)` - Capitalize each word.
34
+ - `word_frequency(text)` - Count how often each word appears.
35
+
36
+ ## Installation
37
+
38
+ Requires Python 3.10 or newer.
39
+
40
+ After the first PyPI release is published, install the package with:
41
+
42
+ ```bash
43
+ python -m pip install textutils-nabil184
44
+ ```
45
+
46
+ The distribution name on PyPI is `textutils-nabil184`,
47
+ while the Python import name remains `textutils`.
48
+
49
+ ## Usage
50
+
51
+ ```python
52
+ from textutils import (
53
+ word_count,
54
+ character_count,
55
+ reverse,
56
+ capitalize_words,
57
+ word_frequency,
58
+ )
59
+
60
+ text = "hello open source"
61
+
62
+ print(word_count(text))
63
+ print(character_count(text))
64
+ print(reverse(text))
65
+ print(capitalize_words(text))
66
+ print(word_frequency("Hello hello world!"))
67
+ ```
68
+
69
+ Expected output:
70
+
71
+ ```text
72
+ 3
73
+ 17
74
+ ecruos nepo olleh
75
+ Hello Open Source
76
+ {'hello': 2, 'world': 1}
77
+ ```
78
+
79
+ ## Development
80
+
81
+ Clone the repository and install the package with its development dependencies:
82
+
83
+ ```bash
84
+ git clone https://github.com/nabil184/textutils.git
85
+ cd textutils
86
+ python -m pip install -e ".[dev]"
87
+ ```
88
+
89
+ ### Running tests
90
+
91
+ Run the complete test suite:
92
+
93
+ ```bash
94
+ python -m pytest -v
95
+ ```
96
+
97
+ Run tests with coverage:
98
+
99
+ ```bash
100
+ python -m pytest --cov=textutils --cov-branch --cov-report=term-missing
101
+ ```
102
+
103
+ Tests are organized inside each subpackage, close to the corresponding implementation.
104
+
105
+ ### Code quality
106
+
107
+ Format the project with Black:
108
+
109
+ ```bash
110
+ python -m black .
111
+ ```
112
+
113
+ Check formatting without modifying files:
114
+
115
+ ```bash
116
+ python -m black --check .
117
+ ```
118
+
119
+ Check code quality with Ruff:
120
+
121
+ ```bash
122
+ python -m ruff check .
123
+ ```
124
+
125
+ ## Continuous Integration
126
+
127
+ This project uses GitHub Actions to automatically check
128
+ code quality and run the test suite.
129
+
130
+ The CI workflow runs on Pull Requests targeting `main`
131
+ and on pushes to `main`.
132
+
133
+ Four environments are tested:
134
+
135
+ - Ubuntu 22.04 with Python 3.11
136
+ - Ubuntu 22.04 with Python 3.12
137
+ - macOS 15 with Python 3.11
138
+ - macOS 15 with Python 3.12
139
+
140
+ Each CI job installs the project, checks Black and Ruff,
141
+ and executes pytest.
142
+
143
+ ## Pre-commit
144
+
145
+ The project uses pre-commit to run Black and Ruff
146
+ automatically before commits.
147
+
148
+ Install the development dependencies:
149
+
150
+ ```bash
151
+ python -m pip install -e ".[dev]"
152
+ ```
153
+
154
+ Install the Git hook:
155
+
156
+ ```bash
157
+ python -m pre_commit install
158
+ ```
159
+
160
+ Run all hooks manually:
161
+
162
+ ```bash
163
+ python -m pre_commit run --all-files
164
+ ```
165
+
166
+ ## Contributing
167
+
168
+ Contributions are welcome.
169
+
170
+ To contribute, create a branch, make your changes,
171
+ run the tests and open a Pull Request.
172
+
173
+ Please ensure that tests pass and that Black and Ruff
174
+ report no issues before submitting your changes.
175
+
176
+ ## License
177
+
178
+ This project is licensed under the MIT License.
179
+ See the `LICENSE` file for details.
@@ -0,0 +1,22 @@
1
+ CHANGELOG.md
2
+ LICENSE
3
+ MANIFEST.in
4
+ README.md
5
+ pyproject.toml
6
+ textutils/__init__.py
7
+ textutils/casing/__init__.py
8
+ textutils/casing/_capitalize.py
9
+ textutils/casing/tests/test_casing.py
10
+ textutils/counting/__init__.py
11
+ textutils/counting/_count.py
12
+ textutils/counting/_frequency.py
13
+ textutils/counting/tests/test_counting.py
14
+ textutils/counting/tests/test_word_frequency.py
15
+ textutils/transform/__init__.py
16
+ textutils/transform/_reverse.py
17
+ textutils/transform/tests/test_reverse.py
18
+ textutils_nabil184.egg-info/PKG-INFO
19
+ textutils_nabil184.egg-info/SOURCES.txt
20
+ textutils_nabil184.egg-info/dependency_links.txt
21
+ textutils_nabil184.egg-info/requires.txt
22
+ textutils_nabil184.egg-info/top_level.txt
@@ -0,0 +1,7 @@
1
+
2
+ [dev]
3
+ pytest<10,>=8
4
+ pytest-cov<8,>=5
5
+ black==25.1.0
6
+ ruff==0.9.7
7
+ pre-commit<5,>=3