<commit_before>var toCapitalCase = require('to-capital-case');

/**
 * Expose `formatOptions`
 */

module.exports.option = formatOption;

/**
 * Format Journey
 */

module.exports.journey = function(journey) {
  var i;

  for (i = 0; i < journey.routes.length; i++) {
    var r = journey.routes[i];
    r.route_long_name = format(r.route_long_name);
    r.route_short_name = format(r.route_short_name) || r.route_long_name;
  }

  for (i = 0; i < journey.stops.length; i++) {
    var s = journey.stops[i];
    s.stop_name = format(s.stop_name) || '';
  }

  return journey;
};

/**
 * Format a given option summary and it's segments
 */

function formatOption(o) {
  // If there are no segments to format, return
  if (!o.transit) return o;
  for (var i = 0; i < o.transit.length; i++) {
    var segment = o.transit[i];

    segment.fromName = format(segment.fromName);
    segment.toName = format(segment.toName);
    segment.longName = format(segment.longName);
    segment.shortName = format(segment.shortName);
  }

  return o;
}

/**
 * Format text
 */

function format(text) {
  if (!text) return;

  text = text
    .replace('METRO STATION', '') // remove metro station
    .replace('METRORAIL STATION', '')
    .replace('(MAIN)', '')
    .replace(/-/g, ' '); // remove hypens

  // capitalize correctly
  text = toCapitalCase(text);

  // process individual words
  text = text
    .split(' ')
    .map(word)
    .join(' ')
    .trim();

  return text;
}

/**
 * Words that get replaced
 */

var wordReplacementTable = {
  'Av': 'Ave',
  'Bwi': 'BWI',
  'Ci': 'Circle',
  'Marc': 'MARC',
  'Mcpherson': 'McPherson',
  'Pi': 'Pike',
  'Sq': 'Square',
  'Md': 'MD',
  'Nw': 'NW',
  'Northwest': 'NW',
  'Ne': 'NE',
  'Nih': 'NIH',
  'Northeast': 'NE',
  'South': 'S',
  'Se': 'SE',
  'Southeast': 'SE',
  'Sw': 'SW',
  'Southwest': 'SW',
  'Metro/naval': 'Metro/Naval',
  'Noma': 'NoMA',
  'Noma-gallaudet': 'NoMA-Gallaudet',
  'Park/u': 'Park/U',
  '(new': '(New',
  'L\'enfant': 'L\'Enfant',
  '(west)': '(West)'
};

/**
 * Word replacement
 */

function word(w) {
  return wordReplacementTable.hasOwnProperty(w) ? wordReplacementTable[w] : w;
}<commit_msg>Capitalize PRTC short name correctly<commit_after>var toCapitalCase = require('to-capital-case');

/**
 * Expose `formatOptions`
 */

module.exports.option = formatOption;

/**
 * Format Journey
 */

module.exports.journey = function(journey) {
  var i;

  for (i = 0; i < journey.routes.length; i++) {
    var r = journey.routes[i];
    r.route_long_name = format(r.route_long_name);
    r.route_short_name = format(r.route_short_name) || r.route_long_name;
  }

  for (i = 0; i < journey.stops.length; i++) {
    var s = journey.stops[i];
    s.stop_name = format(s.stop_name) || '';
  }

  return journey;
};

/**
 * Format a given option summary and it's segments
 */

function formatOption(o) {
  // If there are no segments to format, return
  if (!o.transit) return o;
  for (var i = 0; i < o.transit.length; i++) {
    var segment = o.transit[i];

    segment.fromName = format(segment.fromName);
    segment.toName = format(segment.toName);
    segment.longName = format(segment.longName);
    segment.shortName = format(segment.shortName);
  }

  return o;
}

/**
 * Format text
 */

function format(text) {
  if (!text) return;

  text = text
    .replace('METRO STATION', '') // remove metro station
    .replace('METRORAIL STATION', '')
    .replace('(MAIN)', '')
    .replace(/-/g, ' '); // remove hypens

  // capitalize correctly
  text = toCapitalCase(text);

  // process individual words
  text = text
    .split(' ')
    .map(word)
    .join(' ')
    .trim();

  return text;
}

/**
 * Words that get replaced
 */

var wordReplacementTable = {
  'Av': 'Ave',
  'Bwi': 'BWI',
  'Ci': 'Circle',
  'Lh': 'LH',
  'Marc': 'MARC',
  'Mcpherson': 'McPherson',
  'Pi': 'Pike',
  'Sq': 'Square',
  'Md': 'MD',
  'Nw': 'NW',
  'Northwest': 'NW',
  'Ne': 'NE',
  'Nih': 'NIH',
  'Northeast': 'NE',
  'South': 'S',
  'Se': 'SE',
  'Southeast': 'SE',
  'Sw': 'SW',
  'Southwest': 'SW',
  'Metro/naval': 'Metro/Naval',
  'Noma': 'NoMA',
  'Noma-gallaudet': 'NoMA-Gallaudet',
  'Park/u': 'Park/U',
  '(new': '(New',
  'L\'enfant': 'L\'Enfant',
  '(west)': '(West)'
};

/**
 * Word replacement
 */

function word(w) {
  return wordReplacementTable.hasOwnProperty(w) ? wordReplacementTable[w] : w;
}
{'fraction_non_alphanumeric': 0.20013739409205406, 'fraction_numerical': 0.0013739409205404168, 'mean_word_length': 3.163965681601525, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3848587', 'n_tokens_mistral': 1737, 'n_tokens_neox': 1675, 'n_words': 368}