You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
959 B

4 years ago
  1. #!/usr/bin/env bash
  2. set -e
  3. usage(){
  4. echo "usage: check_spelling.sh <source directory>"
  5. exit 1
  6. }
  7. start_dir=$(pwd)
  8. script_dir=$(dirname "$0")
  9. cd "$script_dir"
  10. target_dir="$1"
  11. source_dir="$2"
  12. cp .pyspelling.yml "$target_dir"
  13. cd "$target_dir"
  14. # Determine what to ignore
  15. find "$source_dir" -type f -name "*.rpy" | xargs grep -Eno "#ignorespelling" | sed -r -e "s=${source_dir}==" | awk 'BEGIN {FS=":"}; {printf "^%s:%s\n", $1, $2}' > ignore_directives
  16. # Find suspect words
  17. pyspelling -n renpy_dialogue -S dialogue.txt | tail -n+4 | head -n -3 > suspect_words
  18. # Print the suspect words
  19. awk 'BEGIN {FS="\t"}; {printf "%s:%s\t%s\n", $4, $5, $3}' < dialogue.tab | column -ts $'\t' > pretty_dialogue.tab
  20. echo "Ignored lines:"
  21. grep -f ignore_directives pretty_dialogue.tab | grep --color -w -f suspect_words
  22. printf "\nSuspected misspellings:\n"
  23. grep -v -f ignore_directives pretty_dialogue.tab | grep --color -w -f suspect_words
  24. cd "$start_dir"
  25. exit 0