<commit_before>from operator import add

from IPython.html import widgets # Widget definitions
from IPython.utils.traitlets import Unicode, CInt, List, Bool, Any
from IPython.display import display, Javascript

def publish_stackedarea_js():
    with open('./static/stackedarea.js', 'r') as f:
        display(Javascript(data=f.read()))


# Define our ForceDirectedGraphWidget and its target model and default view.
class StackedAreaWidget(widgets.DOMWidget):
    _view_name = Unicode('D3StackedAreaView', sync=True)
    
    width = Any(400, sync=True)
    height = Any(300, sync=True)
    data = Unicode(sync=True)
    hide_xaxis = Bool(False, sync=True)
    
    _values = List([], sync=True)
    _line_values = List([], sync=True)
    _scale = List([(0, 10), (10, 0)], sync=True)

    def clear(self):
        self._values = []

    def get_layer(self, name, line=False):
        name = name.lower().strip()
        for layer in (self._line_values if line else self._values):
            if layer['name'].lower().strip() == name:
                return layer<commit_msg>Bug fixes<commit_after>import os
from operator import add

from IPython.html import widgets # Widget definitions
from IPython.utils.traitlets import Unicode, CInt, List, Bool, Any
from IPython.display import display, Javascript

def get_static_path():
    return os.path.join(os.path.split(__file__)[0], 'static')

def publish_stackedarea_js():
    with open(os.path.join(get_static_path(), 'stackedarea.js'), 'r') as f:
        display(Javascript(data=f.read()))


# Define our ForceDirectedGraphWidget and its target model and default view.
class StackedAreaWidget(widgets.DOMWidget):
    _view_name = Unicode('D3StackedAreaView', sync=True)
    
    width = Any(400, sync=True)
    height = Any(300, sync=True)
    data = Unicode(sync=True)
    hide_xaxis = Bool(False, sync=True)
    
    _values = List([], sync=True)
    _line_values = List([], sync=True)
    _scale = List([(0, 10), (10, 0)], sync=True)

    def clear(self):
        self._values = []

    def get_layer(self, name, line=False):
        name = name.lower().strip()
        for layer in (self._line_values if line else self._values):
            if layer['name'].lower().strip() == name:
                return layer
{'fraction_non_alphanumeric': 0.1273209549071618, 'fraction_numerical': 0.011936339522546418, 'mean_word_length': 3.50796812749004, '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': '5285606', 'n_tokens_mistral': 746, 'n_tokens_neox': 703, 'n_words': 190}