ablt 2.0.0__py3-none-any.whl
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.
- ablt/__init__.py +13 -0
- ablt/cli.py +59 -0
- ablt/models/README.txt +4 -0
- ablt/models/SHA256SUMS +2 -0
- ablt/models/ablt-luganda-v2.joiners.json +982 -0
- ablt/models/ablt-luganda-v2.model +0 -0
- ablt/rules.py +90 -0
- ablt/segmenter.py +78 -0
- ablt/tokenizer.py +139 -0
- ablt-2.0.0.dist-info/METADATA +149 -0
- ablt-2.0.0.dist-info/RECORD +16 -0
- ablt-2.0.0.dist-info/WHEEL +5 -0
- ablt-2.0.0.dist-info/entry_points.txt +2 -0
- ablt-2.0.0.dist-info/licenses/LICENSE +194 -0
- ablt-2.0.0.dist-info/licenses/NOTICE +44 -0
- ablt-2.0.0.dist-info/top_level.txt +1 -0
ablt/__init__.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright 2025-2026 Mathew Sekanjako and Psalms23Wave LLC
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
"""ABLT: a grammar-first tokenizer for Luganda and other Bantu languages."""
|
|
4
|
+
|
|
5
|
+
from .segmenter import cut, show_cuts, split_word
|
|
6
|
+
from .tokenizer import ABLT
|
|
7
|
+
|
|
8
|
+
__version__ = "2.0.0"
|
|
9
|
+
__author__ = "Mathew Sekanjako"
|
|
10
|
+
__copyright__ = "Copyright 2025-2026 Mathew Sekanjako and Psalms23Wave LLC"
|
|
11
|
+
__license__ = "Apache-2.0"
|
|
12
|
+
__url__ = "https://www.sekanjakomathew.com"
|
|
13
|
+
__all__ = ["ABLT", "cut", "show_cuts", "split_word"]
|
ablt/cli.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Copyright 2025-2026 Mathew Sekanjako and Psalms23Wave LLC
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
"""Use ABLT from the terminal.
|
|
4
|
+
|
|
5
|
+
ablt "Abantu basoma ebitabo." show the pieces
|
|
6
|
+
ablt --cuts "Abantu basoma ebitabo." show where the grammar cuts fall
|
|
7
|
+
ablt --ids "Abantu basoma ebitabo." show the piece numbers
|
|
8
|
+
ablt < story.txt read lines from a file
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import argparse
|
|
14
|
+
import sys
|
|
15
|
+
|
|
16
|
+
from . import __version__
|
|
17
|
+
from .segmenter import show_cuts
|
|
18
|
+
from .tokenizer import ABLT
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def main(arguments: list[str] | None = None) -> int:
|
|
22
|
+
parser = argparse.ArgumentParser(
|
|
23
|
+
prog="ablt",
|
|
24
|
+
description="ABLT: a grammar-first tokenizer for Luganda, by Mathew Sekanjako (Psalms23Wave LLC).",
|
|
25
|
+
)
|
|
26
|
+
parser.add_argument(
|
|
27
|
+
"text",
|
|
28
|
+
nargs="*",
|
|
29
|
+
help="text to tokenize; if left out, lines are read from standard input",
|
|
30
|
+
)
|
|
31
|
+
output = parser.add_mutually_exclusive_group()
|
|
32
|
+
output.add_argument(
|
|
33
|
+
"--cuts", action="store_true", help="show the text with | at each grammar cut"
|
|
34
|
+
)
|
|
35
|
+
output.add_argument(
|
|
36
|
+
"--ids", action="store_true", help="show piece numbers instead of pieces"
|
|
37
|
+
)
|
|
38
|
+
credit = f"ablt {__version__}. Copyright 2025-2026 Mathew Sekanjako and Psalms23Wave LLC. Apache-2.0."
|
|
39
|
+
parser.add_argument("--version", action="version", version=credit)
|
|
40
|
+
options = parser.parse_args(arguments)
|
|
41
|
+
|
|
42
|
+
lines = (
|
|
43
|
+
[" ".join(options.text)]
|
|
44
|
+
if options.text
|
|
45
|
+
else (line.rstrip("\n") for line in sys.stdin)
|
|
46
|
+
)
|
|
47
|
+
tokenizer = None if options.cuts else ABLT()
|
|
48
|
+
for line in lines:
|
|
49
|
+
if options.cuts:
|
|
50
|
+
print(show_cuts(line))
|
|
51
|
+
elif options.ids:
|
|
52
|
+
print(" ".join(str(index) for index in tokenizer.encode(line)))
|
|
53
|
+
else:
|
|
54
|
+
print(" ".join(tokenizer.tokenize(line)))
|
|
55
|
+
return 0
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
if __name__ == "__main__":
|
|
59
|
+
raise SystemExit(main())
|
ablt/models/README.txt
ADDED
ablt/models/SHA256SUMS
ADDED