telugu-language-tools 5.0.1__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.
Potentially problematic release.
This version of telugu-language-tools might be problematic. Click here for more details.
- telugu_engine/__init__.py +190 -0
- telugu_engine/cli.py +111 -0
- telugu_engine/enhanced_tense.py +854 -0
- telugu_engine/grammar.py +474 -0
- telugu_engine/phonetic_matrix.py +82 -0
- telugu_engine/tense_engine.py +391 -0
- telugu_engine/transliterator.py +676 -0
- telugu_engine/v3_validator.py +413 -0
- telugu_language_tools-5.0.1.dist-info/METADATA +398 -0
- telugu_language_tools-5.0.1.dist-info/RECORD +13 -0
- telugu_language_tools-5.0.1.dist-info/WHEEL +5 -0
- telugu_language_tools-5.0.1.dist-info/licenses/LICENSE +21 -0
- telugu_language_tools-5.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Telugu Library v5.0 - Modern Telugu Engine
|
|
3
|
+
===========================================
|
|
4
|
+
|
|
5
|
+
Complete v3.0 compliant Telugu processing library with full v3.0 support:
|
|
6
|
+
- transliterator: Modern transliteration (no archaic letters)
|
|
7
|
+
- grammar: Modern grammar (verbs, cases, SOV)
|
|
8
|
+
- tense_engine: Integrated tense processing
|
|
9
|
+
- enhanced_tense: v5.0 enhanced tense (present continuous, all tenses)
|
|
10
|
+
- v3_validator: v3.0 compliance validation
|
|
11
|
+
- phonetic_matrix: Phonetic normalization
|
|
12
|
+
|
|
13
|
+
All modules use modern Vyāvahārika standards:
|
|
14
|
+
- Modern pronouns: నేను, వాళ్ళు (NOT ఏను, వాండ్రు)
|
|
15
|
+
- Modern verbs: చేసినాను (NOT చేసితిని)
|
|
16
|
+
- 4-case system: Nominative, Accusative, Dative, Locative
|
|
17
|
+
- SOV syntax
|
|
18
|
+
- No archaic letters: ఱ, ఌ, ౡ, ౘ, ౙ, ఀ, ౝ
|
|
19
|
+
|
|
20
|
+
v5.0 Features:
|
|
21
|
+
- Present continuous tense: "I am going" → నేను వెళ్తున్నాను
|
|
22
|
+
- All 16 v3.0 sections implemented
|
|
23
|
+
- Comprehensive test suites
|
|
24
|
+
- Translation challenges solved
|
|
25
|
+
- Error prevention checklist
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
# Main API - transliteration
|
|
29
|
+
from .transliterator import (
|
|
30
|
+
eng_to_telugu,
|
|
31
|
+
transliterate_word,
|
|
32
|
+
transliterate_sentence,
|
|
33
|
+
validate_v3_compliance as _validate_translit_v3
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# Grammar module
|
|
37
|
+
from .grammar import (
|
|
38
|
+
conjugate_verb,
|
|
39
|
+
apply_case,
|
|
40
|
+
convert_svo_to_soV,
|
|
41
|
+
build_telugu_sentence,
|
|
42
|
+
apply_sandhi,
|
|
43
|
+
check_vowel_harmony,
|
|
44
|
+
apply_vowel_harmony
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# Tense engine
|
|
48
|
+
from .tense_engine import (
|
|
49
|
+
detect_tense,
|
|
50
|
+
detect_person,
|
|
51
|
+
conjugate_english_verb,
|
|
52
|
+
process_simple_sentence,
|
|
53
|
+
process_complex_sentence,
|
|
54
|
+
apply_formality,
|
|
55
|
+
validate_tense_conjugation
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# v3.0 validator
|
|
59
|
+
from .v3_validator import (
|
|
60
|
+
validate_script,
|
|
61
|
+
validate_pronouns,
|
|
62
|
+
validate_verbs,
|
|
63
|
+
validate_case_markers,
|
|
64
|
+
validate_vowel_harmony,
|
|
65
|
+
validate_v3_compliance,
|
|
66
|
+
get_compliance_report,
|
|
67
|
+
test_v3_compliance
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# Enhanced tense engine (v5.0 - full v3.0 support)
|
|
71
|
+
from .enhanced_tense import (
|
|
72
|
+
translate_sentence,
|
|
73
|
+
conjugate_present_continuous,
|
|
74
|
+
conjugate_past_tense,
|
|
75
|
+
conjugate_verb_enhanced,
|
|
76
|
+
detect_tense_enhanced,
|
|
77
|
+
detect_person,
|
|
78
|
+
validate_translation_output,
|
|
79
|
+
run_comprehensive_test_suite
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# Phonetic matrix (kept for compatibility)
|
|
83
|
+
from .phonetic_matrix import map_sound
|
|
84
|
+
|
|
85
|
+
# Public API
|
|
86
|
+
__version__ = "5.0.1"
|
|
87
|
+
__author__ = "Telugu Library v3.0"
|
|
88
|
+
__email__ = "support@telugulibrary.org"
|
|
89
|
+
|
|
90
|
+
__all__ = [
|
|
91
|
+
# Transliteration
|
|
92
|
+
"eng_to_telugu",
|
|
93
|
+
"transliterate_word",
|
|
94
|
+
"transliterate_sentence",
|
|
95
|
+
|
|
96
|
+
# Grammar
|
|
97
|
+
"conjugate_verb",
|
|
98
|
+
"apply_case",
|
|
99
|
+
"convert_svo_to_soV",
|
|
100
|
+
"build_telugu_sentence",
|
|
101
|
+
"apply_sandhi",
|
|
102
|
+
"check_vowel_harmony",
|
|
103
|
+
"apply_vowel_harmony",
|
|
104
|
+
|
|
105
|
+
# Tense
|
|
106
|
+
"detect_tense",
|
|
107
|
+
"detect_person",
|
|
108
|
+
"conjugate_english_verb",
|
|
109
|
+
"process_simple_sentence",
|
|
110
|
+
"process_complex_sentence",
|
|
111
|
+
"apply_formality",
|
|
112
|
+
"validate_tense_conjugation",
|
|
113
|
+
|
|
114
|
+
# Enhanced Tense (v5.0 - Full v3.0 Support)
|
|
115
|
+
"translate_sentence",
|
|
116
|
+
"conjugate_present_continuous",
|
|
117
|
+
"conjugate_past_tense",
|
|
118
|
+
"conjugate_verb_enhanced",
|
|
119
|
+
"detect_tense_enhanced",
|
|
120
|
+
"validate_translation_output",
|
|
121
|
+
"run_comprehensive_test_suite",
|
|
122
|
+
|
|
123
|
+
# Validation
|
|
124
|
+
"validate_v3_compliance",
|
|
125
|
+
"get_compliance_report",
|
|
126
|
+
"test_v3_compliance",
|
|
127
|
+
"validate_script",
|
|
128
|
+
"validate_pronouns",
|
|
129
|
+
"validate_verbs",
|
|
130
|
+
"validate_case_markers",
|
|
131
|
+
"validate_vowel_harmony",
|
|
132
|
+
|
|
133
|
+
# Legacy (for compatibility)
|
|
134
|
+
"map_sound",
|
|
135
|
+
]
|
|
136
|
+
|
|
137
|
+
# Convenience functions
|
|
138
|
+
def translate(text: str, include_grammar: bool = False) -> str:
|
|
139
|
+
"""
|
|
140
|
+
High-level translation function.
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
text: English text to translate
|
|
144
|
+
include_grammar: If True, apply full grammar (cases, SOV, etc.)
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
Telugu text
|
|
148
|
+
"""
|
|
149
|
+
if include_grammar:
|
|
150
|
+
# Apply full grammar processing
|
|
151
|
+
return process_simple_sentence(text)
|
|
152
|
+
else:
|
|
153
|
+
# Just transliterate
|
|
154
|
+
return eng_to_telugu(text)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def is_v3_compliant(text: str) -> bool:
|
|
158
|
+
"""
|
|
159
|
+
Check if text is v3.0 compliant.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
text: Telugu text to check
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
True if compliant, False otherwise
|
|
166
|
+
"""
|
|
167
|
+
result = validate_v3_compliance(text)
|
|
168
|
+
return result['is_compliant']
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def get_compliance_score(text: str) -> float:
|
|
172
|
+
"""
|
|
173
|
+
Get v3.0 compliance score (0-100).
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
text: Telugu text to check
|
|
177
|
+
|
|
178
|
+
Returns:
|
|
179
|
+
Compliance score (0-100)
|
|
180
|
+
"""
|
|
181
|
+
result = validate_v3_compliance(text)
|
|
182
|
+
return result['score']
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
# Add to public API
|
|
186
|
+
__all__.extend([
|
|
187
|
+
"translate",
|
|
188
|
+
"is_v3_compliant",
|
|
189
|
+
"get_compliance_score",
|
|
190
|
+
])
|
telugu_engine/cli.py
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Command-line interface for Telugu Engine
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import sys
|
|
8
|
+
from typing import List, Tuple
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def parse_args(argv: List[str]) -> Tuple[str, str, str, bool]:
|
|
12
|
+
"""
|
|
13
|
+
Parse command-line arguments.
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
(subject, root, tense, auto_mode)
|
|
17
|
+
"""
|
|
18
|
+
auto_mode = False
|
|
19
|
+
|
|
20
|
+
# Check for --auto flag
|
|
21
|
+
if "--auto" in argv:
|
|
22
|
+
auto_mode = True
|
|
23
|
+
argv = [arg for arg in argv if arg != "--auto"]
|
|
24
|
+
|
|
25
|
+
# Check for --help flag
|
|
26
|
+
if "--help" in argv or "-h" in argv:
|
|
27
|
+
print("""
|
|
28
|
+
Telugu Engine - Convert English to Telugu with tense formation
|
|
29
|
+
|
|
30
|
+
Usage:
|
|
31
|
+
python -m telugu_engine.cli <subject> <root> <tense> [--auto]
|
|
32
|
+
|
|
33
|
+
Arguments:
|
|
34
|
+
subject The subject (e.g., 'amma', 'nenu')
|
|
35
|
+
root The verb root (e.g., 'tina', 'ceyu')
|
|
36
|
+
tense The tense (past, present, future)
|
|
37
|
+
|
|
38
|
+
Options:
|
|
39
|
+
--auto Automatically select the first option (non-interactive mode)
|
|
40
|
+
--help, -h Show this help message
|
|
41
|
+
|
|
42
|
+
Examples:
|
|
43
|
+
python -m telugu_engine.cli amma tina past
|
|
44
|
+
python -m telugu_engine.cli amma tina past --auto
|
|
45
|
+
""")
|
|
46
|
+
sys.exit(0)
|
|
47
|
+
|
|
48
|
+
# Check if we have enough args
|
|
49
|
+
if len(argv) < 3:
|
|
50
|
+
print("Error: Need 3 arguments: <subject> <root> <tense>")
|
|
51
|
+
print("Use --help for usage information")
|
|
52
|
+
sys.exit(2)
|
|
53
|
+
|
|
54
|
+
subject, root, tense = argv[0], argv[1], argv[2]
|
|
55
|
+
return subject, root, tense, auto_mode
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def main(argv: List[str] | None = None) -> int:
|
|
59
|
+
"""Main CLI entry point."""
|
|
60
|
+
argv = argv if argv is not None else sys.argv[1:]
|
|
61
|
+
|
|
62
|
+
try:
|
|
63
|
+
subject, root, tense, auto_mode = parse_args(argv)
|
|
64
|
+
except SystemExit:
|
|
65
|
+
# Help was shown, exit with 0
|
|
66
|
+
return 0
|
|
67
|
+
|
|
68
|
+
from .phonetic_matrix import map_sound
|
|
69
|
+
from .tense_engine import build_tense
|
|
70
|
+
from .transliterator import eng_to_telugu
|
|
71
|
+
from .choice import choose
|
|
72
|
+
|
|
73
|
+
# Normalize phonetics first
|
|
74
|
+
subject_norm = map_sound(subject)
|
|
75
|
+
root_norm = map_sound(root)
|
|
76
|
+
|
|
77
|
+
# Build tense form
|
|
78
|
+
try:
|
|
79
|
+
tense_form = build_tense(root_norm, tense)
|
|
80
|
+
except Exception as e:
|
|
81
|
+
print(f"Error forming tense: {e}")
|
|
82
|
+
return 1
|
|
83
|
+
|
|
84
|
+
# Compose sentence candidates (simple variants)
|
|
85
|
+
options = [
|
|
86
|
+
f"{subject_norm} {tense_form}", # subject first
|
|
87
|
+
f"{tense_form} {subject_norm}", # verb first
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
# Select final option
|
|
91
|
+
if auto_mode:
|
|
92
|
+
final = options[0] # Auto-select first option
|
|
93
|
+
else:
|
|
94
|
+
final = choose(options)
|
|
95
|
+
if not final:
|
|
96
|
+
print("No selection made.")
|
|
97
|
+
return 1
|
|
98
|
+
|
|
99
|
+
# Transliterate to Telugu script
|
|
100
|
+
try:
|
|
101
|
+
final_telugu = eng_to_telugu(final)
|
|
102
|
+
print("Output:", final_telugu)
|
|
103
|
+
except Exception as e:
|
|
104
|
+
print(f"Error during transliteration: {e}")
|
|
105
|
+
return 1
|
|
106
|
+
|
|
107
|
+
return 0
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
if __name__ == "__main__":
|
|
111
|
+
raise SystemExit(main())
|