<commit_before>_ = require 'underscore'

# Lifted from:
# https://raw.githubusercontent.com/artsy/artsy-backbone-mixins/master/lib/a_to_z.coffee

module.exports =
  #
  # Collection models must specify what to sort by through an `alphaSortKey` method
  # Sample output:
  # {
  #   '0-9': [ model_instance, model_instance, model_instance ],
  #   A: [ model_instance, model_instance, model_instance ],
  #   ...
  #   Z: [ model_instance, model_instance, model_instance ]
  # }
  groupByAlpha: ->
    instance = new @model()
    @groupBy (model) ->
      key = model.get('title')
      letter = key[0]
      if /^\d$/.test letter
        '0-9'
      else
        letter.toUpperCase()

  #
  # Groups collection output in a format suitable for rendering in an A-Z list with
  # a specified number of columns.
  #<commit_msg>Support accented chars in index<commit_after>_ = require 'underscore'
removeDiacritics = require('diacritics').remove

# Lifted from:
# https://raw.githubusercontent.com/artsy/artsy-backbone-mixins/master/lib/a_to_z.coffee

module.exports =
  #
  # Collection models must specify what to sort by through an `alphaSortKey` method
  # Sample output:
  # {
  #   '0-9': [ model_instance, model_instance, model_instance ],
  #   A: [ model_instance, model_instance, model_instance ],
  #   ...
  #   Z: [ model_instance, model_instance, model_instance ]
  # }
  groupByAlpha: ->
    instance = new @model()
    @groupBy (model) ->
      key = model.get('title')
      letter = key[0]
      if /^\d$/.test letter
        '0-9'
      else
        removeDiacritics(letter).toUpperCase()

  #
  # Groups collection output in a format suitable for rendering in an A-Z list with
  # a specified number of columns.
  #
{'fraction_non_alphanumeric': 0.12023121387283237, 'fraction_numerical': 0.005780346820809248, 'mean_word_length': 2.9793103448275864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '3466380', 'n_tokens_mistral': 576, 'n_tokens_neox': 566, 'n_words': 142}