]> zdv2.bktei.com Git - BK-2020-03.git/blob - unitproc/find_erotica.sh
feat(unitproc/find_erotica.sh):Build grep commands via arrays
[BK-2020-03.git] / unitproc / find_erotica.sh
1 #!/bin/bash
2 # Desc: Searches for erotic phrases in text files in specified working directory
3 # Usage: find_erotica.sh [dir]
4 # Depends: GNU Find utils, GNU Parallel 20210822, GNU Grep, GNU Coreutils 8.32, bc
5 # Version: 0.2.0
6
7
8 FIN_MAX=400;
9 export SHOW_FILENAME=false;
10 export CONTEXT_NOUN=128;
11 export CONTEXT_ADJ=64;
12 export CONTEXT_VERB=32;
13 export CONTEXT_MIX_1=32
14 export CONTEXT_MIX_2=32
15 export CONTEXT_PHRASE=16;
16
17
18 yell() { echo "$0: $*" >&2; } # print script path and all args to stderr
19 die() { yell "$*"; exit 111; } # same as yell() but non-zero exit status
20 must() { "$@" || die "cannot $*"; } # runs args as command, reports args if command fails
21 search_thread() {
22 # Desc: Apply filters to a file
23 # Depends: find_nouns();
24 # Input: arg1 file path
25 # Output: stdout search results
26
27 if [[ ! -f "$1" ]]; then die "FATAL:Not a file:$1"; fi;
28 local fin="$1";
29 # yell "STATUS:Starting search_thread() on ${fin}" # debug;
30 # yell "Processing: ${fin}..."; # debug
31
32 mapfile -t output < <(
33 find_nouns "$1" | \
34 find_adjectives | \
35 find_verbs | \
36 # find_mix_1 | \
37 # find_mix_2 | \
38 find_phrase | \
39 grep -v -- '-$'; # ADJUST ME
40 );
41
42 if [[ "${#output[@]}" -gt 0 ]]; then
43 printf "%s\n" "$(basename "${fin}" )";
44 printf "Result: %d lines.\n" "${#output[@]}"
45 printf "%s\n" "${output[@]}";
46 printf "\n";
47 fi;
48
49 # yell "STATUS:Finished search_thread() on ${fin}" # debug;
50 };
51 find_nouns() {
52 # Desc: Find nouns
53 # Usage: find_nouns [path]
54 # Input: arg1 text file path
55 # CONTEXT_NOUN grep parameter
56 # Output: stdout lines matching grep patterns
57
58 if [[ ! -f "$1" ]]; then die "FATAL:Not a file:$1"; fi;
59 fin="$1";
60
61 #yell "STATUS:Starting find_nouns() on $fin" # debug;
62
63 local cmd+=('grep');
64 cmd+=('--ignore-case');
65 cmd+=('--extended-regexp');
66 if [[ "$SHOW_FILENAME" == "true" ]]; then cmd+=('--with-filename'); fi;
67 cmd+=('--line-number');
68 cmd+=('--context' "$CONTEXT_NOUN");
69 cmd+=('-e' 'nipple');
70 cmd+=('-e' 'areola');
71 cmd+=('-e' 'breast');
72 cmd+=('-e' 'womanhood');
73 cmd+=('-e' 'manhood');
74 cmd+=('-e' 'his member');
75 cmd+=('-e' 'slit');
76 cmd+=('-e' 'pussy');
77 cmd+=('-e' 'vagina');
78 cmd+=('-e' ' cock');
79 cmd+=('-e' 'dildo');
80 cmd+=('-e' 'shaft');
81 cmd+=('-e' 'blood');
82 cmd+=('-e' ' lust');
83 cmd+=('-e' 'tongue');
84 cmd+=('-e' 'neck');
85 cmd+=('-e' 'voyeur');
86 cmd+=('-e' 'ecstacy');
87 cmd+=('-e' 'pleasure');
88 cmd+=('-e' 'tingle');
89 cmd+=('-e' 'orgasm');
90 cmd+=('-e' 'lips');
91 cmd+=('-e' 'lovers');
92 cmd+=('-e' 'hard-on');
93 cmd+=('-e' 'whore');
94 cmd+=('-e' 'sex');
95 cmd+=('-e' 'throat');
96 cmd+=('-e' 'cleavage');
97 cmd+=('--');
98 cmd+=("$fin");
99 local output; mapfile -t output < <( "${cmd[@]}"; );
100 printf "%s\n" "${output[@]}";
101
102 # yell "STATUS:Finished find_nouns() on $fin" # debug;
103 }; # find nouns
104 find_adjectives() {
105 # Desc: Find adjectives
106 # Usage: cat *.txt | find_adjectives
107 # Input: stdin input lines
108 # CONTEXT_ADJ grep parameter
109 # Output: stdout lines matching grep patterns
110
111 local cmd+=('grep');
112 cmd+=('--ignore-case');
113 cmd+=('--extended-regexp');
114 cmd+=('--context' "$CONTEXT_ADJ");
115 cmd+=('-e' 'handsome');
116 cmd+=('-e' 'gorgeous');
117 cmd+=('-e' 'beautiful');
118 cmd+=('-e' 'bewitching');
119 cmd+=('-e' 'seductive');
120 cmd+=('-e' 'lusty');
121 cmd+=('-e' 'comely');
122 cmd+=('-e' 'stunning');
123 cmd+=('-e' 'elegant');
124 cmd+=('-e' 'exquisite');
125 cmd+=('-e' 'luxurious');
126 cmd+=('-e' 'ravishing');
127 cmd+=('-e' 'magnificent');
128 cmd+=('-e' 'glistening');
129 cmd+=('-e' 'lovely');
130 cmd+=('-e' 'loving');
131 cmd+=('-e' 'sexy|sexual|sexiest');
132 cmd+=('-e' 'sweet');
133 cmd+=('-e' 'sensual');
134 cmd+=('-e' 'arousing');
135 cmd+=('-e' 'warm');
136 cmd+=('-e' 'moist');
137 cmd+=('-e' 'soaked');
138 cmd+=('-e' 'hot');
139 cmd+=('-e' 'gentle');
140 cmd+=('-e' 'supple');
141 cmd+=('-e' 'tender');
142 cmd+=('-e' 'pleasurabl');
143 cmd+=('-e' 'buxom|busty|curvy');
144 cmd+=('--');
145 cmd+=('-');
146
147 local output; mapfile -t output < <( "${cmd[@]}"; );
148 printf "%s\n" "${output[@]}";
149 }; # find adjectives
150 find_verbs() {
151 # Desc: Find verbs
152 # Usage: cat *.txt | find_verbs
153 # Input: stdin input lines
154 # CONTEXT_VERB grep parameter
155 # Output: stdout lines matching grep patterns
156
157 local cmd+=('grep');
158 cmd+=('--ignore-case');
159 cmd+=('--extended-regexp');
160 cmd+=('--context' "$CONTEXT_VERB");
161 cmd+=('-e' 'love');
162 cmd+=('-e' 'nuzzle');
163 cmd+=('-e' 'pleasure');
164 cmd+=('-e' 'make love');
165 cmd+=('-e' 'fuck');
166 cmd+=('-e' 'arouse');
167 cmd+=('-e' 'quiver');
168 cmd+=('-e' 'tremble');
169 cmd+=('-e' 'caress');
170 cmd+=('-e' 'knead');
171 cmd+=('-e' 'kiss');
172 cmd+=('-e' 'moan');
173 cmd+=('-e' 'suck|suckle');
174 cmd+=('-e' 'fondle');
175 cmd+=('-e' 'grope');
176 cmd+=('-e' 'feel up|felt up|felt (me|her|him) up');
177 cmd+=('--');
178 cmd+=('-');
179 local output; mapfile -t output < <( "${cmd[@]}"; );
180 printf "%s\n" "${output[@]}";
181 }; # find verbs
182 find_mix_1() {
183 # Desc: Filter mix 1
184 # Usage: cat *.txt | find_mix_1
185 # Input: stdin input lines
186 # CONTEXT_VERB grep parameter
187 # Output: stdout lines matching grep patterns
188 local cmd+=('grep');
189 cmd+=('--ignore-case');
190 cmd+=('--context' "$CONTEXT_MIX_1");
191 cmd+=('-e' 'kiss');
192 cmd+=('-e' 'breast');
193 cmd+=('-e' 'tits');
194 cmd+=('-e' 'manhood');
195 cmd+=('-e' 'vagina');
196 cmd+=('-e' 'sex');
197 cmd+=('--');
198 cmd+=('-');
199 local output; mapfile -t output < <( "${cmd[@]}"; );
200 printf "%s\n" "${output[@]}";
201 };
202 find_mix_2() {
203 # Desc: Filter mix 2
204 # Usage: cat *.txt | find_mix_2
205 # Input: stdin input lines
206 # CONTEXT_VERB grep parameter
207 # Output: stdout lines matching grep patterns
208
209 local cmd+=('grep');
210 cmd+=('--ignore-case');
211 cmd+=('--context' "$CONTEXT_MIX_2");
212 cmd+=('-e' 'nipple');
213 cmd+=('-e' 'womanhood');
214 cmd+=('-e' 'manhood');
215 cmd+=('-e' 'slit');
216 cmd+=('-e' 'pussy');
217 cmd+=('-e' 'vagina');
218 cmd+=('-e' 'cock');
219 cmd+=('-e' 'shaft');
220 cmd+=('-e' '\ lust');
221 cmd+=('-e' 'voyeur');
222 cmd+=('-e' 'ecstacy');
223 cmd+=('-e' 'tingle');
224 cmd+=('-e' 'orgasm');
225 cmd+=('-e' 'gorgeous');
226 cmd+=('-e' 'bewitching');
227 cmd+=('-e' 'seductive');
228 cmd+=('-e' 'lusty');
229 cmd+=('-e' 'stunning');
230 cmd+=('-e' 'ravishing');
231 cmd+=('-e' 'lovely');
232 cmd+=('-e' 'sexy');
233 cmd+=('-e' 'sweet');
234 cmd+=('-e' 'sexiest');
235 cmd+=('-e' 'sensual');
236 cmd+=('-e' 'arousing');
237 cmd+=('-e' 'moist');
238 cmd+=('-e' 'love');
239 cmd+=('-e' 'nuzzle');
240 cmd+=('-e' 'pleasure');
241 cmd+=('-e' 'make\ love');
242 cmd+=('-e' 'sex');
243 cmd+=('-e' 'fuck');
244 cmd+=('-e' 'arouse');
245 cmd+=('-e' 'kiss');
246 cmd+=('-e' 'breast');
247 cmd+=('-e' 'tits');
248 cmd+=('-e' 'manhood');
249 cmd+=('-e' 'vagina');
250 cmd+=('-e' 'lips');
251 cmd+=('-e' 'lovers');
252 cmd+=('--');
253 cmd+=('-');
254 local output; mapfile -t output < <( "${cmd[@]}"; );
255 printf "%s\n" "${output[@]}";
256 };
257 find_phrase () {
258 # Desc: Filter phrase
259 # Usage: cat *.txt | find_phrase
260 # Input: stdin input lines
261 # CONTEXT_VERB grep parameter
262 # Output: stdout lines matching grep patterns
263
264 local cmd+=('grep');
265 cmd+=('--ignore-case');
266 cmd+=('--context' "$CONTEXT_PHRASE");
267 cmd+=('--extended-regexp');
268 cmd+=('--color=always');
269 cmd+=('-e' '( his| her| my) [^\.|;]{,48}( his| her| my) (breast|pussy|tits|nipple|womanhood|cock( |\.|,)|manhood|dick|cunt)');
270 cmd+=('-e' '( his| her| my) [^\.|;]{,24}nipple.{,24}harden');
271 cmd+=('-e' '(suck|lick)[^\.|;]{,12} (nipple|cock( |\.|,)|dick)');
272 cmd+=('-e' '(slap)[^\.|;]{,12}( ass)');
273 cmd+=('-e' '( his| her| my) [^\.|;]{,12} (cunt|pussy( |\.|,)|cock( |\.|,)|dick|shaft( |\.|,|;))');
274 cmd+=('--');
275 cmd+=('-');
276 "${cmd[@]}"; # execute command
277 }; # find phrase
278 main () {
279 din="$1";
280 if [[ ! -d "$din" ]]; then die "FATAL:Not a dir:${din}"; fi;
281
282 find "$din" -type f -name "*.txt" | shuf | head -n "$FIN_MAX" | \
283 #parallel search_thread '{}' | less --RAW-CONTROL-CHARS -S;
284 parallel search_thread '{}';
285 };
286 export -f yell die must search_thread find_nouns find_adjectives find_verbs find_mix_1 find_mix_2 find_phrase;
287
288 main "$@";