<commit_before>class BottleVersion < Version
  def self._parse spec
    spec = Pathname.new(spec) unless spec.is_a? Pathname
    stem = spec.stem

    # e.g. perforce-2013.1.610569-x86_64.mountain_lion.bottle.tar.gz
    m = /-([\d\.]+-x86(_64)?)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. R14B04 from erlang-r14-R14B04.yosemite.bottle.tar.gz
    m = /erlang-r\d+-(R\d+B\d+(-\d)?)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. x264-r2197.4.mavericks.bottle.tar.gz
    # e.g. lz4-r114.mavericks.bottle.tar.gz
    m = /-(r\d+\.?\d*)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. 00-5.0.5 from zpython-00-5.0.5.mavericks.bottle.tar.gz
    m = /(00-\d+\.\d+(\.\d+)+)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. 13-2.9.19 from libpano-13-2.9.19_1.yosemite.bottle.tar.gz
    m = /\D+-(\d+-[\d\.]+)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. 1.6.39 from pazpar2-1.6.39.mavericks.bottle.tar.gz
    m = /-(\d+\.\d+(\.\d+)+)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. ssh-copy-id-6.2p2.mountain_lion.bottle.tar.gz
    # e.g. icu4c-52.1.mountain_lion.bottle.tar.gz
    m = /-(\d+\.(\d)+(p(\d)+)?)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. 0_5_0 from disco-0_5_0.mavericks.bottle.tar.gz
    m = /-(\d+_\d+(_\d+)+)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. 20120731 from fontforge-20120731.mavericks.bottle.tar.gz
    m = /-(\d{8})/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. 2007f from imap-uw-2007f.yosemite.bottle.tar.gz
    m = /-(\d+[a-z])/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. 22 from ngircd-22.mavericks.bottle.tar.gz
    m = /-(\d{2})/.match(stem)
    return m.captures.first unless m.nil?

    super
  end
end<commit_msg>bottle_version: support psutils style<commit_after>class BottleVersion < Version
  def self._parse spec
    spec = Pathname.new(spec) unless spec.is_a? Pathname
    stem = spec.stem

    # e.g. perforce-2013.1.610569-x86_64.mountain_lion.bottle.tar.gz
    m = /-([\d\.]+-x86(_64)?)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. R14B04 from erlang-r14-R14B04.yosemite.bottle.tar.gz
    m = /erlang-r\d+-(R\d+B\d+(-\d)?)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. x264-r2197.4.mavericks.bottle.tar.gz
    # e.g. lz4-r114.mavericks.bottle.tar.gz
    m = /-(r\d+\.?\d*)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. 00-5.0.5 from zpython-00-5.0.5.mavericks.bottle.tar.gz
    m = /(00-\d+\.\d+(\.\d+)+)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. 13-2.9.19 from libpano-13-2.9.19_1.yosemite.bottle.tar.gz
    m = /\D+-(\d+-[\d\.]+)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. 1.6.39 from pazpar2-1.6.39.mavericks.bottle.tar.gz
    m = /-(\d+\.\d+(\.\d+)+)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. ssh-copy-id-6.2p2.mountain_lion.bottle.tar.gz
    # e.g. icu4c-52.1.mountain_lion.bottle.tar.gz
    m = /-(\d+\.(\d)+(p(\d)+)?)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. 0_5_0 from disco-0_5_0.mavericks.bottle.tar.gz
    m = /-(\d+_\d+(_\d+)+)/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. 20120731 from fontforge-20120731.mavericks.bottle.tar.gz
    m = /-(\d{8})/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. 2007f from imap-uw-2007f.yosemite.bottle.tar.gz
    m = /-(\d+[a-z])/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. 22 from ngircd-22.mavericks.bottle.tar.gz
    m = /-(\d{2})/.match(stem)
    return m.captures.first unless m.nil?

    # e.g. p17 from psutils-p17.yosemite.bottle.tar.gz
    m = /-(p\d{2})/.match(stem)
    return m.captures.first unless m.nil?

    super
  end
end
{'fraction_non_alphanumeric': 0.20678053830227744, 'fraction_numerical': 0.06237060041407867, 'mean_word_length': 2.3090753424657535, 'pattern_counts': {'":': 0, '<': 5, '<?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': '953084', 'n_tokens_mistral': 1992, 'n_tokens_neox': 1793, 'n_words': 260}