<commit_before>#!/bin/bash

#
#  prune URLs which have an error status,  or are redirected to an error page
#

site=directgov

awk '$3 ~ /^3/ { print $1 }' "$site.txt" | while read url; do curl -f -s -o /dev/null -w '%{url_effective} %{http_code} %{redirect_url}\n' "$url"; done > "$site-redirects".txt

awk '$3 ~ /(sendHTTPError|404.html|500.html)/ { print }' < "$site-redirects.txt" | sort > $site-errors.txt

awk '$3 !~ /^[4-5]/ { print }' < $site.txt | sort > $site-nonerror.txt

join -v 1 $site-nonerror.txt $site-errors.txt > $site-good.txt<commit_msg>We also want to exlude status codes that start with 3 from the non-error file as some of them are redirects to errors and they are all addressed in the previous line.<commit_after>#!/bin/bash

#
#  prune URLs which have an error status,  or are redirected to an error page
#

site=directgov

awk '$3 ~ /^3/ { print $1 }' "$site.txt" | while read url; do curl -f -s -o /dev/null -w '%{url_effective} %{http_code} %{redirect_url}\n' "$url"; done > "$site-redirects".txt

awk '$3 ~ /(sendHTTPError|404.html|500.html)/ { print }' < "$site-redirects.txt" | sort > $site-errors.txt

awk '$3 !~ /^[3-5]/ { print }' < $site.txt | sort > $site-nonerror.txt

join -v 1 $site-nonerror.txt $site-errors.txt > $site-good.txt
{'fraction_non_alphanumeric': 0.17966903073286053, 'fraction_numerical': 0.022852639873916468, 'mean_word_length': 3.601449275362319, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '3547809', 'n_tokens_mistral': 490, 'n_tokens_neox': 470, 'n_words': 146}