<commit_before>"""
UI for monitoring data

features
- easy setup (simply run `python -m SimpleHTTPServer` in the directory)
- live monitoring (before all the data is done)
- customizable with data
  - eg. linear/log scale, rolling mean window
- multiple charts
- tooltips of the highlighted data point
- click the legend to hide lines
- draggable legend
"""

import re
import os
import json

import numpy as np

from .. import templates


class ResultWriter(object):

    """
    use cases:
    - live monitoring w/ a different process
    """

    def __init__(self, dirname, pattern, remove_matched=True):
        """
        remove_matched:
        whether or not to remove the matched results from the output map
        """
        self.dirname = dirname
        self.pattern = pattern
        self.remove_matched = remove_matched

        templates.copy_template("monitor_ui", dirname)
        self._json_path = os.path.join(self.dirname, "monitor.json")
        self._regex = re.compile(self.pattern)
<commit_msg>by default, don't remove matched keys in monitor ui<commit_after>"""
UI for monitoring data

features
- easy setup (simply run `python -m SimpleHTTPServer` in the directory)
- live monitoring (before all the data is done)
- customizable with data
  - eg. linear/log scale, rolling mean window
- multiple charts
- tooltips of the highlighted data point
- click the legend to hide lines
- draggable legend
"""

import re
import os
import json

import numpy as np

from .. import templates


class ResultWriter(object):

    """
    use cases:
    - live monitoring w/ a different process
    """

    def __init__(self, dirname, pattern, remove_matched=False):
        """
        remove_matched:
        whether or not to remove the matched results from the output map
        """
        self.dirname = dirname
        self.pattern = pattern
        self.remove_matched = remove_matched

        templates.copy_template("monitor_ui", dirname)
        self._json_path = os.path.join(self.dirname, "monitor.json")
        self._regex = re.compile(self.pattern)

{'fraction_non_alphanumeric': 0.08177008177008177, 'fraction_numerical': 0.0, 'mean_word_length': 2.9171374764595104, 'pattern_counts': {'":': 0, '<': 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': '5296628', 'n_tokens_mistral': 566, 'n_tokens_neox': 558, 'n_words': 214}