<commit_before>/**
 * common.js
 * Useful utils
 *
 * @author <NAME>
 */

var fs = require('fs');

function sendFile(res, file, contentType) {
  fs.readFile(file, function(err, data) {
    if(err) {
      res.writeHead(500, {
        'Content-Type': 'text/plain',
        'Content-Length': (''+err).length
      });
      res.end(''+err);
      return;
    }

    res.writeHead(200, {
      'Content-Type': contentType ? contentType : 'text/html',
      'Content-Length': data.length
    });

    res.end(data, 'utf8');
  });
}

var SHORTEN_DICTIONARY = 'abcdefghijklmnopqrstuvwxyz0123456789';

function shortenId(n) {
  if(typeof n === 'string')
    n = parseInt(n, 10);

  var result = '';
  for(var i = 0; n > 0; n = Math.floor(n / SHORTEN_DICTIONARY.length)) {
    result = SHORTEN_DICTIONARY[n % SHORTEN_DICTIONARY.length] + result;
  }

  return result;
}

function unshortenId(s) {
  var result = 0;

  for(var i = 0; i < s.length; i++) {
    result += SHORTEN_DICTIONARY.indexOf(s[i]) * Math.pow(SHORTEN_DICTIONARY.length, s.length - i - 1);
  }

  return result;
}

exports.sendFile = sendFile;
exports.shortenId = shortenId;
epxorts.unshortenId = unshortenId;<commit_msg>Fix typo.<commit_after>/**
 * common.js
 * Useful utils
 *
 * @author <NAME>
 */

var fs = require('fs');

function sendFile(res, file, contentType) {
  fs.readFile(file, function(err, data) {
    if(err) {
      res.writeHead(500, {
        'Content-Type': 'text/plain',
        'Content-Length': (''+err).length
      });
      res.end(''+err);
      return;
    }

    res.writeHead(200, {
      'Content-Type': contentType ? contentType : 'text/html',
      'Content-Length': data.length
    });

    res.end(data, 'utf8');
  });
}

var SHORTEN_DICTIONARY = 'abcdefghijklmnopqrstuvwxyz0123456789';

function shortenId(n) {
  if(typeof n === 'string')
    n = parseInt(n, 10);

  var result = '';
  for(var i = 0; n > 0; n = Math.floor(n / SHORTEN_DICTIONARY.length)) {
    result = SHORTEN_DICTIONARY[n % SHORTEN_DICTIONARY.length] + result;
  }

  return result;
}

function unshortenId(s) {
  var result = 0;

  for(var i = 0; i < s.length; i++) {
    result += SHORTEN_DICTIONARY.indexOf(s[i]) * Math.pow(SHORTEN_DICTIONARY.length, s.length - i - 1);
  }

  return result;
}

exports.sendFile = sendFile;
exports.shortenId = shortenId;
exports.unshortenId = unshortenId;
{'fraction_non_alphanumeric': 0.16497031382527566, 'fraction_numerical': 0.020356234096692113, 'mean_word_length': 3.1169284467713787, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6284715', 'n_tokens_mistral': 941, 'n_tokens_neox': 885, 'n_words': 170}