shobdosearch 2.0.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.
- shobdosearch-2.0.0/ARCHITECTURE.md +69 -0
- shobdosearch-2.0.0/CHANGELOG.md +41 -0
- shobdosearch-2.0.0/DATASET.md +40 -0
- shobdosearch-2.0.0/LICENSE +21 -0
- shobdosearch-2.0.0/MANIFEST.in +8 -0
- shobdosearch-2.0.0/PKG-INFO +130 -0
- shobdosearch-2.0.0/README.md +109 -0
- shobdosearch-2.0.0/ROADMAP.md +29 -0
- shobdosearch-2.0.0/app.py +55 -0
- shobdosearch-2.0.0/converter.py +258 -0
- shobdosearch-2.0.0/data/BengaliWordList_112.txt +112944 -0
- shobdosearch-2.0.0/data/BengaliWordList_40.txt +40829 -0
- shobdosearch-2.0.0/data/BengaliWordList_439.txt +439603 -0
- shobdosearch-2.0.0/data/BengaliWordList_48.txt +48749 -0
- shobdosearch-2.0.0/data/banGenerator.csv +111 -0
- shobdosearch-2.0.0/data/ben2bn.csv +2772 -0
- shobdosearch-2.0.0/pyproject.toml +36 -0
- shobdosearch-2.0.0/run.py +32 -0
- shobdosearch-2.0.0/setup.cfg +4 -0
- shobdosearch-2.0.0/shobdosearch.egg-info/PKG-INFO +130 -0
- shobdosearch-2.0.0/shobdosearch.egg-info/SOURCES.txt +28 -0
- shobdosearch-2.0.0/shobdosearch.egg-info/dependency_links.txt +1 -0
- shobdosearch-2.0.0/shobdosearch.egg-info/requires.txt +3 -0
- shobdosearch-2.0.0/shobdosearch.egg-info/top_level.txt +4 -0
- shobdosearch-2.0.0/static/index.html +90 -0
- shobdosearch-2.0.0/static/manifest.json +17 -0
- shobdosearch-2.0.0/static/script.js +152 -0
- shobdosearch-2.0.0/static/style.css +400 -0
- shobdosearch-2.0.0/static/sw.js +20 -0
- shobdosearch-2.0.0/verify.py +83 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# System Architecture: Banglish-to-Bangla NLP Engine
|
|
2
|
+
|
|
3
|
+
This document outlines the technical design, architectural components, and data flow of the ShobdoSearch transliteration engine.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. End-to-End Pipeline
|
|
8
|
+
|
|
9
|
+
The engine combines fast-path seed caching, recursive candidate generation, dynamic vowel-expansion for shorthand words, and weighted multi-tier dictionary scoring.
|
|
10
|
+
|
|
11
|
+
```mermaid
|
|
12
|
+
graph TD
|
|
13
|
+
A[Input: 'tmi kmn aso?'] --> B[Token & Punctuation Splitter]
|
|
14
|
+
B --> C{In Seed Map or In-Memory Cache?}
|
|
15
|
+
C -- Yes --> D[Instant O-1 Return]
|
|
16
|
+
C -- No --> E[Longest-Match Phonetic Splitter]
|
|
17
|
+
E --> F[Recursive Candidate Generator]
|
|
18
|
+
F --> G{Strong Dict Match Found?}
|
|
19
|
+
G -- Yes --> H[Select Lowest-Weight Word]
|
|
20
|
+
G -- No --> I[Dynamic Vowel-Expansion Engine]
|
|
21
|
+
I --> J[Generate Shorthand Permutations]
|
|
22
|
+
J --> K[Weighted Multi-Tier Dict Scorer 464k+ Words]
|
|
23
|
+
K --> L[Select Best Valid Bangla Word]
|
|
24
|
+
H --> M[Store in b2b_cache & Return]
|
|
25
|
+
L --> M
|
|
26
|
+
D --> N[Assemble Sentence & Return]
|
|
27
|
+
M --> N
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 2. Core Architectural Components
|
|
33
|
+
|
|
34
|
+
### A. Fast-Path Base Map (`ben2bn.csv`) & In-Memory Cache (`b2b_cache`)
|
|
35
|
+
- **Base Seed Map**: Contains 2,770+ curated, alphabetically sorted high-frequency words covering 80%+ daily conversational Bengali.
|
|
36
|
+
- **In-Memory Cache**: Dynamically stores transliterated words during runtime to provide $O(1)$ response time for repeated tokens without disk writes.
|
|
37
|
+
|
|
38
|
+
### B. Longest-Match Phonetic Splitter
|
|
39
|
+
- Sorts phonetic keys in `banGenerator.csv` by length descending to match multi-character phonemes (`kh`, `sh`, `th`, `ch`, `gh`, `dh`, `bh`, `ph`, `ng`, `nd`, `st`) before single letters (`k`, `s`, `t`).
|
|
40
|
+
|
|
41
|
+
### C. Recursive Candidate Generator with Diacritic Filtering
|
|
42
|
+
- Explores valid character substitutions per phoneme.
|
|
43
|
+
- Enforces strict orthographic rules:
|
|
44
|
+
- **Dependent Vowels Filter**: Prevents standalone vowel diacritics (kars like `া`, `ে`, `ি`) from appearing at word beginnings.
|
|
45
|
+
- **Implicit Vowel Handling**: Handles implicit vowels (`a`/`o` $\rightarrow$ `অ` / `""`) while preserving explicit hasantas (`্`).
|
|
46
|
+
- **Conjunct Formation**: Automatically generates conjuncts (`যুক্তবর্ণ`) between consonant clusters.
|
|
47
|
+
|
|
48
|
+
### D. Dynamic Vowel-Expansion Engine
|
|
49
|
+
- Recovers informal chat abbreviations and consonant skeletons (e.g. `tmi`, `vlo`, `kmn`, `apnr`, `bndhu`, `rsta`).
|
|
50
|
+
- Detects adjacent consonants, interpolates candidate vowels (`a`, `o`, `e`, `u`, `i`), and scores them against the dictionary.
|
|
51
|
+
|
|
52
|
+
### E. Weighted Multi-Tier Dictionary Validator
|
|
53
|
+
- Validates candidates against **464,411 words** across 4 frequency tiers:
|
|
54
|
+
- Tier 1: Core vocabulary (40k words) - Weight 1
|
|
55
|
+
- Tier 2: Intermediate vocabulary (48k words) - Weight 2
|
|
56
|
+
- Tier 3: Large vocabulary (112k words) - Weight 3
|
|
57
|
+
- Tier 4: Comprehensive lexicon (439k words) - Weight 4
|
|
58
|
+
- Ranks candidate words by priority score with penalties for single-character relics and trailing hasantas.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 3. Data Structures & Performance
|
|
63
|
+
|
|
64
|
+
| Component | Implementation | Complexity | Purpose |
|
|
65
|
+
| :--- | :--- | :--- | :--- |
|
|
66
|
+
| `b2b_map` | Python `dict` | $O(1)$ | 2,770+ high-frequency seed words |
|
|
67
|
+
| `b2b_cache` | Python `dict` | $O(1)$ | In-memory session cache |
|
|
68
|
+
| `generator_map` | Python `dict[str, list[str]]` | $O(L)$ | 111 phoneme rules (7-column aligned) |
|
|
69
|
+
| `word_weights` | Python `dict[str, int]` | $O(1)$ | 464,411 weighted dictionary words |
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## [1.0.0] - 2026-08-22
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- **Dynamic Vowel-Expansion Engine**: Algorithmic recovery for consonant-heavy chat shorthand and abbreviations (`tmi`, `vlo`, `kmn`, `amr`, `tmr`, `apnr`, `bndhu`, `rsta`, `khbr`).
|
|
11
|
+
- **Comprehensive Base Vocabulary**: Expanded and alphabetically sorted [`data/ben2bn.csv`](file:///c:/Users/Khalid/OneDrive/Desktop/Git%20clone/Antigravity/ShobdoSearch/data/ben2bn.csv) to **2,770+** high-frequency words covering 80%+ daily conversational Bengali.
|
|
12
|
+
- **Extended Phonetic Rules**: Added missing phonemes (`v`, `f`, `w`, `x`, `z`, `q`) and digraph conjuncts (`bd`, `bdh`, `kt`, `st`) to `data/banGenerator.csv`.
|
|
13
|
+
- **Comprehensive Test Suite**: Added [`verify.py`](file:///c:/Users/Khalid/OneDrive/Desktop/Git%20clone/Antigravity/ShobdoSearch/verify.py) with 41 core test cases (100% pass rate).
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- **In-Memory Cache Architecture**: Replaced disk-writing in `converter.py` with in-memory `self.b2b_cache` to prevent dataset pollution during runtime.
|
|
17
|
+
- **CSV Standardization**: Cleaned and standardized `data/banGenerator.csv` to an exact 7-column matrix across all 111 phoneme rows.
|
|
18
|
+
- **Dictionary Priority Scoring**: Refined `get_word_priority` with trailing hasanta and 1-letter word penalties, removing detrimental length tie-breakers.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- **Leading Dependent Vowels**: Fixed bug causing vowel signs (kars like `া`, `ে`, `ি`) to attach at the beginning of words (e.g. `eta` → `এটা` instead of `েটা`).
|
|
22
|
+
- **Implicit Vowel Dangling Hasanta**: Fixed implicit vowel suppression to preserve explicit hasanta endings.
|
|
23
|
+
- **API Stats Endpoint**: Fixed dictionary size calculation in `/stats` to accurately return the 464,411 loaded dictionary words instead of 0.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## [0.2.0] - 2026-05-09
|
|
28
|
+
### Changed
|
|
29
|
+
- Refactored logic from Jupyter Notebook to modular `converter.py`.
|
|
30
|
+
- Implemented recursive candidate generation.
|
|
31
|
+
- Replaced linear dictionary search with set-based lookups.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
- Windows UTF-8 terminal encoding support.
|
|
35
|
+
- Longest-match phoneme splitting for `kh`, `sh`.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## [0.1.0] - 2026-05-09
|
|
40
|
+
### Added
|
|
41
|
+
- Initial project structure with `data/` and basic phoneme mappings.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Dataset Documentation: ShobdoSearch
|
|
2
|
+
|
|
3
|
+
This document describes the datasets and corpora used by the ShobdoSearch transliteration engine.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Phonetic Rules Matrix (`banGenerator.csv`)
|
|
8
|
+
The foundational phonetic mapping matrix. Maps Romanized character sequences to corresponding Bengali characters in order of phonetic likelihood.
|
|
9
|
+
- **Structure**: Exactly 7 columns (`EngLit, Ben1, Ben2, Ben3, Ben4, Ben5, Ben6`).
|
|
10
|
+
- **Total Rules**: 111 rules covering vowels, consonants, digraphs (`kh`, `sh`, `th`, `ch`, `gh`, `dh`, `bh`, `ph`, `ng`, `nd`), and conjuncts (`kt`, `bd`, `bdh`, `st`, etc.).
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 2. High-Frequency Baseline Dictionary (`ben2bn.csv`)
|
|
15
|
+
A curated, pre-indexed mapping of high-frequency Banglish words to accurate Bangla Unicode text.
|
|
16
|
+
- **Total Words**: **2,770+ unique mappings**.
|
|
17
|
+
- **Organization**: Alphabetically sorted from A to Z (`a` through `z`).
|
|
18
|
+
- **Coverage**: Top 80%+ of everyday spoken, written, and chat-shorthand vocabulary (pronouns, tenses, question words, numbers, adjectives, common nouns).
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 3. Weighted Dictionary Corpora (`BengaliWordList_*.txt`)
|
|
23
|
+
Used for candidate validation and frequency-based ranking across **464,411 words**:
|
|
24
|
+
|
|
25
|
+
| File Name | Word Count | Tier / Weight | Description |
|
|
26
|
+
| :--- | :--- | :---: | :--- |
|
|
27
|
+
| `BengaliWordList_40.txt` | ~40,000 | Weight 1 | Highest-frequency core vocabulary |
|
|
28
|
+
| `BengaliWordList_48.txt` | ~48,000 | Weight 2 | Common everyday conversational words |
|
|
29
|
+
| `BengaliWordList_112.txt` | ~112,000 | Weight 3 | Intermediate and domain-specific terms |
|
|
30
|
+
| `BengaliWordList_439.txt` | ~439,000 | Weight 4 | Comprehensive Bengali lexicon & inflections |
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 4. In-Memory Session Cache (`b2b_cache`)
|
|
35
|
+
Dynamic in-memory cache managed at runtime by `BanglishConverter`. Stores dynamically transliterated shorthand words for instantaneous $O(1)$ repeated access without modifying files on disk.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 5. Sources & Acknowledgments
|
|
40
|
+
Word lists are sourced, normalized, and compiled from open-source Bengali linguistic corpora and the [BengaliDictionary](https://github.com/MinhasKamal/BengaliDictionary) repository.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Khalid Mahmud & Antora Ghosh
|
|
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,130 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: shobdosearch
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: High-accuracy Banglish-to-Bangla NLP transliteration engine with dynamic shorthand recovery
|
|
5
|
+
Author: Khalid Mahmud
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/skhalidmahmud/ShobdoSearch
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/skhalidmahmud/ShobdoSearch/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
13
|
+
Classifier: Natural Language :: Bengali
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: fastapi>=0.100.0
|
|
18
|
+
Requires-Dist: uvicorn>=0.20.0
|
|
19
|
+
Requires-Dist: pydantic>=2.0.0
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# 🇧🇩 Banglish-to-Bangla: Phonetic Smart Converter
|
|
23
|
+
|
|
24
|
+
[](https://opensource.org/licenses/MIT)
|
|
25
|
+
[](https://www.python.org/downloads/)
|
|
26
|
+
[](#testing--verification)
|
|
27
|
+
|
|
28
|
+
An intelligent, rule-based, and dictionary-validated NLP engine designed to convert Romanized Bengali (Banglish) into authentic Bangla Unicode script. Features dynamic vowel-expansion for informal texting/chat shorthand, weighted multi-dictionary validation across **464,000+ words**, and an alphabetically sorted curated base dictionary of **2,770+ words** covering 80%+ of daily conversational Bengali.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 🚀 Key Features
|
|
33
|
+
|
|
34
|
+
- **Dynamic Vowel-Expansion & Shorthand Recovery**: Seamlessly transliterates informal chat shorthand (e.g., `tmi` → **তুমি**, `vlo` → **ভালো**, `kmn` → **কেমন**, `amr` → **আমার**, `bndhu` → **বন্ধু**, `rsta` → **রাস্তা**).
|
|
35
|
+
- **Curated 2,770+ Baseline Dictionary**: Pre-indexed and alphabetically sorted mapping in [`data/ben2bn.csv`](file:///c:/Users/Khalid/OneDrive/Desktop/Git%20clone/Antigravity/ShobdoSearch/data/ben2bn.csv) covering top 80%+ everyday Bengali vocabulary.
|
|
36
|
+
- **Weighted Multi-Tier Dictionary**: Validates candidates against 464,411 words across 4 frequency tiers for maximum accuracy.
|
|
37
|
+
- **Modern Glassmorphic Web UI**: Responsive web app with live transliteration, history, voice typing, and clipboard utilities.
|
|
38
|
+
- **FastAPI Backend**: Clean RESTful endpoints (`/convert`, `/stats`) for integration into web, mobile, and desktop applications.
|
|
39
|
+
- **In-Memory Cache**: High-speed session caching (`b2b_cache`) without disk pollution.
|
|
40
|
+
- **PWA & Offline Ready**: Service Worker and Web Manifest support for mobile/desktop installability.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 💻 Installation & Quick Start
|
|
45
|
+
|
|
46
|
+
### 1. Clone the Repository
|
|
47
|
+
```bash
|
|
48
|
+
git clone https://github.com/skhalidmahmud/ShobdoSearch.git
|
|
49
|
+
cd ShobdoSearch
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. Start the Web App (Recommended)
|
|
53
|
+
This installs required dependencies and launches the local dev server:
|
|
54
|
+
```bash
|
|
55
|
+
python run.py
|
|
56
|
+
```
|
|
57
|
+
Open your browser at **http://localhost:8080**.
|
|
58
|
+
|
|
59
|
+
### 3. Using Docker
|
|
60
|
+
```bash
|
|
61
|
+
docker build -t banglish-converter .
|
|
62
|
+
docker run -p 8080:8080 banglish-converter
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 4. Interactive CLI Mode
|
|
66
|
+
```bash
|
|
67
|
+
python converter.py
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 🧪 Testing & Verification
|
|
73
|
+
|
|
74
|
+
Run the built-in test suite to verify phonetic accuracy, edge cases, and chat shorthand recovery:
|
|
75
|
+
```bash
|
|
76
|
+
python verify.py
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Output:
|
|
80
|
+
```text
|
|
81
|
+
===========================================
|
|
82
|
+
SHOBDOSEARCH CONVERSION TESTS
|
|
83
|
+
===========================================
|
|
84
|
+
[PASS] ka -> কা
|
|
85
|
+
[PASS] kha -> খা
|
|
86
|
+
[PASS] eta -> এটা
|
|
87
|
+
[PASS] kemon -> কেমন
|
|
88
|
+
[PASS] ami -> আমি
|
|
89
|
+
[PASS] tumi -> তুমি
|
|
90
|
+
[PASS] valo -> ভালো
|
|
91
|
+
[PASS] shundor -> সুন্দর
|
|
92
|
+
[PASS] manush -> মানুষ
|
|
93
|
+
[PASS] ghor -> ঘর
|
|
94
|
+
...
|
|
95
|
+
-------------------------------------------
|
|
96
|
+
Total: 41 | Passed: 41 | Failed: 0
|
|
97
|
+
ALL TESTS PASSED SUCCESSFULLY!
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 🛠️ API Reference
|
|
103
|
+
|
|
104
|
+
- **Interactive Documentation**: `http://localhost:8080/docs`
|
|
105
|
+
- **Transliterate Endpoint**:
|
|
106
|
+
```http
|
|
107
|
+
POST /convert
|
|
108
|
+
Content-Type: application/json
|
|
109
|
+
|
|
110
|
+
{
|
|
111
|
+
"text": "tmi kmn aso? amr khub vlo lagse."
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
**Response**:
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"original": "tmi kmn aso? amr khub vlo lagse.",
|
|
118
|
+
"converted": "তুমি কেমন আছো? আমার খুব ভালো লাগছে."
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
- **Stats Endpoint**:
|
|
122
|
+
```http
|
|
123
|
+
GET /stats
|
|
124
|
+
```
|
|
125
|
+
Returns dictionary size, active rules, and baseline mappings count.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 📄 License
|
|
130
|
+
Distributed under the MIT License. See `LICENSE` for details.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# 🇧🇩 Banglish-to-Bangla: Phonetic Smart Converter
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](#testing--verification)
|
|
6
|
+
|
|
7
|
+
An intelligent, rule-based, and dictionary-validated NLP engine designed to convert Romanized Bengali (Banglish) into authentic Bangla Unicode script. Features dynamic vowel-expansion for informal texting/chat shorthand, weighted multi-dictionary validation across **464,000+ words**, and an alphabetically sorted curated base dictionary of **2,770+ words** covering 80%+ of daily conversational Bengali.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 🚀 Key Features
|
|
12
|
+
|
|
13
|
+
- **Dynamic Vowel-Expansion & Shorthand Recovery**: Seamlessly transliterates informal chat shorthand (e.g., `tmi` → **তুমি**, `vlo` → **ভালো**, `kmn` → **কেমন**, `amr` → **আমার**, `bndhu` → **বন্ধু**, `rsta` → **রাস্তা**).
|
|
14
|
+
- **Curated 2,770+ Baseline Dictionary**: Pre-indexed and alphabetically sorted mapping in [`data/ben2bn.csv`](file:///c:/Users/Khalid/OneDrive/Desktop/Git%20clone/Antigravity/ShobdoSearch/data/ben2bn.csv) covering top 80%+ everyday Bengali vocabulary.
|
|
15
|
+
- **Weighted Multi-Tier Dictionary**: Validates candidates against 464,411 words across 4 frequency tiers for maximum accuracy.
|
|
16
|
+
- **Modern Glassmorphic Web UI**: Responsive web app with live transliteration, history, voice typing, and clipboard utilities.
|
|
17
|
+
- **FastAPI Backend**: Clean RESTful endpoints (`/convert`, `/stats`) for integration into web, mobile, and desktop applications.
|
|
18
|
+
- **In-Memory Cache**: High-speed session caching (`b2b_cache`) without disk pollution.
|
|
19
|
+
- **PWA & Offline Ready**: Service Worker and Web Manifest support for mobile/desktop installability.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 💻 Installation & Quick Start
|
|
24
|
+
|
|
25
|
+
### 1. Clone the Repository
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/skhalidmahmud/ShobdoSearch.git
|
|
28
|
+
cd ShobdoSearch
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 2. Start the Web App (Recommended)
|
|
32
|
+
This installs required dependencies and launches the local dev server:
|
|
33
|
+
```bash
|
|
34
|
+
python run.py
|
|
35
|
+
```
|
|
36
|
+
Open your browser at **http://localhost:8080**.
|
|
37
|
+
|
|
38
|
+
### 3. Using Docker
|
|
39
|
+
```bash
|
|
40
|
+
docker build -t banglish-converter .
|
|
41
|
+
docker run -p 8080:8080 banglish-converter
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 4. Interactive CLI Mode
|
|
45
|
+
```bash
|
|
46
|
+
python converter.py
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 🧪 Testing & Verification
|
|
52
|
+
|
|
53
|
+
Run the built-in test suite to verify phonetic accuracy, edge cases, and chat shorthand recovery:
|
|
54
|
+
```bash
|
|
55
|
+
python verify.py
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Output:
|
|
59
|
+
```text
|
|
60
|
+
===========================================
|
|
61
|
+
SHOBDOSEARCH CONVERSION TESTS
|
|
62
|
+
===========================================
|
|
63
|
+
[PASS] ka -> কা
|
|
64
|
+
[PASS] kha -> খা
|
|
65
|
+
[PASS] eta -> এটা
|
|
66
|
+
[PASS] kemon -> কেমন
|
|
67
|
+
[PASS] ami -> আমি
|
|
68
|
+
[PASS] tumi -> তুমি
|
|
69
|
+
[PASS] valo -> ভালো
|
|
70
|
+
[PASS] shundor -> সুন্দর
|
|
71
|
+
[PASS] manush -> মানুষ
|
|
72
|
+
[PASS] ghor -> ঘর
|
|
73
|
+
...
|
|
74
|
+
-------------------------------------------
|
|
75
|
+
Total: 41 | Passed: 41 | Failed: 0
|
|
76
|
+
ALL TESTS PASSED SUCCESSFULLY!
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 🛠️ API Reference
|
|
82
|
+
|
|
83
|
+
- **Interactive Documentation**: `http://localhost:8080/docs`
|
|
84
|
+
- **Transliterate Endpoint**:
|
|
85
|
+
```http
|
|
86
|
+
POST /convert
|
|
87
|
+
Content-Type: application/json
|
|
88
|
+
|
|
89
|
+
{
|
|
90
|
+
"text": "tmi kmn aso? amr khub vlo lagse."
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
**Response**:
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"original": "tmi kmn aso? amr khub vlo lagse.",
|
|
97
|
+
"converted": "তুমি কেমন আছো? আমার খুব ভালো লাগছে."
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
- **Stats Endpoint**:
|
|
101
|
+
```http
|
|
102
|
+
GET /stats
|
|
103
|
+
```
|
|
104
|
+
Returns dictionary size, active rules, and baseline mappings count.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 📄 License
|
|
109
|
+
Distributed under the MIT License. See `LICENSE` for details.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Project Roadmap
|
|
2
|
+
|
|
3
|
+
The goal of ShobdoSearch is to deliver a robust, high-accuracy, and frictionless Banglish-to-Bangla transliteration engine.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 📍 Phase 1: Foundational Engine (Completed)
|
|
8
|
+
- [x] Longest-match phonetic splitting logic.
|
|
9
|
+
- [x] Recursive candidate generation.
|
|
10
|
+
- [x] Multi-tier dictionary validation across 464k+ words.
|
|
11
|
+
- [x] Modular object-oriented Python architecture (`converter.py`).
|
|
12
|
+
|
|
13
|
+
## 📍 Phase 2: Shorthand & Accuracy Optimization (Completed)
|
|
14
|
+
- [x] **Dynamic Vowel-Expansion Engine**: Algorithmic recovery for consonant-heavy chat slang (`tmi`, `vlo`, `kmn`, `apnr`, `bndhu`, `rsta`).
|
|
15
|
+
- [x] **2,770+ Core Vocabulary Seed Map**: Alphabetically sorted base dictionary covering 80%+ daily vocabulary.
|
|
16
|
+
- [x] **In-Memory Caching**: High-speed session caching (`b2b_cache`) with zero disk pollution.
|
|
17
|
+
- [x] **Orthographic Corrections**: Fixed leading dependent vowel diacritics and dangling hasantas.
|
|
18
|
+
- [x] **Standardized CSV Rulebook**: Aligned 111 phoneme rules into a strict 7-column matrix.
|
|
19
|
+
|
|
20
|
+
## 📍 Phase 3: Web Platform & API (Completed)
|
|
21
|
+
- [x] **Modern Glassmorphic UI**: Responsive web app with live transliteration.
|
|
22
|
+
- [x] **FastAPI Backend**: Fully operational `/convert` and `/stats` endpoints.
|
|
23
|
+
- [x] **Voice Typing Integration**: Web Speech API for voice-to-text input.
|
|
24
|
+
- [x] **PWA & Offline Ready**: Service Worker and Web Manifest for desktop/mobile installation.
|
|
25
|
+
|
|
26
|
+
## 📍 Phase 4: Future Enhancements (Planned)
|
|
27
|
+
- [ ] **Context-Aware Language Model**: Bigram / Trigram n-gram scoring for adjacent word context.
|
|
28
|
+
- [ ] **Browser Extension**: Chrome & Firefox extension for universal typing in web forms.
|
|
29
|
+
- [ ] **Mobile Keyboard Layouts**: Android and iOS keyboard SDK integration.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from fastapi import FastAPI, HTTPException
|
|
2
|
+
from fastapi.middleware.cors import CORSMiddleware
|
|
3
|
+
from fastapi.staticfiles import StaticFiles
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
from converter import BanglishConverter
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
app = FastAPI(title="Banglish-to-Bangla API")
|
|
9
|
+
|
|
10
|
+
# Enable CORS for frontend integration
|
|
11
|
+
app.add_middleware(
|
|
12
|
+
CORSMiddleware,
|
|
13
|
+
allow_origins=["*"],
|
|
14
|
+
allow_methods=["*"],
|
|
15
|
+
allow_headers=["*"],
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
# Initialize the converter
|
|
19
|
+
converter = BanglishConverter()
|
|
20
|
+
|
|
21
|
+
class TranslationRequest(BaseModel):
|
|
22
|
+
text: str
|
|
23
|
+
|
|
24
|
+
@app.post("/convert")
|
|
25
|
+
async def convert_text(request: TranslationRequest):
|
|
26
|
+
if not request.text:
|
|
27
|
+
return {"original": "", "converted": ""}
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
converted = converter.convert_sentence(request.text)
|
|
31
|
+
return {
|
|
32
|
+
"original": request.text,
|
|
33
|
+
"converted": converted
|
|
34
|
+
}
|
|
35
|
+
except Exception as e:
|
|
36
|
+
raise HTTPException(status_code=500, detail=str(e))
|
|
37
|
+
|
|
38
|
+
@app.get("/stats")
|
|
39
|
+
async def get_stats():
|
|
40
|
+
return {
|
|
41
|
+
"known_mappings": len(converter.b2b_map),
|
|
42
|
+
"generator_rules": len(converter.generator_map),
|
|
43
|
+
"dictionaries_loaded": 4,
|
|
44
|
+
"total_words_in_dict": len(converter.word_weights)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# Serve static files (Frontend)
|
|
48
|
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
49
|
+
static_dir = os.path.join(current_dir, "static")
|
|
50
|
+
if os.path.exists(static_dir):
|
|
51
|
+
app.mount("/", StaticFiles(directory=static_dir, html=True), name="static")
|
|
52
|
+
|
|
53
|
+
if __name__ == "__main__":
|
|
54
|
+
import uvicorn
|
|
55
|
+
uvicorn.run(app, host="0.0.0.0", port=8080)
|