<commit_before>'''
cd dropbox/codes/check_forbidden
py -B check_forbidden.py
'''
import cf_scripts
import tkinter
import tkinter.filedialog

print('Loading...')

root = tkinter.Tk()
frame_main = tkinter.Frame(root)

args_bl = {'filetypes' : [('mqxlz / mqxliff', '*.mqxlz;*.mqxliff')]}
args_terms = {'filetypes' : [('csv / text', '*.csv;*.txt')]}
args_result = {'filetypes' : [('csv', '*.csv')]}

btn_bl = tkinter.Button(text='Billingual', underline=0)
btn_terms = tkinter.Button(text='Terms', underline=0)
btn_result = tkinter.Button(text='Result', underline=0)

var_bl = tkinter.StringVar(frame_main)
var_terms = tkinter.StringVar(frame_main)
var_result = tkinter.StringVar(frame_main)

btn_bl.grid(row=0, column=0, sticky=tkinter.W, padx=5)
btn_terms.grid(row=1, column=0, sticky=tkinter.W, padx=5)
btn_result.grid(row=2, column=0, sticky=tkinter.W, padx=5)


def choose_bl(self):
    f_bl = tkinter.filedialog.askopenfilenames(**args_bl)
    var_bl.set(f_bl)
    if len(var_bl.get()) >= 1 and len(var_result.get()) == 0:
        var_result.set(f_bl[0].rsplit(r'/', 1)[0]+r'/checked_result.csv')


def choose_terms(self):
    f_terms = tkinter.filedialog.askopenfilename(**args_terms)
    var_terms.set(f_terms)


def choose_result(self):
    f_result = tkinter.filedialog.asksaveasfilename(initialfile='checked_result.csv', **args_result)
    var_result.set(f_result)


btn_bl.bind('<ButtonRelease-1>', choose_bl)
btn_terms.bind('<ButtonRelease-1>', choose_terms)
btn_result.bind('<ButtonRelease-1>', choose_result)

ent_bl = tkinter.Entry(width=85, textvariable=var_bl)
ent_terms = tkinter.Entry(width=85, textvariable=var_terms)
ent_result = tkinter.Entry(width=85, textvariable=var_result)

three_entries = [ent_bl, ent_terms, ent_result]
for i in three_entries:
    i.grid(row=three_entries.index(i), column=1, sticky=tkinter.W, columnspan=2, padx=5)

guide_bl = 'Billingual files: .mqxlz or .mqxliff'
guide_terms = 'CSV format: 0(Index), Source, Target (NG), Target (OK)'
guide_result = 'Can be an existing file. Results are added to the bottom.'
guide_options = 'Show / hide options'
guide_run = 'Run button is enabled when all the three fields are filled.'<commit_msg>* Fix the bug where filetypes argument prevents selecting files on Mac<commit_after>'''
cd dropbox/codes/check_forbidden
py -B check_forbidden.py
'''
import cf_scripts
import tkinter
import tkinter.filedialog

print('Loading...')

root = tkinter.Tk()
frame_main = tkinter.Frame(root)

ext_bl = [('mqxlz / mqxliff', '*.mqxlz;*.mqxliff'), ('mqxlz', '*.mqxlz'), ('mqxliff', '*.mqxliff')]
ext_terms = [('csv / text', '*.csv;*.txt'), ('csv', '*.csv'), ('text', '*.txt')]
ext_result = [('csv', '*.csv')]

btn_bl = tkinter.Button(text='Billingual', underline=0)
btn_terms = tkinter.Button(text='Terms', underline=0)
btn_result = tkinter.Button(text='Result', underline=0)

var_bl = tkinter.StringVar(frame_main)
var_terms = tkinter.StringVar(frame_main)
var_result = tkinter.StringVar(frame_main)

btn_bl.grid(row=0, column=0, sticky=tkinter.W, padx=5)
btn_terms.grid(row=1, column=0, sticky=tkinter.W, padx=5)
btn_result.grid(row=2, column=0, sticky=tkinter.W, padx=5)


def choose_bl(self):
    f_bl = tkinter.filedialog.askopenfilenames(filetypes=ext_bl)
    var_bl.set(f_bl)
    if len(var_bl.get()) >= 1 and len(var_result.get()) == 0:
        var_result.set(f_bl[0].rsplit(r'/', 1)[0]+r'/checked_result.csv')


def choose_terms(self):
    f_terms = tkinter.filedialog.askopenfilename(filetypes=ext_terms)
    var_terms.set(f_terms)


def choose_result(self):
    f_result = tkinter.filedialog.asksaveasfilename(filetypes=ext_result, initialfile='checked_result.csv')
    var_result.set(f_result)


btn_bl.bind('<ButtonRelease-1>', choose_bl)
btn_terms.bind('<ButtonRelease-1>', choose_terms)
btn_result.bind('<ButtonRelease-1>', choose_result)

ent_bl = tkinter.Entry(width=85, textvariable=var_bl)
ent_terms = tkinter.Entry(width=85, textvariable=var_terms)
ent_result = tkinter.Entry(width=85, textvariable=var_result)

three_entries = [ent_bl, ent_terms, ent_result]
for i in three_entries:
    i.grid(row=three_entries.index(i), column=1, sticky=tkinter.W, columnspan=2, padx=5)

guide_bl = 'Billingual files: .mqxlz or .mqxliff'
guide_terms = 'CSV format: 0(Index), Source, Target (NG), Target (OK)'
guide_result = 'Can be an existing file. Results are added to the bottom.'
guide_options = 'Show / hide options'
guide_run = 'Run button is enabled when all the three fields are filled.'
{'fraction_non_alphanumeric': 0.1573410922112802, 'fraction_numerical': 0.01342882721575649, 'mean_word_length': 6.11624203821656, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2311693', 'n_tokens_mistral': 1772, 'n_tokens_neox': 1697, 'n_words': 321}