diff --git a/__main__.py b/__main__.py
deleted file mode 100755
index f47f3ad..0000000
--- a/__main__.py
+++ /dev/null
@@ -1,148 +0,0 @@
-
-#!/usr/bin/env python3
-#-*-coding:utf-8-*-
-import sqlite3
-import sys
-import ui, ui2
-from PyQt4 import QtGui, QtCore
-
-
-def table2list(table_tsv):
- with open(table_tsv,'r',encoding='utf-16') as tsv:
- code_list = []
- for line in tsv:
- line_stripped = line.strip()
- code_char_mapping = tuple(line_stripped.split())
-
- code_list.append(code_char_mapping)
- return code_list
-
-def connect_db(db_filename):
- db = sqlite3.connect(db_filename)
- c = db.cursor()
- return db,c
-
-def create_new_db(db_filename):
- db, c = connect_db(db_filename)
- c.execute('''CREATE TABLE ime (code text, char text)''')
- return db, c
-
-
-def list2sqlite(code_list,c):
-
- c.executemany(
- 'INSERT INTO ime VALUES (?,?)', code_list)
-
-def import_all_table():
- import os
- import re
- main_dirname = os.path.dirname(os.path.abspath(__file__))
-
- db ,c = create_new_db(':memory:')
- table_folder = os.path.join(main_dirname, 'table')
- table_folder_files = os.listdir(table_folder)
-
- for file in table_folder_files:
- if re.match('.+\.txt$',file):
-
- file_path = os.path.join(table_folder,file)
- list = table2list(file_path)
- list2sqlite(list,c)
-
- db.commit()
- return db, c
-
-def find_code(char,c):
-
- raw_query = c.execute('''SELECT code FROM ime WHERE char = ?''', (char,))
- raw_code = [i[0] for i in raw_query.fetchall()]
- code_with_index = [rawcode2truecode(i) for i in raw_code]
- code = [i[0] for i in sorted(code_with_index,key= lambda x : x[1])]
- return code
-
-def rawcode2truecode(raw):
- #1^ = Q, 1- = A, 1v = Z, 2^ = W, 2- = S ......, 0^ = P, 0- = :, 0v = ?
- raw_code_order = "QAZWSXEDCRFVTGBYHNUJMIK,OL.P;/"
- true_code = ""
- index = 0
- for i in raw:
- i_index = raw_code_order.index(i)
-
- uncorrected_column = i_index // 3
- #correct the column no. 2 -> 3; 9 -> 0
- column = str(uncorrected_column + 1)[-1]
- row_number = i_index % 3
- row = ['^','-','v'][row_number] # 0=^;1=-;2=v
- column_and_row = column + row
- true_code = true_code + column_and_row
- index = index * 30 + i_index
- index = (5-len(raw))*(30**5) + index
- return true_code,index
-
-class MainWindow(QtGui.QMainWindow, ui.Ui_MainWindow):
- def __init__(self, parent=None):
- self.db,self.c = import_all_table()
-
- super(MainWindow, self).__init__(parent)
- self.setupUi(self)
- self.lineEdit.returnPressed.connect(self.input_characters)
- self.pushButton.clicked.connect(self.input_characters)
- self.pushButton_2.clicked.connect(self.clear_input)
- self.action_About.triggered.connect(self.show_about)
-
- def clear_input(self):
- self.label_2.setText("")
- self.lineEdit.clear()
-
- def show_about(self):
- about_dialog = QtGui.QWidget()
- about_dialog_ui = ui2.Ui_Dialog()
- about_dialog_ui.setupUi(about_dialog)
- about_dialog.show()
-
- def show_result(self,char_code):
- result = ""
- header = "
查碼結果: |
"
- result = header + result
-
- for (char,code) in char_code:
- result = result + '' + \
- char + ' | '
-
- for i in range(len(code)):
- if (i < len(code) - 1):
- result = result + code[i] + ' '
- else:
- result = result + code[i] + ' |
'
-
- result = result + '
'
- self.label_2.setText(result)
-
- def input_characters(self):
- import re
- characters = self.lineEdit.text()
- chinese_char_pattern = re.compile(u"^((?[一-鿌㐀-䶵𠀀-𪛖𪜀-𫜴𫝀-𫠝𫠠-𬺡])|[^\CJK\s\t\n]+)+$",re.UNICODE)
- is_chinese_chars = chinese_char_pattern.match(characters)
-
- if 1:
- char_code_list = [(ch,find_code(ch,self.c)) for ch in characters]
- self.show_result(char_code_list)
- else:
- print("error")
-
-def main():
- app = QtGui.QApplication(sys.argv)
- main_window = MainWindow()
- main_window.show()
- app.exec_()
-
-
-
-if __name__ == '__main__':
- main()
-
-
-
-
-
diff --git a/table/array30_27489-V201509.txt b/table/array30_27489-V201509.txt
deleted file mode 100644
index 38cfccb..0000000
Binary files a/table/array30_27489-V201509.txt and /dev/null differ
diff --git a/table/array30_Ext E_V2016A.txt b/table/array30_Ext E_V2016A.txt
deleted file mode 100644
index 97cdd58..0000000
Binary files a/table/array30_Ext E_V2016A.txt and /dev/null differ
diff --git a/table/array30_ExtB_V2016A.txt b/table/array30_ExtB_V2016A.txt
deleted file mode 100644
index 6dfbed9..0000000
Binary files a/table/array30_ExtB_V2016A.txt and /dev/null differ
diff --git a/table/array30_ExtCD_V2013A.txt b/table/array30_ExtCD_V2013A.txt
deleted file mode 100644
index 65226a8..0000000
Binary files a/table/array30_ExtCD_V2013A.txt and /dev/null differ
diff --git a/ui.py b/ui.py
deleted file mode 100644
index 5b47c85..0000000
--- a/ui.py
+++ /dev/null
@@ -1,129 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Form implementation generated from reading ui file 'ui.ui'
-#
-# Created: Sat Apr 2 15:29:18 2016
-# by: PyQt4 UI code generator 4.10.4
-#
-# WARNING! All changes made in this file will be lost!
-
-from PyQt4 import QtCore, QtGui
-
-try:
- _fromUtf8 = QtCore.QString.fromUtf8
-except AttributeError:
- def _fromUtf8(s):
- return s
-
-try:
- _encoding = QtGui.QApplication.UnicodeUTF8
- def _translate(context, text, disambig):
- return QtGui.QApplication.translate(context, text, disambig, _encoding)
-except AttributeError:
- def _translate(context, text, disambig):
- return QtGui.QApplication.translate(context, text, disambig)
-
-class Ui_MainWindow(object):
- def setupUi(self, MainWindow):
- MainWindow.setObjectName(_fromUtf8("MainWindow"))
- MainWindow.resize(387, 359)
- self.centralwidget = QtGui.QWidget(MainWindow)
- self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
- self.horizontalLayout_3 = QtGui.QHBoxLayout(self.centralwidget)
- self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3"))
- self.verticalLayout = QtGui.QVBoxLayout()
- self.verticalLayout.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint)
- self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
- self.horizontalLayout = QtGui.QHBoxLayout()
- self.horizontalLayout.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint)
- self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
- self.label = QtGui.QLabel(self.centralwidget)
- sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Maximum)
- sizePolicy.setHorizontalStretch(0)
- sizePolicy.setVerticalStretch(0)
- sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
- self.label.setSizePolicy(sizePolicy)
- self.label.setObjectName(_fromUtf8("label"))
- self.horizontalLayout.addWidget(self.label)
- self.lineEdit = QtGui.QLineEdit(self.centralwidget)
- sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Maximum)
- sizePolicy.setHorizontalStretch(0)
- sizePolicy.setVerticalStretch(0)
- sizePolicy.setHeightForWidth(self.lineEdit.sizePolicy().hasHeightForWidth())
- self.lineEdit.setSizePolicy(sizePolicy)
- self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
- self.horizontalLayout.addWidget(self.lineEdit)
- self.pushButton = QtGui.QPushButton(self.centralwidget)
- sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Maximum)
- sizePolicy.setHorizontalStretch(0)
- sizePolicy.setVerticalStretch(0)
- sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth())
- self.pushButton.setSizePolicy(sizePolicy)
- self.pushButton.setObjectName(_fromUtf8("pushButton"))
- self.horizontalLayout.addWidget(self.pushButton)
- self.verticalLayout.addLayout(self.horizontalLayout)
- self.horizontalLayout_2 = QtGui.QHBoxLayout()
- self.horizontalLayout_2.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint)
- self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
- spacerItem = QtGui.QSpacerItem(168, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
- self.horizontalLayout_2.addItem(spacerItem)
- self.pushButton_2 = QtGui.QPushButton(self.centralwidget)
- sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Maximum)
- sizePolicy.setHorizontalStretch(0)
- sizePolicy.setVerticalStretch(0)
- sizePolicy.setHeightForWidth(self.pushButton_2.sizePolicy().hasHeightForWidth())
- self.pushButton_2.setSizePolicy(sizePolicy)
- self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
- self.horizontalLayout_2.addWidget(self.pushButton_2)
- self.verticalLayout.addLayout(self.horizontalLayout_2)
- self.scrollArea = QtGui.QScrollArea(self.centralwidget)
- self.scrollArea.setWidgetResizable(True)
- self.scrollArea.setObjectName(_fromUtf8("scrollArea"))
- self.scrollAreaWidgetContents = QtGui.QWidget()
- self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 365, 219))
- self.scrollAreaWidgetContents.setObjectName(_fromUtf8("scrollAreaWidgetContents"))
- self.horizontalLayout_4 = QtGui.QHBoxLayout(self.scrollAreaWidgetContents)
- self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4"))
- self.label_2 = QtGui.QLabel(self.scrollAreaWidgetContents)
- sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
- sizePolicy.setHorizontalStretch(0)
- sizePolicy.setVerticalStretch(0)
- sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())
- self.label_2.setSizePolicy(sizePolicy)
- self.label_2.setTextFormat(QtCore.Qt.AutoText)
- self.label_2.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
- self.label_2.setMargin(2)
- self.label_2.setIndent(5)
- self.label_2.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByKeyboard|QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextBrowserInteraction|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse)
- self.label_2.setObjectName(_fromUtf8("label_2"))
- self.horizontalLayout_4.addWidget(self.label_2)
- self.scrollArea.setWidget(self.scrollAreaWidgetContents)
- self.verticalLayout.addWidget(self.scrollArea)
- self.horizontalLayout_3.addLayout(self.verticalLayout)
- MainWindow.setCentralWidget(self.centralwidget)
- self.menubar = QtGui.QMenuBar(MainWindow)
- self.menubar.setGeometry(QtCore.QRect(0, 0, 387, 23))
- self.menubar.setObjectName(_fromUtf8("menubar"))
- self.menu_Help = QtGui.QMenu(self.menubar)
- self.menu_Help.setObjectName(_fromUtf8("menu_Help"))
- MainWindow.setMenuBar(self.menubar)
- self.statusbar = QtGui.QStatusBar(MainWindow)
- self.statusbar.setObjectName(_fromUtf8("statusbar"))
- MainWindow.setStatusBar(self.statusbar)
- self.action_About = QtGui.QAction(MainWindow)
- self.action_About.setObjectName(_fromUtf8("action_About"))
- self.menu_Help.addAction(self.action_About)
- self.menubar.addAction(self.menu_Help.menuAction())
-
- self.retranslateUi(MainWindow)
- QtCore.QMetaObject.connectSlotsByName(MainWindow)
-
- def retranslateUi(self, MainWindow):
- MainWindow.setWindowTitle(_translate("MainWindow", "findarray30code - 行列30查碼", None))
- self.label.setText(_translate("MainWindow", "輸入文字", None))
- self.pushButton.setText(_translate("MainWindow", "查詢", None))
- self.pushButton_2.setText(_translate("MainWindow", "清空", None))
- self.label_2.setText(_translate("MainWindow", "
", None))
- self.menu_Help.setTitle(_translate("MainWindow", "說明 (&H)", None))
- self.action_About.setText(_translate("MainWindow", "關於 findarray30code (&A)", None))
-
diff --git a/ui.ui b/ui.ui
deleted file mode 100644
index 3c61c0a..0000000
--- a/ui.ui
+++ /dev/null
@@ -1,176 +0,0 @@
-
-
- MainWindow
-
-
-
- 0
- 0
- 387
- 359
-
-
-
- findarray30code - 行列30查碼
-
-
-
- -
-
-
- QLayout::SetDefaultConstraint
-
-
-
-
-
- QLayout::SetDefaultConstraint
-
-
-
-
-
-
- 0
- 0
-
-
-
- 輸入文字
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- 查詢
-
-
-
-
-
- -
-
-
- QLayout::SetDefaultConstraint
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 168
- 20
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- 清空
-
-
-
-
-
- -
-
-
- true
-
-
-
-
- 0
- 0
- 365
- 219
-
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
-
-
- Qt::AutoText
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
-
-
- 2
-
-
- 5
-
-
- Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 關於 findarray30code (&A)
-
-
-
-
-
-
diff --git a/ui2.py b/ui2.py
deleted file mode 100644
index f1f0cee..0000000
--- a/ui2.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Form implementation generated from reading ui file 'ui2.ui'
-#
-# Created: Wed Mar 23 07:34:15 2016
-# by: PyQt4 UI code generator 4.10.4
-#
-# WARNING! All changes made in this file will be lost!
-
-from PyQt4 import QtCore, QtGui
-
-try:
- _fromUtf8 = QtCore.QString.fromUtf8
-except AttributeError:
- def _fromUtf8(s):
- return s
-
-try:
- _encoding = QtGui.QApplication.UnicodeUTF8
- def _translate(context, text, disambig):
- return QtGui.QApplication.translate(context, text, disambig, _encoding)
-except AttributeError:
- def _translate(context, text, disambig):
- return QtGui.QApplication.translate(context, text, disambig)
-
-class Ui_Dialog(object):
- def setupUi(self, Dialog):
- Dialog.setObjectName(_fromUtf8("Dialog"))
- Dialog.resize(392, 321)
- self.verticalLayout_2 = QtGui.QVBoxLayout(Dialog)
- self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
- self.verticalLayout = QtGui.QVBoxLayout()
- self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
- self.scrollArea = QtGui.QScrollArea(Dialog)
- self.scrollArea.setWidgetResizable(True)
- self.scrollArea.setObjectName(_fromUtf8("scrollArea"))
- self.scrollAreaWidgetContents = QtGui.QWidget()
- self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -14, 357, 706))
- self.scrollAreaWidgetContents.setObjectName(_fromUtf8("scrollAreaWidgetContents"))
- self.horizontalLayout = QtGui.QHBoxLayout(self.scrollAreaWidgetContents)
- self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
- self.label = QtGui.QLabel(self.scrollAreaWidgetContents)
- sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum)
- sizePolicy.setHorizontalStretch(0)
- sizePolicy.setVerticalStretch(0)
- sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
- self.label.setSizePolicy(sizePolicy)
- self.label.setTextFormat(QtCore.Qt.AutoText)
- self.label.setWordWrap(True)
- self.label.setOpenExternalLinks(True)
- self.label.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByKeyboard|QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextBrowserInteraction|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse)
- self.label.setObjectName(_fromUtf8("label"))
- self.horizontalLayout.addWidget(self.label)
- self.scrollArea.setWidget(self.scrollAreaWidgetContents)
- self.verticalLayout.addWidget(self.scrollArea)
- self.verticalLayout_2.addLayout(self.verticalLayout)
- self.buttonBox = QtGui.QDialogButtonBox(Dialog)
- self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
- self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
- self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
- self.verticalLayout_2.addWidget(self.buttonBox)
-
- self.retranslateUi(Dialog)
- QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Dialog.accept)
- QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.reject)
- QtCore.QMetaObject.connectSlotsByName(Dialog)
-
- def retranslateUi(self, Dialog):
- Dialog.setWindowTitle(_translate("Dialog", "Dialog", None))
- self.label.setText(_translate("Dialog", "findarray30code
0.0.1
查詢行列 30 輸入法碼表的工具。
支援 CJK Ext. A - E 的罕字。
https://github.com/Yoxem/findarray30code
Copyright (C) 2016
Yoxem Chen (aka Kian-ting Tan)
under X11 License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
", None))
-
diff --git a/ui2.ui b/ui2.ui
deleted file mode 100644
index ceeba12..0000000
--- a/ui2.ui
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
- Dialog
-
-
-
- 0
- 0
- 392
- 321
-
-
-
- Dialog
-
-
- -
-
-
-
-
-
- true
-
-
-
-
- 0
- -14
- 357
- 706
-
-
-
-
-
-
-
-
- 0
- 0
-
-
-
- <html><head/><body><p align="center"><span style=" font-size:18pt; font-weight:600;">findarray30code</span></p><p align="center">0.0.1</p><p align="center">查詢行列 30 輸入法碼表的工具。</p><p align="center">支援 CJK Ext. A - E 的罕字。</p><p align="center"><a href="https://github.com/Yoxem/findarray30code "><span style=" text-decoration: underline; color:#0000ff;">https://github.com/Yoxem/findarray30code</span></a></p><p align="center">Copyright (C) 2016</p><p align="center">Yoxem Chen (aka Kian-ting Tan)</p><p align="center">under X11 License</p><p><span style=" font-size:9pt;">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</span></p><p><span style=" font-size:9pt;">The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</span></p><p><span style=" font-size:9pt;">THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</span></p></body></html>
-
-
- Qt::AutoText
-
-
- true
-
-
- true
-
-
- Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse
-
-
-
-
-
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
-
-
-
-
-
-
- buttonBox
- accepted()
- Dialog
- accept()
-
-
- 248
- 254
-
-
- 157
- 274
-
-
-
-
- buttonBox
- rejected()
- Dialog
- reject()
-
-
- 316
- 260
-
-
- 286
- 274
-
-
-
-
-
-