<commit_before><!doctype html>
<head>
  <link rel="stylesheet"
        href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
        integrity="<KEY>"
        crossorigin="anonymous">
<title>Gender Ratio of Twitter Friends and Followers</title>
<style type="text/css">
.glyphicon.spinning {
  animation: spin 1s infinite linear;
  -webkit-animation: spin2 1s infinite linear;
}

@keyframes spin {
    from { transform: scale(1) rotate(0deg); }
    to { transform: scale(1) rotate(360deg); }
}

@-webkit-keyframes spin2 {
    from { -webkit-transform: rotate(0deg); }
    to { -webkit-transform: rotate(360deg); }
}
</style>
</head>
<body>
{% macro render_field(field) %}
<dt>{{ field.label }}
<dd>{{ field(**kwargs)|safe }}
  {% if field.errors %}
  <ul class=errors>
    {% for error in field.errors %}
    <li>{{ error }}</li>
    {% endfor %}
  </ul>
  {% endif %}
</dd>
{% endmacro %}

<script type="application/javascript">
  function analyze_click() {
    var button = document.getElementById("analyze-button");
    button.disabled = true;

    var user_id = document.getElementById("user_id");
    user_id.readOnly = true;

    var text = document.getElementById("analyze-button-text");
    text.style.display = 'none';

    var loading = document.getElementById("analyze-loading");
    loading.style.display = 'block';

    return true;
  }
</script>

<div class="container-fluid">
  <div class="col-md-8 col-md-offset-1">
  {% if session.get('twitter_user') %}
    <h4>Hello, @{{ session.twitter_user }}.</h4>
    <p><a href="/logout">Deauthorize this application with Twitter.</a></p>
  {% endif %}
  <h1>Gender Ratio of Twitter Friends and Followers</h1>
  <p class="lead">Estimate the gender ratio of your followers and those you follow.</p>

  {% if session.get('twitter_user') %}
    <form method="post" onsubmit="return analyze_click()">
      <div class="form-group">
        <label for="user_id">Twitter User:</label>
        <div class="input-group col-xs-4">
          <span class="input-group-addon">@</span>
          <input type="text" class="form-control" name="user_id" id="user_id"
            {% if form.user_id.data %} value="{{ form.user_id.data }}"{% endif %}>
        </div>
      </div>
      <button id="analyze-button" type="submit" class="btn btn-primary">
        <span id="analyze-loading" style="display: none;"><span class="glyphicon glyphicon-refresh spinning"></span> Loading...</span>
        <span id="analyze-button-text" >Analyze</span>
      </button>
    </form>
  {% else %}
    <a href="/login" class="btn btn-primary">Log in with Twitter</a>
  {% endif %}

  {% if error %}
    <h2>Error</h2>
    <p>{{ error }}</p>
  {% endif %}

  {% if results %}
    <h2>Results for @{{ form.user_id.data }}</h2>
    <p>Sampled {{ results.friends.ids_sampled }} friends and {{ results.followers.ids_sampled }} followers.</p>
    <table class="table table-striped">
      <thead><tr><th>&nbsp;</th><th>men</th><th>women</th><th>undetermined</th></tr></thead>
      {% for user_type, users in [('Friends you follow', results.friends), ('Followers', results.followers)] %}
      <tr><td>{{ user_type }}</td><td>{{ users.men }}</td><td>{{ users.women }}</td><td>{{ users.andy }}</td></tr>
      <tr>
        <td>&nbsp;</td>
        <td>{{ div(100 * users.men, users.men + users.women)|round|int }}%</td>
        <td>{{ div(100 * users.women, users.men + users.women)|round|int }}%</td>
        <td>&nbsp;</td>
      </tr>
      {% endfor %}
    </table>
  {% endif %}

  </div>
  <div class="col-md-8 col-md-offset-1">
    <h5><a href="https://emptysqua.re/blog/gender-of-twitter-users-i-follow/">About this code</a></h5>
  </div>
</div>
</body>
<commit_msg>Say that estimate is based on first names.<commit_after><!doctype html>
<head>
  <link rel="stylesheet"
        href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
        integrity="<KEY>"
        crossorigin="anonymous">
<title>Gender Ratio of Twitter Friends and Followers</title>
<style type="text/css">
.glyphicon.spinning {
  animation: spin 1s infinite linear;
  -webkit-animation: spin2 1s infinite linear;
}

@keyframes spin {
    from { transform: scale(1) rotate(0deg); }
    to { transform: scale(1) rotate(360deg); }
}

@-webkit-keyframes spin2 {
    from { -webkit-transform: rotate(0deg); }
    to { -webkit-transform: rotate(360deg); }
}
</style>
</head>
<body>
{% macro render_field(field) %}
<dt>{{ field.label }}
<dd>{{ field(**kwargs)|safe }}
  {% if field.errors %}
  <ul class=errors>
    {% for error in field.errors %}
    <li>{{ error }}</li>
    {% endfor %}
  </ul>
  {% endif %}
</dd>
{% endmacro %}

<script type="application/javascript">
  function analyze_click() {
    var button = document.getElementById("analyze-button");
    button.disabled = true;

    var user_id = document.getElementById("user_id");
    user_id.readOnly = true;

    var text = document.getElementById("analyze-button-text");
    text.style.display = 'none';

    var loading = document.getElementById("analyze-loading");
    loading.style.display = 'block';

    return true;
  }
</script>

<div class="container-fluid">
  <div class="col-md-8 col-md-offset-1">
  {% if session.get('twitter_user') %}
    <h4>Hello, @{{ session.twitter_user }}.</h4>
    <p><a href="/logout">Deauthorize this application with Twitter.</a></p>
  {% endif %}
  <h1>Gender Ratio of Twitter Friends and Followers</h1>
  <p class="lead">Estimate the gender ratio of your followers and those you follow, based on their first names.</p>

  {% if session.get('twitter_user') %}
    <form method="post" onsubmit="return analyze_click()">
      <div class="form-group">
        <label for="user_id">Twitter User:</label>
        <div class="input-group col-xs-4">
          <span class="input-group-addon">@</span>
          <input type="text" class="form-control" name="user_id" id="user_id"
            {% if form.user_id.data %} value="{{ form.user_id.data }}"{% endif %}>
        </div>
      </div>
      <button id="analyze-button" type="submit" class="btn btn-primary">
        <span id="analyze-loading" style="display: none;"><span class="glyphicon glyphicon-refresh spinning"></span> Loading...</span>
        <span id="analyze-button-text" >Analyze</span>
      </button>
    </form>
  {% else %}
    <a href="/login" class="btn btn-primary">Log in with Twitter</a>
  {% endif %}

  {% if error %}
    <h2>Error</h2>
    <p>{{ error }}</p>
  {% endif %}

  {% if results %}
    <h2>Results for @{{ form.user_id.data }}</h2>
    <p>Sampled {{ results.friends.ids_sampled }} friends and {{ results.followers.ids_sampled }} followers.</p>
    <table class="table table-striped">
      <thead><tr><th>&nbsp;</th><th>men</th><th>women</th><th>undetermined</th></tr></thead>
      {% for user_type, users in [('Friends you follow', results.friends), ('Followers', results.followers)] %}
      <tr><td>{{ user_type }}</td><td>{{ users.men }}</td><td>{{ users.women }}</td><td>{{ users.andy }}</td></tr>
      <tr>
        <td>&nbsp;</td>
        <td>{{ div(100 * users.men, users.men + users.women)|round|int }}%</td>
        <td>{{ div(100 * users.women, users.men + users.women)|round|int }}%</td>
        <td>&nbsp;</td>
      </tr>
      {% endfor %}
    </table>
  {% endif %}

  </div>
  <div class="col-md-8 col-md-offset-1">
    <h5><a href="https://emptysqua.re/blog/gender-of-twitter-users-i-follow/">About this code</a></h5>
  </div>
</div>
</body>

{'fraction_non_alphanumeric': 0.20045436322330615, 'fraction_numerical': 0.010156354403314178, 'mean_word_length': 3.3410672853828305, 'pattern_counts': {'":': 0, '<': 209, '<?xml version=': 0, '>': 209, 'https://': 4, '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': '5070613', 'n_tokens_mistral': 2709, 'n_tokens_neox': 2489, 'n_words': 534}