<commit_before>var request = require('request');
var cheerio = require('cheerio');

var getCount = function(callback) {
  var url = 'http://b.hatena.ne.jp/bouzuya/';
  request({ url: url }, function(err, res, body) {
    if (err) return callback(err);
    if (res.statusCode !== 200) {
      var e = new Error('invalid status code : ' + res.statusCode);
      return callback(e);
    }

    var $ = cheerio.load(body);
    var counts = [];
    $('#profile-count-navi dl').each(function() {
      var label = $(this).find('dt').text();
      var value = $(this).find('dd').text().replace(/,/g, '');
      counts.push({ label: label, count: value });
    });

    var labels = {
      'ブックマーク': 'Hatena Bookmark',
      'お気に入り': 'Hatena Bookmark Follow',
      'お気に入られ': 'Hatena Bookmark Follower',
    };

    counts = counts.map(function(count) {
      var newCount = count;
      Object.keys(labels).forEach(function(key) {
        if (key === count.label) {
          newCount = { label: labels[key], count: count.count };
        }
      });
      return newCount;
    });

    callback(null, counts);
  });
};

module.exports = getCount;<commit_msg>support cars<commit_after>var request = require('request');
var cheerio = require('cheerio');

var getCount = function(callback) {
  var url = 'http://b.hatena.ne.jp/bouzuya/';
  request({ url: url }, function(err, res, body) {
    if (err) return callback(err);
    if (res.statusCode !== 200) {
      var e = new Error('invalid status code : ' + res.statusCode);
      return callback(e);
    }

    var $ = cheerio.load(body);
    var counts = [];
    $('#profile-count-navi dl').each(function() {
      var label = $(this).find('dt').text();
      var value = $(this).find('dd').text().replace(/,/g, '');
      counts.push({ label: label, count: value });
    });

    var labels = {
      'ブックマーク': 'Hatena Bookmark',
      'お気に入り': 'Hatena Bookmark Follow',
      'お気に入られ': 'Hatena Bookmark Follower',
    };

    callback(null, counts.reduce(function(memo, count) {
      Object.keys(labels).forEach(function(label) {
        if (label === count.label) {
          memo[labels[label]] = count.count;
        }
      });
      return memo;
    }, {}));
  });
};

module.exports = getCount;
{'fraction_non_alphanumeric': 0.18638790035587188, 'fraction_numerical': 0.0026690391459074734, 'mean_word_length': 2.742096505823627, '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': '1928082', 'n_tokens_mistral': 766, 'n_tokens_neox': 748, 'n_words': 161}