Skip to content

Instantly share code, notes, and snippets.

@orymate
Created October 7, 2012 13:12
Show Gist options
  • Save orymate/3848356 to your computer and use it in GitHub Desktop.
Save orymate/3848356 to your computer and use it in GitHub Desktop.
Magyar XKCD jelszó-generátor http://xkcd.com/936/
#!/bin/bash
DB=/var/tmp/frequent-words
CORPUS='ftp://ftp.mokk.bme.hu/Language/Hungarian/Freq/Web2.2/web2.2-freq-sorted.top100k.nofreqs.txt'
if [ ! -e "$DB" ]
then
wget "$CORPUS" -O - |
iconv -f latin2 | hunspell -G | hunspell -s |
iconv -t ascii//TRANSLIT | tr -d ":'\"" |
awk '$2 ~ /^[:lower:]/{print $2}' | sort -u > /var/tmp/frequent-words
fi
for i in $(seq ${2:-1})
do
echo $(sort -R "$DB" | head -n ${1:-4})
done
@tgulacsi
Copy link

#!/bin/bash

DB=/var/tmp/frequent-words
CORPUS='ftp://ftp.mokk.bme.hu/Language/Hungarian/Freq/Web2.2/web2.2-freq-sorted.top100k.nofreqs.txt'

if [ ! -s "$DB" ]
then
    curl -sS "$CORPUS"  | \
    iconv -f latin2 | hunspell -G | hunspell -s | \
    iconv -t ascii//TRANSLIT | tr -d ":'\"" | \
    awk '$2 ~ /^[:lower:]/{print $2}' | sort -u > /var/tmp/frequent-words
fi

for i in $(seq ${2:-1})
do
    echo $(sort -R "$DB" | head -n ${1:-4} | while read nm; do printf '% 3d %s\n' "${#nm}" "${nm}"; done | sort -k1 -n -r | cut -c5-)
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment