2024-10-04 15:28:44 +02:00
#!/bin/bash
2024-10-17 11:55:23 +02:00
# Check if the current directory is named 'AMR'
if [ " $( basename " $PWD " ) " != "AMR" ] ; then
echo "Error: The script must be run from the 'AMR' directory."
exit 1
fi
2024-11-21 12:02:58 +01:00
rm -rf data-raw/gpt_training_text_v*
2024-10-04 15:28:44 +02:00
# Define the output file, located in ./data-raw
2024-10-18 10:58:57 +02:00
version = " $1 "
output_file = " data-raw/gpt_training_text_v ${ version } .txt "
2024-10-04 15:28:44 +02:00
# Clear the output file if it exists
2024-10-18 10:58:57 +02:00
echo "This files contains all context you must know about the AMR package for R." > " $output_file "
2024-11-21 12:02:58 +01:00
echo " First and foremost, you are trained on version ${ version } . Remember this whenever someone asks which AMR package version you’ re at. " >> " $output_file "
echo "--------------------------------" >> " $output_file "
echo "" >> " $output_file "
2024-10-04 15:28:44 +02:00
# Function to remove header block (delimited by # ======)
remove_header( ) {
sed '/# =\{6,\}/,/# =\{6,\}/d' " $1 "
}
2024-10-17 11:55:23 +02:00
# Process all .R files in the 'R' folder
2024-11-21 12:02:58 +01:00
# for file in R/*.R; do
# echo "THE PART HEREAFTER CONTAINS CONTENTS FROM FILE '$file':" >> "$output_file"
# echo -e "\n" >> "$output_file"
# remove_header "$file" >> "$output_file"
# echo -e "\n\n" >> "$output_file"
# done
2024-10-04 15:28:44 +02:00
2024-10-04 15:44:05 +02:00
# Process important metadata files (DESCRIPTION, NAMESPACE, index.md)
2024-11-21 12:02:58 +01:00
for file in NAMESPACE index.md; do
2024-10-04 15:28:44 +02:00
if [ [ -f $file ] ] ; then
2024-11-21 12:02:58 +01:00
echo " THE PART HEREAFTER CONTAINS CONTENTS FROM FILE ' $file ': " >> " $output_file "
echo -e "\n" >> " $output_file "
2024-10-04 15:28:44 +02:00
cat " $file " >> " $output_file "
echo -e "\n\n" >> " $output_file "
fi
done
2024-11-21 12:02:58 +01:00
# Process all .Rd files from the 'man' folder
for file in man/*.Rd; do
echo " THE PART HEREAFTER CONTAINS CONTENTS FROM FILE ' $file ': " >> " $output_file "
echo -e "\n" >> " $output_file "
2024-10-04 15:28:44 +02:00
remove_header " $file " >> " $output_file "
echo -e "\n\n" >> " $output_file "
done
2024-11-21 12:02:58 +01:00
# Process all .Rmd files in the 'vignettes' folder
for file in vignettes/*.Rmd; do
echo " THE PART HEREAFTER CONTAINS CONTENTS FROM FILE ' $file ': " >> " $output_file "
echo -e "\n" >> " $output_file "
remove_header " $file " >> " $output_file "
2024-10-04 15:28:44 +02:00
echo -e "\n\n" >> " $output_file "
2024-11-21 12:02:58 +01:00
done
# Process all .Rmd files in the 'vignettes' folder
echo "THE PART HEREAFTER CONTAINS THE README OF OUR PYTHON PACKAGE" >> " $output_file "
echo -e "\n" >> " $output_file "
for file in PythonPackage/AMR/README.md; do
2024-10-04 15:28:44 +02:00
remove_header " $file " >> " $output_file "
echo -e "\n\n" >> " $output_file "
done
2024-11-21 12:02:58 +01:00
# Process test files (if available) in the 'tests' folder
# for file in tests/*.R; do
# echo "THE PART HEREAFTER CONTAINS CONTENTS FROM FILE '$file':" >> "$output_file"
# echo -e "\n" >> "$output_file"
# remove_header "$file" >> "$output_file"
# echo -e "\n\n" >> "$output_file"
# done