<commit_before>var _ = require('lodash');
var endings = require('./patterns/endings');
var lettersToTonify = require('./patterns/letters-to-tonify');
var toneMap = require('./tone-map');
var toneNumbers = [1, 2, 3, 4, 5];

module.exports = {
  /**
   * @param {string} phrase
   * @return {array}
   */
  splitPhraseIntoWords: function(phrase) {
    return phrase.split(' ');
  },

  /**
   * @param {string} word
   * @return {number|null}
   */
  getTone: function(word) {
    var lastCharacter = parseInt(_.last(word), 10);
    return _.includes(toneNumbers, lastCharacter) ? lastCharacter : null;
  },

  /**
   * @param {string} word
   * @return {string|null}
   */
  getEnding: function(word) {
    var ending = null;

    _.forEach(endings, function(pattern, plainEnding) {
      if (word.match(pattern)) {
        ending = plainEnding;
      }
    });

    return ending;
  },

  /**
   * @param {string} ending
   * @param {number} tone
   * @return {string}
   */
  tonifyEnding: function(ending, tone) {
    var letter;

    _.forEach(lettersToTonify, function(letterAndPattern) {
      if (!letter && ending.match(letterAndPattern.pattern)) {
        letter = letterAndPattern.letter;
      }
    });

    if (!letter) {
      return ending;
    }

    return ending.replace(letter, this.tonifyLetter(letter, tone));
  },

  /**
   * @param {string} letter
   * @param {number} tone
   * @return {string}
   */
  tonifyLetter: function(letter, tone) {
    var keys = letter + '.' + tone;
    return _.get(toneMap, keys, letter);
  },

  /**
   * Strips a tone number from a word.
   * @param {string} word
   * @return {string}
   */
  stripToneNumber: function(word) {
    return _.trim(word, toneNumbers);
  },

  /**
   * @param {string} word
   * @return {string}
   */
  tonifyWord: function(word) {
    var tone = this.getTone(word);<commit_msg>Remove redundant function description<commit_after>var _ = require('lodash');
var endings = require('./patterns/endings');
var lettersToTonify = require('./patterns/letters-to-tonify');
var toneMap = require('./tone-map');
var toneNumbers = [1, 2, 3, 4, 5];

module.exports = {
  /**
   * @param {string} phrase
   * @return {array}
   */
  splitPhraseIntoWords: function(phrase) {
    return phrase.split(' ');
  },

  /**
   * @param {string} word
   * @return {number|null}
   */
  getTone: function(word) {
    var lastCharacter = parseInt(_.last(word), 10);
    return _.includes(toneNumbers, lastCharacter) ? lastCharacter : null;
  },

  /**
   * @param {string} word
   * @return {string|null}
   */
  getEnding: function(word) {
    var ending = null;

    _.forEach(endings, function(pattern, plainEnding) {
      if (word.match(pattern)) {
        ending = plainEnding;
      }
    });

    return ending;
  },

  /**
   * @param {string} ending
   * @param {number} tone
   * @return {string}
   */
  tonifyEnding: function(ending, tone) {
    var letter;

    _.forEach(lettersToTonify, function(letterAndPattern) {
      if (!letter && ending.match(letterAndPattern.pattern)) {
        letter = letterAndPattern.letter;
      }
    });

    if (!letter) {
      return ending;
    }

    return ending.replace(letter, this.tonifyLetter(letter, tone));
  },

  /**
   * @param {string} letter
   * @param {number} tone
   * @return {string}
   */
  tonifyLetter: function(letter, tone) {
    var keys = letter + '.' + tone;
    return _.get(toneMap, keys, letter);
  },

  /**
   * @param {string} word
   * @return {string}
   */
  stripToneNumber: function(word) {
    return _.trim(word, toneNumbers);
  },

  /**
   * @param {string} word
   * @return {string}
   */
  tonifyWord: function(word) {
    var tone = this.getTone(word);
{'fraction_non_alphanumeric': 0.16051710207379477, 'fraction_numerical': 0.0037705359547535685, 'mean_word_length': 2.813141683778234, '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': '2673115', 'n_tokens_mistral': 1287, 'n_tokens_neox': 1219, 'n_words': 269}