-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmkscowl
executable file
·81 lines (64 loc) · 2.67 KB
/
mkscowl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# mkscowl
# Concatenate, CAPITALIZE, and sort the scowl word lists of a specific size and smaller.
# After running this script, delete the old data directory and rerun generate_puzzles.py
# You may pick the spelling categories, sub-categories, and list size.
#
# For spelling categories, pick "english" and then add in "american" or "british" or both.
# For sub-categories, pick "words" and optionally add in "proper-names" or "abbreviations".
# For list size, pick 35 for a reasonable, but small dictionary. Or try 50, 70, 80, or 95.
spelling_categories={english,american,british}
#sub_categories={words,proper-names,abbreviations}
sub_categories=words # No brace expansion for a single item.
size=${1:-35} # Default to 35 if no command line arg given.
###
cd $(dirname $0)
if [[ ! -d scowl ]]; then
echo "Error: Scowl files not found in $(dirname $0)" >&2
exit 1
fi
outputfile=${spelling_categories}-${sub_categories}.${size}
outputfile=$(echo $outputfile | tr -d '{}')
possiblelists=$(eval echo scowl/$spelling_categories-$sub_categories.*)
for f in $possiblelists; do
s=${f##*.}
if [[ -e $f && $s -le $size ]]; then
wordlists+=($f)
fi
done
if [[ ${#wordlists} -eq 0 ]]; then
echo "Error: No word lists matched scowl/$spelling_categories-$sub_categories.*" >&2
echo "Please edit $0." >&2
exit 1
fi
echo "Creating $outputfile from these wordlists:"
for f in ${wordlists[@]}; do
echo " $f"
done
cat ${wordlists[@]} |
LANG=C grep -v "'" | # Skip words with apostrophes
iconv -f latin1 -t ASCII//TRANSLIT | # Remove accents (café -> cafe)
tr '[a-z]' '[A-Z]' |
sort -u > $outputfile
echo "Done."
if ln -sf $outputfile scowl.txt; then
echo "Linked $outputfile to scowl.txt"
fi
echo "You may now remove the 'data' directory and run generate_puzzles.py"
#####################################################################################
# Scowl file naming convention: #
# <spelling category>-<sub category>.<size> #
# #
# Where the spelling category is one of #
# english, american, british, british_z, canadian, australian #
# variant_1, variant_2, variant_3, #
# british_variant_1, british_variant_2, #
# canadian_variant_1, canadian_variant_2, #
# australian_variant_1, australian_variant_2 #
# #
# Sub-category is one of #
# abbreviations, contractions, proper-names, upper, words #
# #
# And size is one of #
# 10, 20, 35 (small), 40, 50 (medium), 55, 60, 70 (large), 80 (huge), 95 (insane) #
#####################################################################################