<commit_before>{% from 'macros.html' import include_src, include_md %}
{% extends "base.html" %}


{% block title %}bagofcharsd3{% endblock %}


{% block head %}
<style>
p{
    max-width: 60em;
}
path.slice{
    stroke-width: 2px;
}
polyline{
    opacity: .3;
    stroke: black;
    stroke-width: 2px;
    fill: none;
}
</style>
{% endblock %}


{% block content %}
<h1>Bag of Chars</h1>

<input type="text" class="form-control" id="sentence"
       placeholder="type a phrase"
       autocomplete="off" autofocus />

<br />
<div id="viz" style="height: 300px; width: 100%;"></div>

[[ include_md('bagofcharsd3/README.md') ]]

<h3>Log</h3>
<pre id="log"></pre>
{% endblock %}


{% block footerscripts %}
<script src="/bagofcharsd3/static/d3charcount.js?version=1"></script>
<script>
    var databench = Databench();

    $('#sentence').on('keyup', function(event) {
        databench.emit('sentence', {sentence: $(this).val()});
    });


    var d3viz = d3charcount('viz');

    databench.on('counts', function(msg) {
        console.log(msg);
        var reformattedData = Object.keys(msg).map(function(letter) {
            return {label:letter, value:msg[letter]};
        });
        console.log(reformattedData);
        if (reformattedData.length > 0) d3viz(reformattedData);
    });<commit_msg>minor<commit_after>{% from 'macros.html' import include_src, include_md %}
{% extends "base.html" %}


{% block title %}bagofcharsd3{% endblock %}


{% block head %}
<style>
path.slice {
    stroke-width: 2px;
}
polyline {
    opacity: .3;
    stroke: black;
    stroke-width: 2px;
    fill: none;
}
</style>
{% endblock %}


{% block content %}
<h1>Bag of Chars</h1>

<input type="text" class="form-control" id="sentence"
       placeholder="type a phrase"
       autocomplete="off" autofocus />

<br />
<div id="viz" style="height: 300px; width: 100%;"></div>

[[ include_md('bagofcharsd3/README.md') ]]

<h3>Log</h3>
<pre id="log"></pre>
{% endblock %}


{% block footerscripts %}
<script src="/bagofcharsd3/static/d3charcount.js?version=1"></script>
<script>
    var databench = Databench();

    $('#sentence').on('keyup', function(event) {
        databench.emit('sentence', {sentence: $(this).val()});
    });


    var d3viz = d3charcount('viz');

    databench.on('counts', function(msg) {
        var reformattedData = Object.keys(msg).map(function(letter) {
            return {label:letter, value:msg[letter]};
        });
        if (reformattedData.length > 0) d3viz(reformattedData);
    });
{'fraction_non_alphanumeric': 0.1901913875598086, 'fraction_numerical': 0.018341307814992026, 'mean_word_length': 3.561818181818182, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 35, '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': '2113785', 'n_tokens_mistral': 973, 'n_tokens_neox': 893, 'n_words': 171}