8000 feat(util): extend spell script by franbuehler · Pull Request #3233 · coreruleset/coreruleset · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(util): extend spell script #3233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions util/fp-finder/spell.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# This script finds common English words in .data files (if no argument provided).
#
# Or it finds english words in the provided input file (one argument). Example:
# bash util/fp-finder/spell.sh regex-assembly/932380.ra

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
RULES_DIR="${SCRIPT_DIR}/../../rules/"

for datafile in "$RULES_DIR"*.data; do
DATAFILE_NAME=${datafile##*/}

echo "-> checking ${DATAFILE_NAME}"

for word in $(grep -E '^[a-z]+$' "${datafile}" | uniq | sort); do
# If no argument provided:
if [ $# -eq 0 ]
then
for datafile in "$RULES_DIR"*.data; do
DATAFILE_NAME=${datafile##*/}
echo "-> checking ${DATAFILE_NAME}"
for word in $(grep -E '^[a-z]+$' "${datafile}" | uniq | sort); do
IS_NOT_ENGLISH=$(echo "${word}" | spell | wc -l)
if [ "${IS_NOT_ENGLISH}" -lt 1 ]; then
echo " \`- found English word: ${word}"
fi
done

done
echo ""
done
done
# If argument provided, check this file:
else
datafile=$SCRIPT_DIR/../../$1
DATAFILE_NAME=${datafile##*/}
for word in $(grep -E '[a-z]+$' "${datafile}" | grep -vE [#@\\] | uniq | sort); do
IS_NOT_ENGLISH=$(echo "${word}" | spell | wc -l)
if [ "${IS_NOT_ENGLISH}" -lt 1 ]; then
echo " \`- found English word: ${word}"
fi
done
echo ""
fi
0