<commit_before>#! /bin/bash

set -euo pipefail

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

# $1 - Name of shflags REGION variable, so that caller can customize their
#      shflags name to plural form (e.g. FLAGS_regions).
script_input() {
  local region_variable_name="${1:-"FLAGS_region"}"

  if [ -t 0 ]; then
    if [ "${!region_variable_name}+defined" ]; then
      echo "${!region_variable_name}" | xargs printf "%s\n"
    else
      $DIR/ec2-describe-regions.sh $(option_if_not_blank "${!region_variable_name}" "-r \"${!region_variable_name}\"")
    fi
  else
    cat /dev/stdin
  fi | $DIR/resources_by_region.awk
}

script_output() {
  local region="$1"
  if [ ! -z "${FLAGS_jq}" ]; then
    cat -
  else
    cat - | awk --assign region=$region '{ print region, $0 }'
  fi
}

extract() {
  local resource_type="$1"
  local region="${2:-}"

  if [ "$resource_type" == "region" ]; then<commit_msg>Removed function no longer used<commit_after>#! /bin/bash

set -euo pipefail

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

# $1 - Name of shflags REGION variable, so that caller can customize their
#      shflags name to plural form (e.g. FLAGS_regions).
script_input() {
  local region_variable_name="${1:-"FLAGS_region"}"

  if [ -t 0 ]; then
    if [ "${!region_variable_name}+defined" ]; then
      echo "${!region_variable_name}" | xargs printf "%s\n"
    else
      $DIR/ec2-describe-regions.sh $(option_if_not_blank "${!region_variable_name}" "-r \"${!region_variable_name}\"")
    fi
  else
    cat /dev/stdin
  fi | $DIR/resources_by_region.awk
}

extract() {
  local resource_type="$1"
  local region="${2:-}"

  if [ "$resource_type" == "region" ]; then
{'fraction_non_alphanumeric': 0.17337278106508874, 'fraction_numerical': 0.009467455621301775, 'mean_word_length': 3.5702702702702704, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6864209', 'n_tokens_mistral': 614, 'n_tokens_neox': 590, 'n_words': 150}