-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtkfile.py
54 lines (42 loc) · 1.54 KB
/
tkfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import srttotxt as stt
import mastercode as mc
import loadntset as ls
from tkinter import *
import meanings as mn
global trivlist
import srttosrt as ss
import dynamictraining as dt
trivlist=list() #nested list with words and its meanings
def callme(fl):
win=Tk()
win.geometry('800x500+0+0')
f=Frame(win)
win.title("logophile's companion")
lb = Listbox(win,height=500)
lb.pack(fill=BOTH)
sb = Scrollbar(win,orient=VERTICAL)
sb.pack(fill=BOTH)
sb.configure(command=lb.yview)
lb.pack(fill=BOTH)
lb.configure(yscrollcommand=sb.set)
lb.curselection()
if fl[len(fl.strip())-4:]==".srt": #checks if the file is srt or txt
s=stt.importsrt(fl)
else:
s=fl
new=mc.inputfile(s) #extracts attributes of words into a new file
nontrivial=ls.predict(new,s) #classifies non trivial words
trivlist=mn.mean(nontrivial)
if fl[len(fl.strip())-4:]==".srt":
ss.srttosrt(fl,nontrivial) #replaces original srt with modified srt with meanings
for i in trivlist: #addition of non trivial words with meanings into tkinter list box
if len(i)>1:
lb.insert(END,i[0].upper())
lb.insert(END,"Definition :")
for j in i[1:]:
lb.insert(END,j)
r=open("newnontrivialwords.txt","w")
for word in nontrivial:
r.write(word+"\n")
r.close()
dt.calltrain("newnontrivialwords.txt") #retraining the network on new words from videos