├── src ├── core │ ├── __init__.py │ ├── __pycache__ │ │ ├── Engine.cpython-35.pyc │ │ ├── Engine.cpython-36.pyc │ │ ├── LangMap.cpython-35.pyc │ │ ├── LangMap.cpython-36.pyc │ │ ├── Utility.cpython-35.pyc │ │ ├── Utility.cpython-36.pyc │ │ ├── __init__.cpython-35.pyc │ │ └── __init__.cpython-36.pyc │ ├── Utility.py │ ├── LangMap.py │ └── Engine.py ├── pencil.png ├── __pycache__ │ ├── Window.cpython-35.pyc │ └── Window.cpython-36.pyc ├── app.py ├── Window.py └── assets │ └── json │ └── english_to_bangla_map.json ├── .gitignore └── README.md /src/core/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | venv -------------------------------------------------------------------------------- /src/pencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alimranahmed/Chondralok/HEAD/src/pencil.png -------------------------------------------------------------------------------- /src/__pycache__/Window.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alimranahmed/Chondralok/HEAD/src/__pycache__/Window.cpython-35.pyc -------------------------------------------------------------------------------- /src/__pycache__/Window.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alimranahmed/Chondralok/HEAD/src/__pycache__/Window.cpython-36.pyc -------------------------------------------------------------------------------- /src/core/__pycache__/Engine.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alimranahmed/Chondralok/HEAD/src/core/__pycache__/Engine.cpython-35.pyc -------------------------------------------------------------------------------- /src/core/__pycache__/Engine.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alimranahmed/Chondralok/HEAD/src/core/__pycache__/Engine.cpython-36.pyc -------------------------------------------------------------------------------- /src/core/__pycache__/LangMap.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alimranahmed/Chondralok/HEAD/src/core/__pycache__/LangMap.cpython-35.pyc -------------------------------------------------------------------------------- /src/core/__pycache__/LangMap.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alimranahmed/Chondralok/HEAD/src/core/__pycache__/LangMap.cpython-36.pyc -------------------------------------------------------------------------------- /src/core/__pycache__/Utility.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alimranahmed/Chondralok/HEAD/src/core/__pycache__/Utility.cpython-35.pyc -------------------------------------------------------------------------------- /src/core/__pycache__/Utility.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alimranahmed/Chondralok/HEAD/src/core/__pycache__/Utility.cpython-36.pyc -------------------------------------------------------------------------------- /src/core/__pycache__/__init__.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alimranahmed/Chondralok/HEAD/src/core/__pycache__/__init__.cpython-35.pyc -------------------------------------------------------------------------------- /src/core/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alimranahmed/Chondralok/HEAD/src/core/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Chondralok 2 | A program to write Bangala using phonetic 3 | 4 | Primary purpose of this project is to make a system independent Bangla writing software. 5 | -------------------------------------------------------------------------------- /src/app.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from src.Window import Window 4 | 5 | 6 | def run(): 7 | app = QtWidgets.QApplication(sys.argv) 8 | window = Window() 9 | sys.exit(app.exec_()) 10 | 11 | run() 12 | -------------------------------------------------------------------------------- /src/core/Utility.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import json 3 | 4 | class Utility: 5 | @staticmethod 6 | def log(class_name, method_name, message): 7 | log_msg = "[" + str(datetime.datetime.now()) + "]" 8 | log_msg += "[" + class_name.__class__.__name__ + "][" + method_name + "] " 9 | log_msg += message 10 | print(log_msg) 11 | 12 | @staticmethod 13 | def load_json(json_path): 14 | with open(json_path, encoding='utf-8-sig') as letter_map_file: 15 | json_text = letter_map_file.read() 16 | return json.loads(json_text) -------------------------------------------------------------------------------- /src/core/LangMap.py: -------------------------------------------------------------------------------- 1 | from src.core.Utility import Utility 2 | import os 3 | 4 | class LangMap: 5 | 6 | def __init__(self): 7 | letter_map_list = Utility.load_json(os.getcwd()+"/assets/json/english_to_bangla_map.json") 8 | self.eng_to_ban_map = self.make_dict(letter_map_list) 9 | print(self.eng_to_ban_map) 10 | 11 | @staticmethod 12 | def make_dict(letter_map_list): 13 | eng_to_ban_map = {} 14 | for letter in letter_map_list: 15 | if type(letter['search_for']) is list: 16 | for search_for in letter['search_for']: 17 | eng_to_ban_map[search_for] = letter 18 | else: 19 | eng_to_ban_map[letter['search_for']] = letter 20 | return eng_to_ban_map 21 | 22 | langMap = LangMap() 23 | -------------------------------------------------------------------------------- /src/core/Engine.py: -------------------------------------------------------------------------------- 1 | from src.core.LangMap import langMap 2 | 3 | 4 | class Engine: 5 | def __init__(self): 6 | self.eng_to_ban_map = langMap.eng_to_ban_map 7 | 8 | def get_ban_char(self, eng_char, last_eng_chars): 9 | # letters with more than one character 10 | if last_eng_chars[0]+last_eng_chars[1]+eng_char in self.eng_to_ban_map: 11 | add_char = self.get_char_to_replace(last_eng_chars[0]+last_eng_chars[1]+eng_char, last_eng_chars[1]) 12 | return {"ban_char": add_char, "replace_count": 2} 13 | elif last_eng_chars[1]+eng_char in self.eng_to_ban_map: 14 | add_char = self.get_char_to_replace(last_eng_chars[1] + eng_char, last_eng_chars[1]) 15 | return {"ban_char": add_char, "replace_count": 1} 16 | else: 17 | add_char = self.get_char_to_replace(eng_char, last_eng_chars[1]) 18 | return {"ban_char": add_char, "replace_count": 0} 19 | 20 | def get_char_to_replace(self, eng_chars, last_eng_char): 21 | if eng_chars not in self.eng_to_ban_map: 22 | return eng_chars 23 | 24 | if self.eng_to_ban_map[eng_chars]['type'] == 'vowel': 25 | if last_eng_char is ' ' or self.eng_to_ban_map[last_eng_char]['type'] == 'vowel': 26 | return self.eng_to_ban_map[eng_chars]['replace'] 27 | else: 28 | return self.eng_to_ban_map[eng_chars]['short_form'] 29 | else: 30 | return self.eng_to_ban_map[eng_chars]['replace'] -------------------------------------------------------------------------------- /src/Window.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtGui, QtCore, QtWidgets 3 | from PyQt5.QtCore import Qt 4 | from src.core.Engine import Engine 5 | 6 | 7 | class Window(QtWidgets.QMainWindow): 8 | def __init__(self): 9 | super(Window, self).__init__() 10 | self.engine = Engine() 11 | self.last_eng_chars = [' ', ' ', ' '] 12 | 13 | self.setGeometry(50, 50, 700, 400) 14 | self.setWindowTitle("Chondralok") 15 | self.setWindowIcon(QtGui.QIcon("pencil.png")) 16 | 17 | self.text_editor = QtWidgets.QTextEdit() 18 | 19 | # menu action 20 | action_quit = QtWidgets.QAction("&Quit", self) 21 | action_quit.setShortcut("Ctrl+Q") 22 | action_quit.triggered.connect(self.close_application) 23 | 24 | action_editor = QtWidgets.QAction("&Open Editor", self) 25 | action_editor.setShortcut("Ctrl+E") 26 | action_editor.triggered.connect(self.open_editor) 27 | 28 | # status bar 29 | self.statusBar().showMessage("Write in Bangla...") 30 | 31 | # menu bar 32 | menu_bar = self.menuBar() 33 | file_menu = menu_bar.addMenu('&File') 34 | file_menu.addAction(action_quit) 35 | file_menu.addAction(action_editor) 36 | 37 | self.organize_home() 38 | self.show() 39 | 40 | def organize_home(self): 41 | # close action 42 | open_editor = QtWidgets.QAction(QtGui.QIcon("pencil.png"), 'Open editor', self) 43 | open_editor.triggered.connect(self.open_editor) 44 | 45 | # toolbar 46 | toolbar = self.addToolBar("A Toolbar") 47 | toolbar.addAction(open_editor) 48 | 49 | self.show() 50 | 51 | def open_editor(self): 52 | self.setCentralWidget(self.text_editor) 53 | self.text_editor.setFocus() 54 | self.text_editor.keyPressEvent = self.editor_key_press_event 55 | 56 | def editor_key_press_event(self, key_event): 57 | modifier = QtWidgets.QApplication.keyboardModifiers() 58 | shift_modifier = QtCore.Qt.ShiftModifier 59 | 60 | try: 61 | if ord('A') <= key_event.key() <= ord('Z'): 62 | pressed_eng_char = Window.get_eng_char(key_event, modifier, shift_modifier) 63 | elif key_event.key() == Qt.Key_Backspace: 64 | self.text_editor.textCursor().deletePreviousChar() 65 | return 66 | elif key_event.key() == Qt.Key_Return: 67 | self.text_editor.insertPlainText("\n") 68 | return 69 | else: 70 | pressed_eng_char = chr(key_event.key()) 71 | 72 | except ValueError as e: 73 | print("Key cannot be converted to character") 74 | return 75 | 76 | replace_map = self.engine.get_ban_char(pressed_eng_char, self.last_eng_chars) 77 | 78 | self.last_eng_chars[0] = self.last_eng_chars[1] 79 | self.last_eng_chars[1] = pressed_eng_char 80 | if replace_map['replace_count'] == 0: 81 | self.text_editor.insertPlainText(replace_map['ban_char']) 82 | elif replace_map['replace_count'] == 1: 83 | self.text_editor.textCursor().deletePreviousChar() 84 | self.text_editor.insertPlainText(replace_map['ban_char']) 85 | elif replace_map['replace_count'] == 2: 86 | self.text_editor.textCursor().deletePreviousChar() 87 | self.text_editor.textCursor().deletePreviousChar() 88 | self.text_editor.insertPlainText(replace_map['ban_char']) 89 | 90 | @staticmethod 91 | def get_eng_char(key_event, modifier, shift_modifier): 92 | key = key_event.key() 93 | return chr(key) if modifier and shift_modifier else chr(key + 32) 94 | 95 | @staticmethod 96 | def close_application(): 97 | print("Application closed") 98 | sys.exit() 99 | -------------------------------------------------------------------------------- /src/assets/json/english_to_bangla_map.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "search_for": "o", 4 | "replace": "অ", 5 | "short_form": "", 6 | "type": "vowel" 7 | }, 8 | { 9 | "search_for": "a", 10 | "replace": "আ", 11 | "short_form": "\u09BE", 12 | "type": "vowel" 13 | }, 14 | { 15 | "search_for": "i", 16 | "replace": "ই", 17 | "short_form": "\u09BF", 18 | "type": "vowel" 19 | }, 20 | { 21 | "search_for": "I", 22 | "replace": "ঈ", 23 | "short_form": "\u09C0", 24 | "type": "vowel" 25 | }, 26 | { 27 | "search_for": "u", 28 | "replace": "উ", 29 | "short_form": "\u09C1", 30 | "type": "vowel" 31 | }, 32 | { 33 | "search_for": "U", 34 | "replace": "ঊ", 35 | "short_form": "\u09C2", 36 | "type": "vowel" 37 | }, 38 | { 39 | "search_for": "rri", 40 | "replace": "ঋ", 41 | "short_form": "\u09C3", 42 | "type": "vowel" 43 | }, 44 | { 45 | "search_for": "e", 46 | "replace": "এ", 47 | "short_form": "\u09C7", 48 | "type": "vowel" 49 | }, 50 | { 51 | "search_for": "oi", 52 | "replace": "ঐ", 53 | "short_form": "\u09C8", 54 | "type": "vowel" 55 | }, 56 | { 57 | "search_for": "O", 58 | "replace": "ও", 59 | "short_form": "\u09CB", 60 | "type": "vowel" 61 | }, 62 | { 63 | "search_for": "ou", 64 | "replace": "ঔ", 65 | "short_form": "\u09CC", 66 | "type": "vowel" 67 | }, 68 | { 69 | "search_for": "k", 70 | "replace": "ক", 71 | "short_form": "", 72 | "type": "consonant" 73 | }, 74 | { 75 | "search_for": "kh", 76 | "replace": "খ", 77 | "short_form": "", 78 | "type": "consonant" 79 | }, 80 | { 81 | "search_for": "g", 82 | "replace": "গ", 83 | "short_form": "", 84 | "type": "consonant" 85 | }, 86 | { 87 | "search_for": "gh", 88 | "replace": "ঘ", 89 | "short_form": "", 90 | "type": "consonant" 91 | }, 92 | { 93 | "search_for": "Ng", 94 | "replace": "ঙ", 95 | "short_form": "", 96 | "type": "consonant" 97 | }, 98 | { 99 | "search_for": "c", 100 | "replace": "চ", 101 | "short_form": "", 102 | "type": "consonant" 103 | }, 104 | { 105 | "search_for": "ch", 106 | "replace": "ছ", 107 | "short_form": "", 108 | "type": "consonant" 109 | }, 110 | { 111 | "search_for": "j", 112 | "replace": "জ", 113 | "short_form": "", 114 | "type": "consonant" 115 | }, 116 | { 117 | "search_for": "jh", 118 | "replace": "ঝ", 119 | "short_form": "", 120 | "type": "consonant" 121 | }, 122 | { 123 | "search_for": "NG", 124 | "replace": "ঞ", 125 | "short_form": "", 126 | "type": "consonant" 127 | }, 128 | { 129 | "search_for": "T", 130 | "replace": "ট", 131 | "short_form": "", 132 | "type": "consonant" 133 | }, 134 | { 135 | "search_for": "Th", 136 | "replace": "ঠ", 137 | "short_form": "", 138 | "type": "consonant" 139 | }, 140 | { 141 | "search_for": "D", 142 | "replace": "ড", 143 | "short_form": "", 144 | "type": "consonant" 145 | }, 146 | { 147 | "search_for": "Dh", 148 | "replace": "ঢ", 149 | "short_form": "", 150 | "type": "consonant" 151 | }, 152 | { 153 | "search_for": "N", 154 | "replace": "ণ", 155 | "short_form": "", 156 | "type": "consonant" 157 | }, 158 | { 159 | "search_for": "t", 160 | "replace": "ত", 161 | "short_form": "", 162 | "type": "consonant" 163 | }, 164 | { 165 | "search_for": "th", 166 | "replace": "থ", 167 | "short_form": "", 168 | "type": "consonant" 169 | }, 170 | { 171 | "search_for": "d", 172 | "replace": "দ", 173 | "short_form": "", 174 | "type": "consonant" 175 | }, 176 | { 177 | "search_for": "dh", 178 | "replace": "ধ", 179 | "short_form": "", 180 | "type": "consonant" 181 | }, 182 | { 183 | "search_for": "n", 184 | "replace": "ন", 185 | "short_form": "", 186 | "type": "consonant" 187 | }, 188 | { 189 | "search_for": "p", 190 | "replace": "প", 191 | "short_form": "", 192 | "type": "consonant" 193 | }, 194 | { 195 | "search_for": "ph", 196 | "replace": "ফ", 197 | "short_form": "", 198 | "type": "consonant" 199 | }, 200 | { 201 | "search_for": "b", 202 | "replace": "ব", 203 | "short_form": "", 204 | "type": "consonant" 205 | }, 206 | { 207 | "search_for": "bh", 208 | "replace": "ভ", 209 | "short_form": "", 210 | "type": "consonant" 211 | }, 212 | { 213 | "search_for": "m", 214 | "replace": "ম", 215 | "short_form": "", 216 | "type": "consonant" 217 | }, 218 | { 219 | "search_for": "z", 220 | "replace": "য", 221 | "short_form": "", 222 | "type": "consonant" 223 | }, 224 | { 225 | "search_for": "r", 226 | "replace": "র", 227 | "short_form": "্রর", 228 | "type": "consonant" 229 | }, 230 | { 231 | "search_for": "rr", 232 | "replace": "র্‌", 233 | "short_form": "", 234 | "type": "consonant" 235 | }, 236 | { 237 | "search_for": "l", 238 | "replace": "ল", 239 | "short_form": "", 240 | "type": "consonant" 241 | }, 242 | { 243 | "search_for": "sh", 244 | "replace": "শ", 245 | "short_form": "", 246 | "type": "consonant" 247 | }, 248 | { 249 | "search_for": ["Sh", "SH"], 250 | "replace": "ষ", 251 | "short_form": "", 252 | "type": "consonant" 253 | }, 254 | { 255 | "search_for": "s", 256 | "replace": "স", 257 | "short_form": "", 258 | "type": "consonant" 259 | }, 260 | { 261 | "search_for": "h", 262 | "replace": "হ", 263 | "short_form": "", 264 | "type": "consonant" 265 | }, 266 | { 267 | "search_for": "y", 268 | "replace": "য়", 269 | "short_form": "", 270 | "type": "consonant" 271 | }, 272 | { 273 | "search_for": "R", 274 | "replace": "ড়", 275 | "short_form": "", 276 | "type": "consonant" 277 | }, 278 | { 279 | "search_for": "Rh", 280 | "replace": "ঢ়", 281 | "short_form": "", 282 | "type": "consonant" 283 | }, 284 | { 285 | "search_for": "t``", 286 | "replace": "ৎ", 287 | "short_form": "", 288 | "type": "consonant" 289 | }, 290 | { 291 | "search_for": "ng", 292 | "replace": "ং", 293 | "short_form": "", 294 | "type": "consonant" 295 | }, 296 | { 297 | "search_for": ":", 298 | "replace": "ঃ", 299 | "short_form": "", 300 | "type": "consonant" 301 | }, 302 | { 303 | "search_for": "^", 304 | "replace": "ঁ", 305 | "short_form": "", 306 | "type": "consonant" 307 | }, 308 | { 309 | "search_for": ".", 310 | "replace": "।", 311 | "short_form": "", 312 | "type": "consonant" 313 | }, 314 | { 315 | "search_for": "$", 316 | "replace": "৳", 317 | "short_form": "", 318 | "type": "consonant" 319 | }, 320 | { 321 | "search_for": ",,", 322 | "replace": "্‌", 323 | "short_form": "", 324 | "type": "consonant" 325 | }, 326 | { 327 | "search_for": "kkh", 328 | "replace": "ক্ষ‌", 329 | "short_form": "", 330 | "type": "consonant" 331 | } 332 | ] 333 | --------------------------------------------------------------------------------