<commit_before><!DOCTYPE html>
<html>
  <head>
    <title>Formula Tree Graph</title>
    <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
#viz {
    display: inline-block;
}

.label {
    font: bold 14px monospace;
}

.link {
    fill: none;
    stroke: #ccc;
    stroke-width: 2.5px;
}
</style>
<script>
    function gTextArea( id ) {
        var el = document.getElementById( id );

        document.getElementById('console').value = '';
        try {
            renderTree( buildTree( parser.parse( el.value ) ) );
        }
        catch (ex) {
            document.getElementById('console').value = '' + ex;
        }
    }
</script>
  </head>
  <body>
        <a href="https://github.com/couchand/force-formula"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
        <textarea rows="20" cols="100" id="src"></textarea>
        <div id="viz"></div>
        <br>
        <textarea rows="10" cols="100" id="console"></textarea>
        <button onClick="gTextArea('src');">Graph!</button>
        <script>
            var module = {}
        </script>
        <script type="text/javascript" src="../dst/parser.js"></script>
        <script type="text/javascript" src="../dst/tree.js"></script>
        <script>
            var buildTree = module.exports;
        </script>
        <script type="text/javascript" src="../dst/nodes.js"></script>
    <script type="text/javascript">
 parser.yy = module.exports;

 function renderTree(treeData) {
      // Create a svg canvas
      var vis = d3.select("#viz").html(null).append("svg:svg")
      .attr("width", 600)
      .attr("height", 300)
      .append("svg:g")
      .attr("transform", "translate(40, 0)"); // shift everything to the right

      // Create a tree "canvas"
      var tree = d3.layout.cluster()
        .size([300,400]);

      var diagonal = d3.svg.diagonal()
      // change x and y (for the left to right tree)
      .projection(function(d) { return [d.y, d.x]; });

      // Preparing the data for the tree layout, convert data into an array of nodes
      var nodes = tree.nodes(treeData);
      // Create an array with all the links
      var links = tree.links(nodes);

      console.log(treeData)
      console.log(nodes)
      console.log(links)

      var link = vis.selectAll("pathlink")
      .data(links)
      .enter().append("svg:path")
      .attr("class", "link")
      .attr("d", diagonal)

      var node = vis.selectAll("g.node")
      .data(nodes)
      .enter().append("svg:g")
      .attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; })

      // Add the dot at every node
      node.append("svg:circle")
      .attr("r", 3.5);

      // place the name atribute left or right depending if children
      node.append("svg:text")
      .attr("x", function(d) { return d.children ? -8 : 8; })
      .attr("dy", 3)
      .attr("text-anchor", function(d) { return d.children ? "end" : "start"; })
      .attr("class", "label")
      .text(function(d) { return d.name; })
}
    </script>
        <script type="text/javascript">
          var _gaq = _gaq || [];
          _gaq.push(['_setAccount', 'UA-40537296-1']);
          _gaq.push(['_trackPageview']);
          (function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
          })();
        </script>
  </body>
</html><commit_msg>tree example: put node name in node<commit_after><!DOCTYPE html>
<html>
  <head>
    <title>Formula Tree Graph</title>
    <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
#viz {
    display: inline-block;
}

.label {
    font: bold 12px monospace;
}

.node ellipse {
    fill: #fff;
    stroke: steelblue;
    stroke-width: 1.5px;
}

.link {
    fill: none;
    stroke: #ccc;
    stroke-width: 3.5px;
}
</style>
<script>
    function gTextArea( id ) {
        var el = document.getElementById( id );

        document.getElementById('console').value = '';
        try {
            renderTree( buildTree( parser.parse( el.value ) ) );
        }
        catch (ex) {
            document.getElementById('console').value = '' + ex;
        }
    }
</script>
  </head>
  <body>
        <a href="https://github.com/couchand/force-formula"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
        <textarea rows="20" cols="100" id="src"></textarea>
        <div id="viz"></div>
        <br>
        <textarea rows="10" cols="100" id="console"></textarea>
        <button onClick="gTextArea('src');">Graph!</button>
        <script>
            var module = {}
        </script>
        <script type="text/javascript" src="../dst/parser.js"></script>
        <script type="text/javascript" src="../dst/tree.js"></script>
        <script>
            var buildTree = module.exports;
        </script>
        <script type="text/javascript" src="../dst/nodes.js"></script>
    <script type="text/javascript">
 parser.yy = module.exports;

 function renderTree(treeData) {
      // Create a svg canvas
      var vis = d3.select("#viz").html(null).append("svg:svg")
      .attr("width", 600)
      .attr("height", 300)
      .append("svg:g")
      .attr("transform", "translate(40, 0)"); // shift everything to the right

      // Create a tree "canvas"
      var tree = d3.layout.cluster()
        .size([300,400]);

      var diagonal = d3.svg.diagonal()
      // change x and y (for the left to right tree)
      .projection(function(d) { return [d.y, d.x]; });

      // Preparing the data for the tree layout, convert data into an array of nodes
      var nodes = tree.nodes(treeData);
      // Create an array with all the links
      var links = tree.links(nodes);

      console.log(treeData)
      console.log(nodes)
      console.log(links)

      var link = vis.selectAll("pathlink")
      .data(links)
      .enter().append("svg:path")
      .attr("class", "link")
      .attr("d", diagonal)

      var node = vis.selectAll("g.node")
      .data(nodes)
      .enter().append("svg:g")
      .attr("class", "node")
      .attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; })

      // Add the dot at every node
      node.append("svg:ellipse")
      .attr("rx", 33.5)
      .attr("ry", 9.5);

      // place the name atribute left or right depending if children
      node.append("svg:text")
      .attr("x", -1)
      .attr("dy", 5)
      .attr("text-anchor", function(d) { return "middle"; })// d.children ? "end" : "start"; })
      .attr("class", "label")
      .text(function(d) { return d.name; })
}
    </script>
        <script type="text/javascript">
          var _gaq = _gaq || [];
          _gaq.push(['_setAccount', 'UA-40537296-1']);
          _gaq.push(['_trackPageview']);
          (function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
          })();
        </script>
  </body>
</html>
{'fraction_non_alphanumeric': 0.18307449328770728, 'fraction_numerical': 0.016583311397736247, 'mean_word_length': 2.3728362183754994, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 85, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, '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': '3258614', 'n_tokens_mistral': 2539, 'n_tokens_neox': 2421, 'n_words': 544}