<commit_before><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="<NAME>">

    <title>Propositional Logic Compiler</title>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <style>
    body {padding-top: 70px;}
    </style>
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>

  <!-- Navigation -->
  <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container">
        <a target="_blank" href="https://github.com/cmendesce/propositional-logic-compiler.git"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/52760788cde945287fbb584134c4cbc2bc36f904/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f77686974655f6666666666662e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png"></a>
          <!-- Brand and toggle get grouped for better mobile display -->
          <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                  <span class="sr-only">Toggle navigation</span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
              </button>
              <a class="navbar-brand" href="/">Propositional Logic Compiler</a>
          </div>
          <!-- Collect the nav links, forms, and other content for toggling -->
          <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
              <ul class="nav navbar-nav">
                  <li>
                      <a href="/about">About</a>
                  </li>
              </ul>
          </div>
          <!-- /.navbar-collapse -->
      </div>
      <!-- /.container -->
  </nav>
    <div class="container">
      <div class="page-header">
        <h1>Propositional Logic Compiler<br>
          <small>You can type an expression like <em>(~P)</em> or <em>((A^B)->(Av~B))</em> or <em>((A->(BvC))->((AvB)v(AvC)))</em> and you'll get the abstract syntax tree.</small></h1>
      </div>

      <div class="form-inline">
        <div class="form-group">
          <label for="expressionText">Expression</label>
          <input type="text" id="expressionText" size="70" class="form-control input-lg" placeholder="type an expression">
        </div>

        <div class="form-group">
          <button type="submit" id="btnEvaluate" class="btn btn-default btn-lg">Generate syntax tree</button>
        </div>
      </div>
      <br><br>
      <div class="panel panel-default" id="containerChart" style="display:none">
        <div class="panel-heading">Syxtax tree for <strong> <span id="expressionTitle" /></strong></div>
        <div class="panel-body">
          <div id="chart_div"></div>
        </div>
      </div>

    </div>

    <script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

    <script type="text/javascript">
      google.charts.load('current', {packages:["orgchart"]})
      var index = 0
      $('#btnEvaluate').on('click', evaluate)

      function draw(parent) {
        var data = new google.visualization.DataTable()
        data.addColumn('string', 'Node')
        data.addColumn('string', 'Parent')

        deep(data, parent)
        var chart = new google.visualization.OrgChart(document.getElementById('chart_div'))
        chart.draw(data)
        $('#containerChart').show()
      }



      function deep(data, node) {
        const parent = tokenString(node.token, index)
        let row = [parent, '']
        data.addRows([row])

        if (!!node.children) {
          node.children.forEach(child => {
            index++
            let row = [tokenString(child.token, index), parent]

            data.addRows([row])
            if (!!child.children) {
              deep(data, child, index)
            }
          })
        }

      }

      function tokenString(token, index) {
        return '('+index+') ' + token.type + ' ' + token.value
      }


      function evaluate() {
        index = 0
        const expression = $(expressionText).val()
        $.ajax({
          type: "POST",
          url: '/evaluate',
          data: JSON.stringify({'expression':expression}),
          contentType: 'application/json; charset=UTF-8',
          dataType: 'json',
          success: function(data) {
            $('#expressionTitle').text(expression)
            draw(data)
          },
        });
      }
    </script>
</body>
</html><commit_msg>Add support to es5<commit_after><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="<NAME>">

    <title>Propositional Logic Compiler</title>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <style>
    body {padding-top: 70px;}
    </style>
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>

  <!-- Navigation -->
  <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container">
        <a target="_blank" href="https://github.com/cmendesce/propositional-logic-compiler.git"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/52760788cde945287fbb584134c4cbc2bc36f904/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f77686974655f6666666666662e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png"></a>
          <!-- Brand and toggle get grouped for better mobile display -->
          <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                  <span class="sr-only">Toggle navigation</span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
              </button>
              <a class="navbar-brand" href="/">Propositional Logic Compiler</a>
          </div>
          <!-- Collect the nav links, forms, and other content for toggling -->
          <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
              <ul class="nav navbar-nav">
                  <li>
                      <a href="/about">About</a>
                  </li>
              </ul>
          </div>
          <!-- /.navbar-collapse -->
      </div>
      <!-- /.container -->
  </nav>
    <div class="container">
      <div class="page-header">
        <h1>Propositional Logic Compiler<br>
          <small>You can type an expression like <em>(~P)</em> or <em>((A^B)->(Av~B))</em> or <em>((A->(BvC))->((AvB)v(AvC)))</em> and you'll get the abstract syntax tree.</small></h1>
      </div>

      <div class="form-inline">
        <div class="form-group">
          <label for="expressionText">Expression</label>
          <input type="text" id="expressionText" size="70" class="form-control input-lg" placeholder="type an expression">
        </div>

        <div class="form-group">
          <button type="submit" id="btnEvaluate" class="btn btn-default btn-lg">Generate syntax tree</button>
        </div>
      </div>
      <br><br>
      <div class="panel panel-default" id="containerChart" style="display:none">
        <div class="panel-heading">Syxtax tree for <strong> <span id="expressionTitle" /></strong></div>
        <div class="panel-body">
          <div id="chart_div"></div>
        </div>
      </div>

    </div>

    <script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

    <script type="text/javascript">
      google.charts.load('current', {packages:["orgchart"]})
      var index = 0
      $('#btnEvaluate').on('click', evaluate)

      function draw(parent) {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Node');
        data.addColumn('string', 'Parent');

        deep(data, parent);
        var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
        chart.draw(data);
        $('#containerChart').show();
      }

      function deep(data, node) {
        var parent = tokenString(node.token, index);
        var row = [parent, ''];
        data.addRows([row]);

        if (!!node.children) {

          for (var i = 0; i < node.children.length; i++) {
            index++;
            var child = node.children[i];

            var row = [tokenString(child.token, index), parent]
            data.addRows([row]);
            if (!!child.children) {
              deep(data, child, index);
            }
          }
        }
      }

      function tokenString(token, index) {
        return '('+index+') ' + token.type + ' ' + token.value;
      }

      function evaluate() {
        index = 0;
        var expression = $(expressionText).val();
        $.ajax({
          type: "POST",
          url: '/evaluate',
          data: JSON.stringify({'expression':expression}),
          contentType: 'application/json; charset=UTF-8',
          dataType: 'json',
          success: function(data) {
            $('#expressionTitle').text(expression)
            draw(data)
          }
        });
      }
    </script>
</body>
</html>
{'fraction_non_alphanumeric': 0.1725417439703154, 'fraction_numerical': 0.03525046382189239, 'mean_word_length': 2.478864149725718, 'pattern_counts': {'":': 0, '<': 214, '<?xml version=': 0, '>': 220, 'https://': 18, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '3466668', 'n_tokens_mistral': 3640, 'n_tokens_neox': 3325, 'n_words': 603}