causality-ai 0.1.0a1__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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Contributors
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,41 @@
1
+ Metadata-Version: 2.4
2
+ Name: causality-ai
3
+ Version: 0.1.0a1
4
+ Summary: Plain-text character, word, and line counts
5
+ License-Expression: MIT
6
+ Classifier: Development Status :: 3 - Alpha
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.11
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Dynamic: license-file
13
+
14
+ # causality-ai
15
+
16
+ Version 0.1.0a1 is a small, standalone plain-text statistics utility. It reports
17
+ character, word, and line counts. This alpha has no causal-inference or machine
18
+ learning functionality. Python 3.11 or later; no third-party dependencies.
19
+
20
+ ```sh
21
+ python -m pip install causality-ai==0.1.0a1
22
+ causality-ai notes.txt
23
+ printf 'hello world\n' | causality-ai -
24
+ ```
25
+
26
+ ```python
27
+ from causality_ai import text_stats
28
+
29
+ assert text_stats("hello world\n") == {"characters": 12, "words": 2, "lines": 1}
30
+ ```
31
+
32
+ Characters are Unicode code points, including newline characters, rather than
33
+ bytes or displayed glyphs. Words are whitespace-separated tokens (`str.split`).
34
+ Lines follow `str.splitlines`: empty text has zero lines and a trailing newline
35
+ does not add an empty line. Files must be UTF-8; file bytes are decoded without
36
+ newline conversion. The utility reads the whole text into memory.
37
+
38
+ The command prints a JSON object. Missing files or invalid UTF-8 produce an error
39
+ on stderr and exit status 2. `python -m causality_ai` is also supported.
40
+
41
+ The API may change during alpha development. Licensed under MIT; see LICENSE.
@@ -0,0 +1,28 @@
1
+ # causality-ai
2
+
3
+ Version 0.1.0a1 is a small, standalone plain-text statistics utility. It reports
4
+ character, word, and line counts. This alpha has no causal-inference or machine
5
+ learning functionality. Python 3.11 or later; no third-party dependencies.
6
+
7
+ ```sh
8
+ python -m pip install causality-ai==0.1.0a1
9
+ causality-ai notes.txt
10
+ printf 'hello world\n' | causality-ai -
11
+ ```
12
+
13
+ ```python
14
+ from causality_ai import text_stats
15
+
16
+ assert text_stats("hello world\n") == {"characters": 12, "words": 2, "lines": 1}
17
+ ```
18
+
19
+ Characters are Unicode code points, including newline characters, rather than
20
+ bytes or displayed glyphs. Words are whitespace-separated tokens (`str.split`).
21
+ Lines follow `str.splitlines`: empty text has zero lines and a trailing newline
22
+ does not add an empty line. Files must be UTF-8; file bytes are decoded without
23
+ newline conversion. The utility reads the whole text into memory.
24
+
25
+ The command prints a JSON object. Missing files or invalid UTF-8 produce an error
26
+ on stderr and exit status 2. `python -m causality_ai` is also supported.
27
+
28
+ The API may change during alpha development. Licensed under MIT; see LICENSE.
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "causality-ai"
7
+ version = "0.1.0a1"
8
+ description = "Plain-text character, word, and line counts"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Programming Language :: Python :: 3",
16
+ "Operating System :: OS Independent",
17
+ ]
18
+
19
+ [project.scripts]
20
+ causality-ai = "causality_ai:main"
21
+
22
+ [tool.setuptools]
23
+ py-modules = ["causality_ai"]
24
+ package-dir = {"" = "src"}
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.4
2
+ Name: causality-ai
3
+ Version: 0.1.0a1
4
+ Summary: Plain-text character, word, and line counts
5
+ License-Expression: MIT
6
+ Classifier: Development Status :: 3 - Alpha
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.11
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Dynamic: license-file
13
+
14
+ # causality-ai
15
+
16
+ Version 0.1.0a1 is a small, standalone plain-text statistics utility. It reports
17
+ character, word, and line counts. This alpha has no causal-inference or machine
18
+ learning functionality. Python 3.11 or later; no third-party dependencies.
19
+
20
+ ```sh
21
+ python -m pip install causality-ai==0.1.0a1
22
+ causality-ai notes.txt
23
+ printf 'hello world\n' | causality-ai -
24
+ ```
25
+
26
+ ```python
27
+ from causality_ai import text_stats
28
+
29
+ assert text_stats("hello world\n") == {"characters": 12, "words": 2, "lines": 1}
30
+ ```
31
+
32
+ Characters are Unicode code points, including newline characters, rather than
33
+ bytes or displayed glyphs. Words are whitespace-separated tokens (`str.split`).
34
+ Lines follow `str.splitlines`: empty text has zero lines and a trailing newline
35
+ does not add an empty line. Files must be UTF-8; file bytes are decoded without
36
+ newline conversion. The utility reads the whole text into memory.
37
+
38
+ The command prints a JSON object. Missing files or invalid UTF-8 produce an error
39
+ on stderr and exit status 2. `python -m causality_ai` is also supported.
40
+
41
+ The API may change during alpha development. Licensed under MIT; see LICENSE.
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/causality_ai.py
5
+ src/causality_ai.egg-info/PKG-INFO
6
+ src/causality_ai.egg-info/SOURCES.txt
7
+ src/causality_ai.egg-info/dependency_links.txt
8
+ src/causality_ai.egg-info/entry_points.txt
9
+ src/causality_ai.egg-info/top_level.txt
10
+ tests/test_text_stats.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ causality-ai = causality_ai:main
@@ -0,0 +1 @@
1
+ causality_ai
@@ -0,0 +1,32 @@
1
+ """Plain-text statistics using Python's Unicode string operations."""
2
+
3
+ import argparse
4
+ import json
5
+ from pathlib import Path
6
+ import sys
7
+
8
+
9
+ def text_stats(text: str) -> dict[str, int]:
10
+ """Count Unicode code points, whitespace-separated words, and text lines."""
11
+ if not isinstance(text, str):
12
+ raise TypeError("text must be a string")
13
+ return {
14
+ "characters": len(text),
15
+ "words": len(text.split()),
16
+ "lines": len(text.splitlines()),
17
+ }
18
+
19
+
20
+ def main() -> None:
21
+ parser = argparse.ArgumentParser(description=__doc__)
22
+ parser.add_argument("path", help="UTF-8 text file, or - for standard input")
23
+ args = parser.parse_args()
24
+ try:
25
+ text = sys.stdin.read() if args.path == "-" else Path(args.path).read_bytes().decode("utf-8")
26
+ print(json.dumps(text_stats(text)))
27
+ except (OSError, UnicodeError) as error:
28
+ parser.error(str(error))
29
+
30
+
31
+ if __name__ == "__main__":
32
+ main()
@@ -0,0 +1,23 @@
1
+ import json
2
+ import subprocess
3
+ import sys
4
+ import unittest
5
+
6
+ from causality_ai import text_stats
7
+
8
+
9
+ class TextStatsTests(unittest.TestCase):
10
+ def test_empty_and_unicode(self):
11
+ self.assertEqual(text_stats(""), dict(characters=0, words=0, lines=0))
12
+ self.assertEqual(text_stats("café 猫\r\nnext\n"), dict(characters=13, words=3, lines=2))
13
+
14
+ def test_blank_lines_and_input_type(self):
15
+ self.assertEqual(text_stats("\n\n"), dict(characters=2, words=0, lines=2))
16
+ with self.assertRaises(TypeError):
17
+ text_stats(b"bytes")
18
+
19
+ def test_cli(self):
20
+ result = subprocess.run([sys.executable, "-m", "causality_ai", "-"],
21
+ input="hello world\n", text=True, capture_output=True)
22
+ self.assertEqual(result.returncode, 0, result.stderr)
23
+ self.assertEqual(json.loads(result.stdout), dict(characters=12, words=2, lines=1))