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

require 'csv'

abort "Usage: #{__FILE__} http://example.com < document_mappings.csv" unless ARGV.size > 0

input = CSV.parse($stdin, headers: true).select { |row|
  /#{Regexp.escape(ARGV.first)}/ =~ row['Old Url']
}.collect { |row|
  [row['Old Url'], row['New Url']] if ['published','draft','submitted'].include?(row['State'])
}<commit_msg>Hack to work around broken attachment CSV rows<commit_after>#!/usr/bin/env ruby

require 'csv'

abort "Usage: #{__FILE__} http://example.com < document_mappings.csv" unless ARGV.size > 0

def include_row?(row)
  # 'Whole Tag' is because attachments are currently in the wrong format
  ['published', 'draft', 'submitted'].include?(row['State']) || row['Whole Tag'] == 'Closed'
end

input = CSV.parse($stdin, headers: true).select { |row|
  /#{Regexp.escape(ARGV.first)}/ =~ row['Old Url']
}.collect { |row|
  [row['Old Url'], row['New Url']] if include_row? row
}
{'fraction_non_alphanumeric': 0.19936034115138593, 'fraction_numerical': 0.0021321961620469083, 'mean_word_length': 5.218543046357616, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7627934', 'n_tokens_mistral': 342, 'n_tokens_neox': 330, 'n_words': 84}