<commit_before>import json
import threading
import tkinter as tk
import tkinter.filedialog as filedialog
import tkinter.ttk as ttk
import urllib.error
import urllib.parse
import urllib.request


class JSONText(tk.Text):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.tag_configure('keystring', foreground='#000080')
        self.tag_configure('string', foreground='#dd1144')
        self.tag_configure('number', foreground='#009999')
        self.tag_configure('boolean', font='bold')

    def highlight(self):
        self.set_tags('"[^":]*"(?=\:)', 'keystring')
        self.set_tags('"[^":]*"(?!\:)', 'string')
        self.set_tags('[\d\.]', 'number')
        self.set_tags('(true|false|null)', 'boolean')

    def set_tags(self, pattern, tag):
        start = self.index('1.0')
        self.mark_set('matchStart', start)
        self.mark_set('matchEnd', start)
        self.mark_set('searchLimit', self.index('end'))
        count = tk.IntVar()
        while True:
            index = self.search(pattern, 'matchEnd', 'searchLimit',
                                count=count, regexp=True)
            if not index:
                break
            self.mark_set('matchStart', index)
            self.mark_set('matchEnd', '{}+{}c'.format(index, count.get()))
            self.tag_add(tag, 'matchStart', 'matchEnd')


class App(ttk.Frame):
<commit_msg>Better number matching<commit_after>import json
import threading
import tkinter as tk
import tkinter.filedialog as filedialog
import tkinter.ttk as ttk
import urllib.error
import urllib.parse
import urllib.request


class JSONText(tk.Text):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.tag_configure('keystring', foreground='#000080')
        self.tag_configure('string', foreground='#dd1144')
        self.tag_configure('number', foreground='#009999')
        self.tag_configure('boolean', font='bold')

    def highlight(self):
        self.set_tags('"[^":]*"(?=\:)', 'keystring')
        self.set_tags('"[^":]*"(?!\:)', 'string')
        self.set_tags('(0|[1-9])[0-9]*(\.[0-9]*)?', 'number')
        self.set_tags('(true|false|null)', 'boolean')

    def set_tags(self, pattern, tag):
        start = self.index('1.0')
        self.mark_set('matchStart', start)
        self.mark_set('matchEnd', start)
        self.mark_set('searchLimit', self.index('end'))
        count = tk.IntVar()
        while True:
            index = self.search(pattern, 'matchEnd', 'searchLimit',
                                count=count, regexp=True)
            if not index:
                break
            self.mark_set('matchStart', index)
            self.mark_set('matchEnd', '{}+{}c'.format(index, count.get()))
            self.tag_add(tag, 'matchStart', 'matchEnd')


class App(ttk.Frame):

{'fraction_non_alphanumeric': 0.1693010186160871, 'fraction_numerical': 0.01510361784334387, 'mean_word_length': 2.8434547908232117, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, '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': '3148309', 'n_tokens_mistral': 949, 'n_tokens_neox': 891, 'n_words': 170}