Fix missing dates + top words scripts
This commit is contained in:
23
top_words.sh
23
top_words.sh
@ -6,25 +6,32 @@ set -o pipefail
|
||||
fetch_top_words() {
|
||||
local url
|
||||
local basedir
|
||||
|
||||
|
||||
url="${1:-}"
|
||||
basedir=$(dirname "$0")
|
||||
|
||||
|
||||
if [[ $(uname -s) == "Darwin" ]]; then
|
||||
gnubin_dir="/usr/local/opt/grep/libexec/gnubin"
|
||||
if test -f "$gnubin_dir"; then
|
||||
brew install grep
|
||||
fi
|
||||
export PATH="$gnubin_dir:$PATH"
|
||||
fi
|
||||
|
||||
if [[ "${url:-}" = "" ]]; then
|
||||
grep --only-matching --extended-regexp '[a-zA-Z]{3,}' "$basedir/README.md" \
|
||||
\grep --only-matching --extended-regexp '[a-zA-Z]{3,}' "$basedir/README.md" \
|
||||
| tr '[:upper:]' '[:lower:]' \
|
||||
| grep --invert-match --word-regexp --fixed-strings --file=stopwords.txt \
|
||||
| \grep --invert-match --word-regexp --fixed-strings --file=stopwords.txt \
|
||||
| sort \
|
||||
| uniq --count \
|
||||
| uniq -c \
|
||||
| sort -n
|
||||
else
|
||||
curl "$url" \
|
||||
| grep --only-matching --extended-regexp '[a-zA-Z]{3,}' \
|
||||
| \grep --only-matching --extended-regexp '[a-zA-Z]{3,}' \
|
||||
| tr '[:upper:]' '[:lower:]' \
|
||||
| grep --invert-match --word-regexp --fixed-strings --file=stopwords.txt \
|
||||
| \grep --invert-match --word-regexp --fixed-strings --file=stopwords.txt \
|
||||
| sort \
|
||||
| uniq --count \
|
||||
| uniq -c \
|
||||
| sort -n
|
||||
fi
|
||||
}
|
||||
|
Reference in New Issue
Block a user