-
Notifications
You must be signed in to change notification settings - Fork 2
/
Wrapper.py
89 lines (63 loc) · 2.45 KB
/
Wrapper.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from tkinter import *
from tkinter.filedialog import askopenfilename
from tkinter.filedialog import askdirectory
from os import listdir
import driver
import sys
file_names = []
summaries = []
whitelist = set('abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ')
sample_files = []
def get_file_name():
global file_names
file_names = []
file_name = askopenfilename()
file_names.append( file_name )
def get_directory_path():
global sample_files
directory_path = askdirectory()
files = listdir( directory_path )
sample_files = []
for i in files:
sample_files.append( directory_path + '/' + i )
def clean_output( string ):
string = ''.join(filter(whitelist.__contains__, string ))
return ' '.join( string.split() )
def get_summaries():
global summaries
summaries = driver.driver_code( file_names[0] , file_names[1] )
summaries[0] = clean_output( summaries[0] )
summaries[1] = clean_output( summaries[1] )
def generate_summaries():
global file_names
summary_window = Tk()
summary_window.geometry( '800x800' )
text = Text( summary_window )
for i in sample_files:
file_names.append( i )
get_summaries()
text.insert( INSERT , "The Summary Of ( " + file_names[0] + " ) is \n\n" )
text.insert( INSERT , summaries[0] + '.' )
text.insert( INSERT, "\n\n")
text.insert( INSERT , "The Summary Of ( " + file_names[1] + " ) is \n\n" )
text.insert( INSERT, summaries[1] + '.' )
text.insert( INSERT, "\n------------------------------------------------------------------------------------------------------------\n\n")
file_names.pop()
text.pack(expand=True, fill=BOTH)
summary_window.mainloop()
return
if __name__ == '__main__':
main_window = Tk()
main_window.title( "Patcom" )
main_window.geometry( '850x550' )
main_window.grid_columnconfigure(2, weight=1)
l1 = Label( main_window , text="Patent Document Comparison System", fg = "light green", bg = "dark green" , height = 3 , width = 40)
l1.config(font=("Courier", 25 ))
l1.place(relx=0.5, rely=0.2, anchor=CENTER)
bt_1 = Button(main_window, text='Select Test File', command = get_file_name )
bt_1.place(relx=0.5, rely=0.5, anchor=CENTER)
bt_2 = Button(main_window, text='Select Directory', command = get_directory_path )
bt_2.place(relx=0.5, rely=0.6, anchor=CENTER)
generate_summaries = Button(main_window, text='Generate Summaries', command = generate_summaries , height = 1 , width = 20 )
generate_summaries.place(relx=0.5, rely=0.7, anchor=CENTER)
main_window.mainloop()