wordstats-mg 0.1.0__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,6 @@
1
+ .venv/
2
+ dist/
3
+ build/
4
+ __pycache__/
5
+ *.egg-info/
6
+ .pytest_cache/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2026] [Mani Gupta]
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,26 @@
1
+ Metadata-Version: 2.5
2
+ Name: wordstats-mg
3
+ Version: 0.1.0
4
+ Summary: A tiny library for word count, reading time and most common word
5
+ Project-URL: Homepage, https://github.com/Mani010903/wordstats-mg
6
+ Author-email: Mani Gupta <manigupta617291@gmail.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Keywords: statistics,text,words
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+
15
+ # wordstats-mg
16
+
17
+ A tiny library to analyse text.
18
+
19
+ ## Usage
20
+
21
+ from wordstats_mg import word_count, reading_time, most_common_word
22
+
23
+ text = "the cat and the hat"
24
+ print(word_count(text)) # 5
25
+ print(reading_time(text)) # 0.03
26
+ print(most_common_word(text)) # the
@@ -0,0 +1,12 @@
1
+ # wordstats-mg
2
+
3
+ A tiny library to analyse text.
4
+
5
+ ## Usage
6
+
7
+ from wordstats_mg import word_count, reading_time, most_common_word
8
+
9
+ text = "the cat and the hat"
10
+ print(word_count(text)) # 5
11
+ print(reading_time(text)) # 0.03
12
+ print(most_common_word(text)) # the
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "wordstats-mg"
7
+ version = "0.1.0"
8
+ description = "A tiny library for word count, reading time and most common word"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ authors = [{ name = "Mani Gupta", email = "manigupta617291@gmail.com" }]
13
+ keywords = ["text", "words", "statistics"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Operating System :: OS Independent",
17
+ ]
18
+ dependencies = []
19
+
20
+ [project.urls]
21
+ Homepage = "https://github.com/Mani010903/wordstats-mg"
@@ -0,0 +1 @@
1
+ from .core import word_count, reading_time, most_common_word
@@ -0,0 +1,26 @@
1
+ import re
2
+ from collections import Counter
3
+
4
+
5
+ def _get_words(text):
6
+ """Split text into a list of lowercase words."""
7
+ return re.findall(r"[a-zA-Z']+", text.lower())
8
+
9
+
10
+ def word_count(text):
11
+ """Return how many words are in the text."""
12
+ return len(_get_words(text))
13
+
14
+
15
+ def reading_time(text, wpm=200):
16
+ """Return estimated reading time in minutes (default 200 words/min)."""
17
+ minutes = word_count(text) / wpm
18
+ return round(minutes, 2)
19
+
20
+
21
+ def most_common_word(text):
22
+ """Return the most frequent word, or None if the text has no words."""
23
+ words = _get_words(text)
24
+ if not words:
25
+ return None
26
+ return Counter(words).most_common(1)[0][0]
@@ -0,0 +1,29 @@
1
+ from wordstats_mg import word_count, reading_time, most_common_word
2
+
3
+
4
+ def test_word_count_basic():
5
+ assert word_count("hello big world") == 3
6
+
7
+
8
+ def test_word_count_ignores_punctuation_and_case():
9
+ assert word_count("Hello, HELLO! hello.") == 3
10
+
11
+
12
+ def test_word_count_empty():
13
+ assert word_count("") == 0
14
+
15
+
16
+ def test_reading_time():
17
+ assert reading_time("word " * 200) == 1.0
18
+
19
+
20
+ def test_reading_time_custom_wpm():
21
+ assert reading_time("word " * 300, wpm=300) == 1.0
22
+
23
+
24
+ def test_most_common_word():
25
+ assert most_common_word("the cat and the hat") == "the"
26
+
27
+
28
+ def test_most_common_word_empty():
29
+ assert most_common_word("") is None