diff --git a/README.md b/README.md
index ce6e893..a665444 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,14 @@ pip install memedensity
memedensity
```
+* ### Handy offline dictionary
+A tiny offline dictionary app based on nltk wordnet and pyqt5
+```bash
+cd dictionary
+python app.py
+```
+
+
* ### Facebook Auto Post
This is python script that log in into facebook and post the status.
@@ -238,5 +246,6 @@ The following people helped in creating the above content.
* Ishank Arora
* Vishal Sharma
* Apurva Nitanjay
+* Surya K
### If you like the project give a star [
](https://github.com/Logan1x/Python-Scripts)
diff --git a/bin/dictionary/app.py b/bin/dictionary/app.py
new file mode 100644
index 0000000..245101c
--- /dev/null
+++ b/bin/dictionary/app.py
@@ -0,0 +1,17 @@
+from dict_dialog import Dict_Dialog
+from PyQt5.QtWidgets import QApplication, QDialog
+import sys
+
+
+class AppWindow(QDialog):
+ def __init__(self):
+ super().__init__()
+ self.ui = Dict_Dialog()
+ self.ui.setupUi(self)
+ self.show()
+
+
+app = QApplication(sys.argv)
+w = AppWindow()
+w.show()
+sys.exit(app.exec_())
diff --git a/bin/dictionary/dict_dialog.py b/bin/dictionary/dict_dialog.py
new file mode 100644
index 0000000..f788069
--- /dev/null
+++ b/bin/dictionary/dict_dialog.py
@@ -0,0 +1,56 @@
+from dictionary import definition
+from PyQt5 import QtCore, QtWidgets
+
+
+class Dict_Dialog(object):
+ def setupUi(self, Dialog):
+ Dialog.setObjectName("Dictionary")
+ Dialog.resize(344, 249)
+ self.widget = QtWidgets.QWidget(Dialog)
+ self.widget.setGeometry(QtCore.QRect(10, 10, 321, 236))
+ self.widget.setObjectName("widget")
+ self.verticalLayout = QtWidgets.QVBoxLayout(self.widget)
+ self.verticalLayout.setContentsMargins(0, 0, 0, 0)
+ self.verticalLayout.setObjectName("verticalLayout")
+ self.horizontalLayout = QtWidgets.QHBoxLayout()
+ self.horizontalLayout.setContentsMargins(-1, -1, -1, 4)
+ self.horizontalLayout.setSpacing(6)
+ self.horizontalLayout.setObjectName("horizontalLayout")
+ self.searchText = QtWidgets.QLineEdit(self.widget)
+ self.searchText.setText("")
+ self.searchText.setObjectName("searchText")
+ self.horizontalLayout.addWidget(self.searchText)
+ self.searchButton = QtWidgets.QPushButton(self.widget)
+ self.searchButton.setObjectName("searchButton")
+ self.horizontalLayout.addWidget(self.searchButton)
+ self.verticalLayout.addLayout(self.horizontalLayout)
+ self.resultText = QtWidgets.QTextBrowser(self.widget)
+ self.resultText.setObjectName("resultText")
+ self.verticalLayout.addWidget(self.resultText)
+
+ # output fonts
+ font = self.resultText.font()
+ font.setPointSize(20)
+
+ self.retranslateUi(Dialog)
+ QtCore.QMetaObject.connectSlotsByName(Dialog)
+ Dialog.setTabOrder(self.searchText, self.searchButton)
+
+ # events
+ self.searchButton.clicked.connect(self.show_definition)
+
+ def show_definition(self):
+ word = self.searchText.text()
+ defn = definition(word)
+
+ if defn != '':
+ self.resultText.setText(defn)
+ else:
+ self.resultText.setText('definition not found')
+
+ def retranslateUi(self, Dialog):
+ _translate = QtCore.QCoreApplication.translate
+ Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
+ self.searchText.setPlaceholderText(
+ _translate("Dialog", "word to search"))
+ self.searchButton.setText(_translate("Dialog", "search"))
diff --git a/bin/dictionary/dictionary.py b/bin/dictionary/dictionary.py
new file mode 100644
index 0000000..063801a
--- /dev/null
+++ b/bin/dictionary/dictionary.py
@@ -0,0 +1,25 @@
+from nltk.corpus import wordnet as wn
+
+
+def extractInfo(synset):
+ """
+ get string containing definition from a synset
+ """
+ out = synset.pos() + ' : '
+ out += synset.definition()
+
+ return out
+
+
+def definition(word):
+ ssets = wn.synsets(word)
+ defns = list()
+
+ for i in ssets:
+ # ensure words in synsets are same
+ if i.name().split('.')[0] == word:
+ info = extractInfo(i)
+ defns.append(info)
+
+ # return defns
+ return '\n'.join(defns)