<commit_before># Strict quote parser for the format entered into the clipboard by the Slack thick client.

moment = require 'moment'
_ = require 'underscore'

# RegExp snippets for reuse
TS = '\\[(\d{1,2}:\d{2}(?: [aApP][mM])?)\\]' # [11:22 AM] *or* [16:00]

# RegExps
rxWs = /^\s*$/
rxNickLine = new RegExp("^\s*(\S+)\s+#{TS}\s*$")
rxTsLine = new RegExp("^\s*#{TS}\s*")

parseTs = (ts) ->
  parsed = moment(ts, ['h:mm a', 'H:mm'], true)
  unless parsed.isValid()
    throw new Error("Invalid date: [#{ts}]")
  parsed

module.exports = (lines) ->
  [nick, ts] = []

  result = []
  for line in lines
    if rxWs.test line
      continue

    m = rxNickLine.exec line
    if m?
      nick = m[1]
      ts = parseTs m[2]
      continue

    m = rxTsLine.exec line
    if m?
      ts = parseTs m[1]
      continue

    unless nick? and ts?
      throw new Error("Expected nick and timestamp line first.")

    result.push "#{nick} [#{ts}] #{line}"
  result<commit_msg>Trim `(edited)` from the ends of lines.<commit_after># Strict quote parser for the format entered into the clipboard by the Slack thick client.

moment = require 'moment'
_ = require 'underscore'

# RegExp snippets for reuse
TS = '\\[(\d{1,2}:\d{2}(?: [aApP][mM])?)\\]' # [11:22 AM] *or* [16:00]

# RegExps
rxWs = /^\s*$/
rxNickLine = new RegExp("^\s*(\S+)\s+#{TS}\s*$")
rxTsLine = new RegExp("^\s*#{TS}\s*")

parseTs = (ts) ->
  parsed = moment(ts, ['h:mm a', 'H:mm'], true)
  unless parsed.isValid()
    throw new Error("Invalid date: [#{ts}]")
  parsed

module.exports = (lines) ->
  [nick, ts] = []

  result = []
  for line in lines
    if rxWs.test line
      continue

    m = rxNickLine.exec line
    if m?
      nick = m[1]
      ts = parseTs m[2]
      continue

    m = rxTsLine.exec line
    if m?
      ts = parseTs m[1]
      continue

    unless nick? and ts?
      throw new Error("Expected nick and timestamp line first.")

    line = line.replace(/\s*\(edited\)$/, '')

    result.push "#{nick} [#{ts}] #{line}"
  result
{'fraction_non_alphanumeric': 0.18422366450324512, 'fraction_numerical': 0.013979031452820768, 'mean_word_length': 2.7882797731569, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2616581', 'n_tokens_mistral': 788, 'n_tokens_neox': 745, 'n_words': 221}