kannada-tokenizer 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,105 @@
1
+ Metadata-Version: 2.4
2
+ Name: kannada-tokenizer
3
+ Version: 0.1.0
4
+ Summary: Kannada tokenizer with sandhi splitting for Information Retrieval.
5
+ Author: Hemanth HM
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Topic :: Text Processing :: Linguistic
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+
12
+ # kannada-tokenizer
13
+
14
+ Tokenize Kannada text with sandhi splitting for Information Retrieval.
15
+
16
+ ```bash
17
+ pip install kannada-tokenizer
18
+ ```
19
+
20
+ ## Quick start
21
+
22
+ ```python
23
+ from kannada_tokenizer import tokenize
24
+
25
+ tokenize("ಕನ್ನಡ ಧರ್ಮ")
26
+ # ['kannaḍa', 'dharma']
27
+
28
+ tokenize("vidyālaya")
29
+ # ['vidyālaya']
30
+
31
+ tokenize("mahōtsava")
32
+ # ['maha', 'ōtsava']
33
+ ```
34
+
35
+ `tokenize()` normalizes to ISO 15919, splits on whitespace and punctuation, then applies reverse sandhi rules. Accepts both Kannada script and romanized input.
36
+
37
+ ## Sandhi splitting
38
+
39
+ ```python
40
+ from kannada_tokenizer.sandhi import split_sandhi
41
+
42
+ split_sandhi("rāmāyana") # lōpa sandhi: ā → a + ā
43
+ # ['rāma', 'āyana']
44
+
45
+ split_sandhi("kannaḍa") # no junction found
46
+ # ['kannaḍa']
47
+ ```
48
+
49
+ Rule-based engine covering lōpa sandhi (vowel elision), āgama sandhi (y/v insertion), ādeśa sandhi (guṇa-like substitution), and consonant sandhi (voicing, gemination, nasals). Uses longest-match heuristic when splits are ambiguous.
50
+
51
+ ## Transliteration
52
+
53
+ ```python
54
+ from kannada_tokenizer.transliterate import (
55
+ kannada_to_iso15919,
56
+ iso15919_to_kannada,
57
+ is_kannada,
58
+ )
59
+
60
+ kannada_to_iso15919("ಬೆಂಗಳೂರು")
61
+ # 'beṃgaḻūru'
62
+
63
+ iso15919_to_kannada("kannaḍa")
64
+ # 'ಕನ್ನಡ'
65
+
66
+ is_kannada("ಕನ್ನಡ")
67
+ # True
68
+ ```
69
+
70
+ Handles Kannada's short/long e/o distinction (ಎ→e vs ಏ→ē) and the retroflex lateral ಳ→ḻ unique to Dravidian.
71
+
72
+ ## Word-level tokenization
73
+
74
+ ```python
75
+ from kannada_tokenizer.tokenizer import tokenize_words
76
+
77
+ tokenize_words("vidyālaya namaḥ")
78
+ # ['vidyālaya', 'namaḥ']
79
+ ```
80
+
81
+ `tokenize_words()` splits on whitespace and punctuation only — no sandhi splitting.
82
+
83
+ ## CLI
84
+
85
+ ```bash
86
+ kannada-tokenize "ಕನ್ನಡ ಧರ್ಮ"
87
+ # kannaḍa
88
+ # dharma
89
+
90
+ echo "vidyālaya" | kannada-tokenize
91
+ # vidyālaya
92
+
93
+ kannada-tokenize --no-sandhi "mahōtsava"
94
+ # mahōtsava
95
+
96
+ kannada-tokenize -s " " "dharma yōga"
97
+ # dharma yōga
98
+ ```
99
+
100
+ - `--no-sandhi` — word-level only, skip sandhi splitting
101
+ - `--separator SEP` — output separator (default: newline)
102
+
103
+ ## License
104
+
105
+ MIT © [Hemanth.HM](https://h3manth.com)
@@ -0,0 +1,94 @@
1
+ # kannada-tokenizer
2
+
3
+ Tokenize Kannada text with sandhi splitting for Information Retrieval.
4
+
5
+ ```bash
6
+ pip install kannada-tokenizer
7
+ ```
8
+
9
+ ## Quick start
10
+
11
+ ```python
12
+ from kannada_tokenizer import tokenize
13
+
14
+ tokenize("ಕನ್ನಡ ಧರ್ಮ")
15
+ # ['kannaḍa', 'dharma']
16
+
17
+ tokenize("vidyālaya")
18
+ # ['vidyālaya']
19
+
20
+ tokenize("mahōtsava")
21
+ # ['maha', 'ōtsava']
22
+ ```
23
+
24
+ `tokenize()` normalizes to ISO 15919, splits on whitespace and punctuation, then applies reverse sandhi rules. Accepts both Kannada script and romanized input.
25
+
26
+ ## Sandhi splitting
27
+
28
+ ```python
29
+ from kannada_tokenizer.sandhi import split_sandhi
30
+
31
+ split_sandhi("rāmāyana") # lōpa sandhi: ā → a + ā
32
+ # ['rāma', 'āyana']
33
+
34
+ split_sandhi("kannaḍa") # no junction found
35
+ # ['kannaḍa']
36
+ ```
37
+
38
+ Rule-based engine covering lōpa sandhi (vowel elision), āgama sandhi (y/v insertion), ādeśa sandhi (guṇa-like substitution), and consonant sandhi (voicing, gemination, nasals). Uses longest-match heuristic when splits are ambiguous.
39
+
40
+ ## Transliteration
41
+
42
+ ```python
43
+ from kannada_tokenizer.transliterate import (
44
+ kannada_to_iso15919,
45
+ iso15919_to_kannada,
46
+ is_kannada,
47
+ )
48
+
49
+ kannada_to_iso15919("ಬೆಂಗಳೂರು")
50
+ # 'beṃgaḻūru'
51
+
52
+ iso15919_to_kannada("kannaḍa")
53
+ # 'ಕನ್ನಡ'
54
+
55
+ is_kannada("ಕನ್ನಡ")
56
+ # True
57
+ ```
58
+
59
+ Handles Kannada's short/long e/o distinction (ಎ→e vs ಏ→ē) and the retroflex lateral ಳ→ḻ unique to Dravidian.
60
+
61
+ ## Word-level tokenization
62
+
63
+ ```python
64
+ from kannada_tokenizer.tokenizer import tokenize_words
65
+
66
+ tokenize_words("vidyālaya namaḥ")
67
+ # ['vidyālaya', 'namaḥ']
68
+ ```
69
+
70
+ `tokenize_words()` splits on whitespace and punctuation only — no sandhi splitting.
71
+
72
+ ## CLI
73
+
74
+ ```bash
75
+ kannada-tokenize "ಕನ್ನಡ ಧರ್ಮ"
76
+ # kannaḍa
77
+ # dharma
78
+
79
+ echo "vidyālaya" | kannada-tokenize
80
+ # vidyālaya
81
+
82
+ kannada-tokenize --no-sandhi "mahōtsava"
83
+ # mahōtsava
84
+
85
+ kannada-tokenize -s " " "dharma yōga"
86
+ # dharma yōga
87
+ ```
88
+
89
+ - `--no-sandhi` — word-level only, skip sandhi splitting
90
+ - `--separator SEP` — output separator (default: newline)
91
+
92
+ ## License
93
+
94
+ MIT © [Hemanth.HM](https://h3manth.com)
@@ -0,0 +1,22 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "kannada-tokenizer"
7
+ version = "0.1.0"
8
+ description = "Kannada tokenizer with sandhi splitting for Information Retrieval."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ authors = [{name = "Hemanth HM"}]
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "Topic :: Text Processing :: Linguistic",
16
+ ]
17
+
18
+ [project.scripts]
19
+ kannada-tokenize = "kannada_tokenizer.cli:main"
20
+
21
+ [tool.setuptools.packages.find]
22
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,6 @@
1
+ """Kannada tokenizer with sandhi splitting for Information Retrieval."""
2
+
3
+ from kannada_tokenizer.tokenizer import tokenize
4
+
5
+ __version__ = "0.1.0"
6
+ __all__ = ["tokenize"]
@@ -0,0 +1,65 @@
1
+ """Command-line interface for the Kannada tokenizer."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import sys
7
+
8
+ from .tokenizer import tokenize, tokenize_words
9
+
10
+
11
+ def _build_parser() -> argparse.ArgumentParser:
12
+ """Build and return the argument parser."""
13
+ parser = argparse.ArgumentParser(
14
+ prog="kannada-tokenize",
15
+ description="Tokenize Kannada text with optional sandhi splitting.",
16
+ )
17
+ parser.add_argument(
18
+ "text",
19
+ nargs="?",
20
+ default=None,
21
+ help="Kannada text to tokenize. Reads from stdin if omitted.",
22
+ )
23
+ parser.add_argument(
24
+ "--no-sandhi",
25
+ action="store_true",
26
+ default=False,
27
+ help="Disable sandhi splitting (word-level tokenization only).",
28
+ )
29
+ parser.add_argument(
30
+ "--separator",
31
+ "-s",
32
+ default="\n",
33
+ help="Token separator in output (default: newline).",
34
+ )
35
+ return parser
36
+
37
+
38
+ def main(argv: list[str] | None = None) -> None:
39
+ """Entry point for the ``kannada-tokenize`` CLI.
40
+
41
+ Args:
42
+ argv: Optional argument list (defaults to ``sys.argv[1:]``).
43
+ """
44
+ parser = _build_parser()
45
+ args = parser.parse_args(argv)
46
+
47
+ # Determine input source
48
+ if args.text is not None:
49
+ text: str = args.text
50
+ elif not sys.stdin.isatty():
51
+ text = sys.stdin.read()
52
+ else:
53
+ parser.print_help()
54
+ sys.exit(1)
55
+
56
+ # Select tokenization strategy
57
+ tok_fn = tokenize_words if args.no_sandhi else tokenize
58
+ tokens: list[str] = tok_fn(text)
59
+
60
+ if tokens:
61
+ print(args.separator.join(tokens))
62
+
63
+
64
+ if __name__ == "__main__":
65
+ main()