]> zdv2.bktei.com Git - BK-2020-03.git/blob - unitproc/find_erotica.sh
0660d1e5fca6bc6f91031993fc7840aea349a03b
[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
5 # Version: 0.1.0
6
7
8 FIN_MAX=400
9 export SHOW_FILENAME=false;
10 export CONTEXT_NOUN=256;
11 export CONTEXT_ADJ=128;
12 export CONTEXT_VERB=64;
13 export CONTEXT_MIX_1=32;
14 export CONTEXT_MIX_2=16;
15 export CONTEXT_PHRASE=12;
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 if [[ "$SHOW_FILENAME" == "true" ]]; then cmd+=('--with-filename'); fi;
66 cmd+=('--line-number');
67 cmd+=('--context' "$CONTEXT_NOUN");
68
69 #declare -p cmd CONTEXT_NOUN 1>&2; # debug
70
71 "${cmd[@]}" \
72 -e 'nipple' \
73 -e 'womanhood' \
74 -e 'manhood' \
75 -e 'his member' \
76 -e 'slit' \
77 -e 'pussy' \
78 -e 'vagina' \
79 -e 'cock' \
80 -e 'shaft' \
81 -e 'blood' \
82 -e '\ lust' \
83 -e 'tongue' \
84 -e 'neck' \
85 -e 'voyeur' \
86 -e 'ecstacy' \
87 -e 'tingle' \
88 -e 'orgasm' \
89 -e 'lips' \
90 -- \
91 "$fin" ;
92 # yell "STATUS:Finished find_nouns() on $fin" # debug;
93 }; # find nouns
94 find_adjectives() {
95 # Desc: Find adjectives
96 # Usage: cat *.txt | find_adjectives
97 # Input: stdin input lines
98 # CONTEXT_ADJ grep parameter
99 # Output: stdout lines matching grep patterns
100
101 local cmd+=('grep');
102 cmd+=('--ignore-case');
103 cmd+=('--context' "$CONTEXT_ADJ");
104 "${cmd[@]}" \
105 -e 'handsome' \
106 -e 'gorgeous' \
107 -e 'beautiful' \
108 -e 'bewitching' \
109 -e 'seductive' \
110 -e 'lusty' \
111 -e 'comely' \
112 -e 'stunning' \
113 -e 'elegant' \
114 -e 'exquisite' \
115 -e 'luxurious' \
116 -e 'ravishing' \
117 -e 'magnificent' \
118 -e 'lovely' \
119 -e 'sexy' \
120 -e 'sweet' \
121 -e 'sexiest' \
122 -e 'sensual' \
123 -e 'arousing' \
124 -e 'warm' \
125 -e 'moist' \
126 -- \
127 - ;
128 }; # find adjectives
129 find_verbs() {
130 # Desc: Find verbs
131 # Usage: cat *.txt | find_verbs
132 # Input: stdin input lines
133 # CONTEXT_VERB grep parameter
134 # Output: stdout lines matching grep patterns
135 grep \
136 --ignore-case \
137 --context="$CONTEXT_VERB" \
138 -e 'love' \
139 -e 'nuzzle' \
140 -e 'pleasure' \
141 -e 'hot' \
142 -e 'make\ love' \
143 -e 'sex' \
144 -e 'fuck' \
145 -e 'arouse' \
146 -e 'quiver' \
147 -- \
148 - ;
149 }; # find verbs
150 find_mix_1() {
151 # Desc: Filter mix 1
152 # Usage: cat *.txt | find_mix_1
153 # Input: stdin input lines
154 # CONTEXT_VERB grep parameter
155 # Output: stdout lines matching grep patterns
156 grep \
157 --ignore-case \
158 --context="$CONTEXT_MIX_1" \
159 -e 'kiss' \
160 -e 'breast' \
161 -e 'tits' \
162 -e 'manhood' \
163 -e 'vagina' \
164 -- \
165 - ;
166 };
167 find_mix_2() {
168 # Desc: Filter mix 2
169 # Usage: cat *.txt | find_mix_2
170 # Input: stdin input lines
171 # CONTEXT_VERB grep parameter
172 # Output: stdout lines matching grep patterns
173 grep \
174 --ignore-case \
175 --context="$CONTEXT_MIX_2" \
176 -e 'nipple' \
177 -e 'womanhood' \
178 -e 'manhood' \
179 -e 'slit' \
180 -e 'pussy' \
181 -e 'vagina' \
182 -e 'cock' \
183 -e 'shaft' \
184 -e '\ lust' \
185 -e 'voyeur' \
186 -e 'ecstacy' \
187 -e 'tingle' \
188 -e 'orgasm' \
189 -e 'gorgeous' \
190 -e 'bewitching' \
191 -e 'seductive' \
192 -e 'lusty' \
193 -e 'stunning' \
194 -e 'ravishing' \
195 -e 'lovely' \
196 -e 'sexy' \
197 -e 'sweet' \
198 -e 'sexiest' \
199 -e 'sensual' \
200 -e 'arousing' \
201 -e 'moist' \
202 -e 'love' \
203 -e 'nuzzle' \
204 -e 'pleasure' \
205 -e 'make\ love' \
206 -e 'sex' \
207 -e 'fuck' \
208 -e 'arouse' \
209 -e 'kiss' \
210 -e 'breast' \
211 -e 'tits' \
212 -e 'manhood' \
213 -e 'vagina' \
214 -e 'lips' \
215 -- \
216 - ;
217 };
218 find_phrase () {
219 # Desc: Filter phrase
220 # Usage: cat *.txt | find_phrase
221 # Input: stdin input lines
222 # CONTEXT_VERB grep parameter
223 # Output: stdout lines matching grep patterns
224 grep \
225 --ignore-case \
226 --context="$CONTEXT_PHRASE" \
227 --extended-regexp \
228 --color=always \
229 -e '( his| her) .{,48}my (throat|breasts|pussy|tits|nipple|womanhood|cock|manhood|dick|cunt)' \
230 -- \
231 - ;
232 }; # find phrase
233 main () {
234 din="$1";
235 if [[ ! -d "$din" ]]; then die "FATAL:Not a dir:${din}"; fi;
236
237 find "$din" -type f -name "*.txt" | shuf | head -n "$FIN_MAX" | \
238 parallel search_thread '{}' | less --RAW-CONTROL-CHARS -S;
239 };
240 export -f yell die must search_thread find_nouns find_adjectives find_verbs find_mix_1 find_mix_2 find_phrase;
241
242 main "$@";
243
244
245 # find "$1" -type f -name "*.txt" | \
246 # shuf | head -n400 | \
247 # parallel grep -HEin -C256 -- 'nipple\|womanhood\|manhood\|his\ member\|slit\|pussy\|vagina\|cock\|shaft\|blood\|\ lust\|tongue\|neck\|voyeur\|ecstacy\|tingle\|orgasm\|lips' | \
248 # grep -i -C128 -- 'handsome\|gorgeous\|beautiful\|bewitching\|seductive\|lusty\|comely\|stunning\|elegant\|exquisite\|luxurious\|ravishing\|magnificent\|lovely\|sexy\|sweet\|sexiest\|sensual\|arousing\|warm\|moist' | \
249 # grep -i -C64 -- 'love\|nuzzle\|pleasure\|hot\|make\ love\|sex\|fuck\|arouse\|quiver' | \
250 # grep -i -C32 -- 'kiss\|breast\|tits\|manhood\|vagina' | \
251 # grep -i -C16 -- 'nipple\|womanhood\|manhood\|slit\|pussy\|vagina\|cock\|shaft\|\ lust\|voyeur\|ecstacy\|tingle\|orgasm\|gorgeous\|bewitching\|seductive\|lusty\|stunning\|ravishing\|lovely\|sexy\|sweet\|sexiest\|sensual\|arousing\|moist\|love\|nuzzle\|pleasure\|make\ love\|sex\|fuck\|arouse\|kiss\|breast\|tits\|manhood\|vagina\|lips' | \
252 # grep -Ei -C12 --color=always -- '( his| her) .{,48}my (throat|breasts|pussy|tits|nipple|womanhood|cock|manhood|dick|cunt)' | \
253 # grep -v -- '-$' | less --RAW-CONTROL-CHARS -S;