<commit_before>Promise = require('bluebird')
xre = require('xregexp').XRegExp

class ChangeLog
  constructor: (@blob) ->

  parse: ->
    entryRe = xre(
      '^(?<pkgname>\\w+)' +
      '\\s' +
      '\\(' +
      '(?<major>\\d+)' +
      '\\.' +
      '(?<minor>\\d+)' +
      '\\.?' +
      '(?<patchLevel>\\d+)?-' +
      '(?<versionExtra>\\d+.*)\\)' +
      '\\s' +
      '(?<series>\\w+);\\surgency=(?<priority>\\w+)' +
      '\\s+\\*\\s(?<body>.*)' +
      '\\s*--\\s(?<ts>.*)', 'img')

    matches = []
    xre.forEach @blob, entryRe, (matchVer, i) ->
      model =
        pkgname: matchVer.pkgname
        major: parseInt(matchVer.major, 10)
        minor: parseInt(matchVer.minor, 10)
        patchLevel: parseInt(matchVer.patchLevel, 10) or undefined
        versionExtra: matchVer.versionExtra
        series: matchVer.series
        priority: matchVer.priority
      model.debVersion = "#{model.major}.#{model.minor}"
      if model.patchLevel?
        model.debVersion = "#{model.debVersion}.#{model.patchLevel}"
      model.semVer = false
      if xre.exec("#{model.major}.#{model.minor}.#{model.patchLevel}",
        /^(\d+\.\d+\.\d+)/)
        model.semVer = true
      model.body = matchVer.body
      model.timestamp = matchVer.ts
      matches.push model
    return Promise.all(matches)

module.exports = ChangeLog<commit_msg>expand timestamp parse<commit_after>Promise = require('bluebird')
xre = require('xregexp').XRegExp

class ChangeLog
  constructor: (@blob) ->

  parse: ->
    entryRe = xre(
      '^(?<pkgname>\\w+)' +
      '\\s' +
      '\\(' +
      '(?<major>\\d+)' +
      '\\.' +
      '(?<minor>\\d+)' +
      '\\.?' +
      '(?<patchLevel>\\d+)?-' +
      '(?<versionExtra>\\d+.*)\\)' +
      '\\s' +
      '(?<series>\\w+);\\surgency=(?<priority>\\w+)' +
      '\\s+\\*\\s(?<body>.*)' +
      '\\s*--\\s(?<firstname>\\w+)' +
      '\\s' +
      '(?<lastname>\\w+)' +
      '\\s' +
      '(?<email><.*>)' +
      '\\s+' +
      '(?<timestamp>.*)$', 'img')

    matches = []
    xre.forEach @blob, entryRe, (match, i) ->
      model =
        pkgname: match.pkgname
        major: parseInt(match.major, 10)
        minor: parseInt(match.minor, 10)
        patchLevel: parseInt(match.patchLevel, 10) or undefined
        versionExtra: match.versionExtra
        series: match.series
        priority: match.priority
      model.debVersion = "#{model.major}.#{model.minor}"
      if model.patchLevel?
        model.debVersion = "#{model.debVersion}.#{model.patchLevel}"
      model.semVer = false
      if xre.exec("#{model.major}.#{model.minor}.#{model.patchLevel}",
        /^(\d+\.\d+\.\d+)/)
        model.semVer = true
      model.body = match.body
      model.firstname = match.firstname
      model.lastname = match.lastname
      model.email = match.email
      model.timestamp = match.timestamp
      matches.push model
    return Promise.all(matches)

module.exports = ChangeLog
{'fraction_non_alphanumeric': 0.2210058159425248, 'fraction_numerical': 0.004105371193978789, 'mean_word_length': 2.11395101171459, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 31, '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': '4761876', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1025, 'n_words': 155}