<commit_before>#!/usr/bin/env ruby

######
# Run this script to add/update NCIP's mandatory license headers or to verify
# the presence of the headers in all applicable files.
#
# Usage:
#   $ cd {PSC_WORKING_ROOT}
#   $ ruby license_headers.rb [update|check]
#
# The `update` subcommand applies the current license to all applicable files.
#
# The `check` subcommand verifies that all applicable files have the license. If
# any are missing the license, it exits with a status of 1 and prints a
# descriptive message to standard out.

###### UPDATE STRATEGIES

class LicenseUpdater
  LICENSE_TOKEN = /\{LICENSE\}/

  LICENSE_HEADER_TEXT = <<-TEXT
Copyright Northwestern University.

Distributed under the OSI-approved BSD 3-Clause License.
See http://ncip.github.com/psc/LICENSE for details.
TEXT

  attr_reader :filename, :contents

  def initialize(filename)
    @filename = filename
    @contents = File.read(filename)
  end

  def needs_update?
    new_contents != contents
  end

  def update
    File.open(filename, 'w') { |f| f.write(new_contents) } if needs_update?
  end

  def new_contents
    if contents =~ license_pattern
      contents.sub(license_pattern, license_comment)
    else
      with_new_license
    end<commit_msg>Correct URL.<commit_after>#!/usr/bin/env ruby

######
# Run this script to add/update NCIP's mandatory license headers or to verify
# the presence of the headers in all applicable files.
#
# Usage:
#   $ cd {PSC_WORKING_ROOT}
#   $ ruby license_headers.rb [update|check]
#
# The `update` subcommand applies the current license to all applicable files.
#
# The `check` subcommand verifies that all applicable files have the license. If
# any are missing the license, it exits with a status of 1 and prints a
# descriptive message to standard out.

###### UPDATE STRATEGIES

class LicenseUpdater
  LICENSE_TOKEN = /\{LICENSE\}/

  LICENSE_HEADER_TEXT = <<-TEXT
Copyright Northwestern University.

Distributed under the OSI-approved BSD 3-Clause License.
See http://ncip.github.com/psc/LICENSE.txt for details.
TEXT

  attr_reader :filename, :contents

  def initialize(filename)
    @filename = filename
    @contents = File.read(filename)
  end

  def needs_update?
    new_contents != contents
  end

  def update
    File.open(filename, 'w') { |f| f.write(new_contents) } if needs_update?
  end

  def new_contents
    if contents =~ license_pattern
      contents.sub(license_pattern, license_comment)
    else
      with_new_license
    end
{'fraction_non_alphanumeric': 0.08940797422472815, 'fraction_numerical': 0.0016109544905356424, 'mean_word_length': 3.832684824902724, 'pattern_counts': {'":': 0, '<': 7, '<?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': '464957', 'n_tokens_mistral': 767, 'n_tokens_neox': 725, 'n_words': 258}