├── .idea ├── .gitignore ├── misc.xml ├── inspectionProfiles │ └── profiles_settings.xml ├── modules.xml └── nlpapp.iml ├── resources └── favicon.ico ├── settings.cfg ├── db.json ├── README.md ├── myapi.py ├── mydb.py └── app.py /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /resources/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/campusx-official/nlpapp/HEAD/resources/favicon.ico -------------------------------------------------------------------------------- /settings.cfg: -------------------------------------------------------------------------------- 1 | [PD] 2 | exist = true 3 | api_key = IH4OCcC3pwUFU6jRcoyzug4ShpopFEtpLFigQEZImmk 4 | 5 | -------------------------------------------------------------------------------- /db.json: -------------------------------------------------------------------------------- 1 | {"nitish@gmail.com": ["Nitish", "nnitish1234"], "ankit@gmail.com": ["Ankit", "1234"], "ankita@gmail.com": ["Ankita", "1234"]} -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nlpapp 2 | An API based NLP application created using Tkinter and OOP 3 | 4 | Link for API - https://komprehend.io/api-wrappers 5 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/nlpapp.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /myapi.py: -------------------------------------------------------------------------------- 1 | import paralleldots 2 | # Setting your API key 3 | 4 | class API: 5 | 6 | def __init__(self): 7 | paralleldots.set_api_key('IH4OCcC3pwUFU6jRcoyzug4ShpopFEtpLFigQEZImmk') 8 | 9 | def sentiment_analysis(self,text): 10 | response = paralleldots.sentiment(text) 11 | return response 12 | 13 | def ner(self,text): 14 | paralleldots.ner(text) 15 | 16 | def emotion_prediction(self,text): 17 | paralleldots.emotion(text) -------------------------------------------------------------------------------- /mydb.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | class Database: 4 | 5 | def add_data(self,name,email,password): 6 | 7 | with open('db.json','r') as rf: 8 | database = json.load(rf) 9 | 10 | if email in database: 11 | return 0 12 | else: 13 | database[email] = [name,password] 14 | with open('db.json','w') as wf: 15 | json.dump(database,wf) 16 | return 1 17 | 18 | def search(self,email,password): 19 | 20 | with open('db.json','r') as rf: 21 | database = json.load(rf) 22 | if email in database: 23 | if database[email][1] == password: 24 | return 1 25 | else: 26 | return 0 27 | else: 28 | return 0 29 | 30 | 31 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | 2 | from tkinter import * 3 | from mydb import Database 4 | from tkinter import messagebox 5 | from myapi import API 6 | 7 | class NLPApp: 8 | 9 | def __init__(self): 10 | 11 | # create db object 12 | self.dbo = Database() 13 | self.apio = API() 14 | 15 | # login ka gui load karna 16 | self.root = Tk() 17 | self.root.title('NLPApp') 18 | self.root.iconbitmap('resources/favicon.ico') 19 | self.root.geometry('350x600') 20 | self.root.configure(bg='#34495E') 21 | 22 | self.login_gui() 23 | 24 | self.root.mainloop() 25 | 26 | def login_gui(self): 27 | 28 | self.clear() 29 | 30 | heading = Label(self.root,text='NLPApp',bg='#34495E',fg='white') 31 | heading.pack(pady=(30,30)) 32 | heading.configure(font=('verdana',24,'bold')) 33 | 34 | label1 = Label(self.root,text='Enter Email') 35 | label1.pack(pady=(10,10)) 36 | 37 | self.email_input = Entry(self.root,width=50) 38 | self.email_input.pack(pady=(5,10),ipady=4) 39 | 40 | label2 = Label(self.root, text='Enter Password') 41 | label2.pack(pady=(10, 10)) 42 | 43 | self.password_input = Entry(self.root, width=50,show='*') 44 | self.password_input.pack(pady=(5, 10), ipady=4) 45 | 46 | login_btn = Button(self.root,text='Login',width=30,height=2,command=self.perform_login) 47 | login_btn.pack(pady=(10,10)) 48 | 49 | label3 = Label(self.root, text='Not a member?') 50 | label3.pack(pady=(20, 10)) 51 | 52 | redirect_btn = Button(self.root, text='Register Now',command=self.register_gui) 53 | redirect_btn.pack(pady=(10, 10)) 54 | 55 | def register_gui(self): 56 | self.clear() 57 | 58 | heading = Label(self.root, text='NLPApp', bg='#34495E', fg='white') 59 | heading.pack(pady=(30, 30)) 60 | heading.configure(font=('verdana', 24, 'bold')) 61 | 62 | label0 = Label(self.root, text='Enter Name') 63 | label0.pack(pady=(10, 10)) 64 | 65 | self.name_input = Entry(self.root, width=50) 66 | self.name_input.pack(pady=(5, 10), ipady=4) 67 | 68 | label1 = Label(self.root, text='Enter Email') 69 | label1.pack(pady=(10, 10)) 70 | 71 | self.email_input = Entry(self.root, width=50) 72 | self.email_input.pack(pady=(5, 10), ipady=4) 73 | 74 | label2 = Label(self.root, text='Enter Password') 75 | label2.pack(pady=(10, 10)) 76 | 77 | self.password_input = Entry(self.root, width=50, show='*') 78 | self.password_input.pack(pady=(5, 10), ipady=4) 79 | 80 | register_btn = Button(self.root, text='Register', width=30, height=2,command=self.perform_registration) 81 | register_btn.pack(pady=(10, 10)) 82 | 83 | label3 = Label(self.root, text='Already a member?') 84 | label3.pack(pady=(20, 10)) 85 | 86 | redirect_btn = Button(self.root, text='Login Now', command=self.login_gui) 87 | redirect_btn.pack(pady=(10, 10)) 88 | 89 | def clear(self): 90 | # clear the existing gui 91 | for i in self.root.pack_slaves(): 92 | i.destroy() 93 | 94 | def perform_registration(self): 95 | # fetch data from the gui 96 | name = self.name_input.get() 97 | email = self.email_input.get() 98 | password = self.password_input.get() 99 | 100 | response = self.dbo.add_data(name, email, password) 101 | 102 | if response: 103 | messagebox.showinfo('Success','Registration successful. You can login now') 104 | else: 105 | messagebox.showerror('Error','Email already exists') 106 | 107 | def perform_login(self): 108 | 109 | email = self.email_input.get() 110 | password = self.password_input.get() 111 | 112 | response = self.dbo.search(email, password) 113 | 114 | if response: 115 | messagebox.showinfo('success','Login successful') 116 | self.home_gui() 117 | else: 118 | messagebox.showerror('error','Incorrect email/password') 119 | 120 | def home_gui(self): 121 | 122 | self.clear() 123 | 124 | heading = Label(self.root, text='NLPApp', bg='#34495E', fg='white') 125 | heading.pack(pady=(30, 30)) 126 | heading.configure(font=('verdana', 24, 'bold')) 127 | 128 | sentiment_btn = Button(self.root, text='Sentiment Analysis', width=30, height=4, command=self.sentiment_gui) 129 | sentiment_btn.pack(pady=(10, 10)) 130 | 131 | ner_btn = Button(self.root, text='Named Entity Recognition', width=30, height=4, 132 | command=self.perform_registration) 133 | ner_btn.pack(pady=(10, 10)) 134 | 135 | emotion_btn = Button(self.root, text='Emotion Prediction', width=30, height=4, 136 | command=self.perform_registration) 137 | emotion_btn.pack(pady=(10, 10)) 138 | 139 | logout_btn = Button(self.root, text='Logout', command=self.login_gui) 140 | logout_btn.pack(pady=(10, 10)) 141 | 142 | def sentiment_gui(self): 143 | 144 | self.clear() 145 | 146 | heading = Label(self.root, text='NLPApp', bg='#34495E', fg='white') 147 | heading.pack(pady=(30, 30)) 148 | heading.configure(font=('verdana', 24, 'bold')) 149 | 150 | heading2 = Label(self.root, text='Sentiment Analysis', bg='#34495E', fg='white') 151 | heading2.pack(pady=(10, 20)) 152 | heading2.configure(font=('verdana', 20)) 153 | 154 | label1 = Label(self.root, text='Enter the text') 155 | label1.pack(pady=(10, 10)) 156 | 157 | self.sentiment_input = Entry(self.root, width=50) 158 | self.sentiment_input.pack(pady=(5, 10), ipady=4) 159 | 160 | sentiment_btn = Button(self.root, text='Analyze Sentiment', command=self.do_sentiment_analysis) 161 | sentiment_btn.pack(pady=(10, 10)) 162 | 163 | self.sentiment_result = Label(self.root, text='',bg='#34495E',fg='white') 164 | self.sentiment_result.pack(pady=(10, 10)) 165 | self.sentiment_result.configure(font=('verdana', 16)) 166 | 167 | 168 | goback_btn = Button(self.root, text='Go Back', command=self.home_gui) 169 | goback_btn.pack(pady=(10, 10)) 170 | 171 | def do_sentiment_analysis(self): 172 | 173 | text = self.sentiment_input.get() 174 | result = self.apio.sentiment_analysis(text) 175 | 176 | txt = '' 177 | for i in result['sentiment']: 178 | txt = txt + i + ' -> ' + str(result['sentiment'][i]) + '\n' 179 | 180 | print(txt) 181 | self.sentiment_result['text'] = txt 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | nlp = NLPApp() 203 | 204 | 205 | --------------------------------------------------------------------------------