#!/bin/bash # Set the source directory containing the JSON files source_dir="multilingual" # Set the destination directory to save the modified JSON files destination_dir="fi_processed" # Create the destination directory if it doesn't exist mkdir -p "$destination_dir" # Process each train split JSON file in the source directory for file in "$source_dir"/c4-fi.*.json; do # Extract the filename without the directory path and extension filename=$(basename -- "$file") filename="${filename%.*}" # Remove the "lang" key from the JSON file using jq because it had errors while trying to load into huggingface datasets jq -c 'del(.lang)' "$file" > "$destination_dir/$filename.json" done # Process each validation split JSON file in the source directory for file in "$source_dir"/c4-fi-validation*.json; do # Extract the filename without the directory path and extension filename=$(basename -- "$file") filename="${filename%.*}" # Remove the "lang" key from the JSON file using jq because it had errors while trying to load into huggingface datasets jq -c 'del(.lang)' "$file" > "$destination_dir/$filename.json" done