From: Steven Baltakatei Sandoval Date: Wed, 9 Apr 2025 10:58:54 +0000 (+0000) Subject: feat(unitproc/find_erotica.sh):Split one-liner into functions X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/f059459690d6487577943a708737b386ff5b01ca?ds=sidebyside;hp=51f3f8450b12a1f628a8c957ac30934540c5c826 feat(unitproc/find_erotica.sh):Split one-liner into functions --- diff --git a/unitproc/find_erotica.sh b/unitproc/find_erotica.sh index bed0970..0660d1e 100755 --- a/unitproc/find_erotica.sh +++ b/unitproc/find_erotica.sh @@ -2,14 +2,252 @@ # Desc: Searches for erotic phrases in text files in specified working directory # Usage: find_erotica.sh [dir] # Depends: GNU Find utils, GNU Parallel 20210822, GNU Grep, GNU Coreutils 8.32 -# Version: 0.0.1 - -find "$1" -type f -name "*.txt" | \ - shuf | head -n400 | \ - parallel grep -HEin -C256 -- 'nipple\|womanhood\|manhood\|his\ member\|slit\|pussy\|vagina\|cock\|shaft\|blood\|\ lust\|tongue\|neck\|voyeur\|ecstacy\|tingle\|orgasm\|lips' | \ - grep -i -C128 -- 'handsome\|gorgeous\|beautiful\|bewitching\|seductive\|lusty\|comely\|stunning\|elegant\|exquisite\|luxurious\|ravishing\|magnificent\|lovely\|sexy\|sweet\|sexiest\|sensual\|arousing\|warm\|moist' | \ - grep -i -C64 -- 'love\|nuzzle\|pleasure\|hot\|make\ love\|sex\|fuck\|arouse\|quiver' | \ - grep -i -C32 -- 'kiss\|breast\|tits\|manhood\|vagina' | \ - 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' | \ - grep -Ei -C12 --color=always -- '( his| her) .{,48}my (throat|breasts|pussy|tits|nipple|womanhood|cock|manhood|dick|cunt)' | \ - grep -v -- '-$' | less -S; +# Version: 0.1.0 + + +FIN_MAX=400 +export SHOW_FILENAME=false; +export CONTEXT_NOUN=256; +export CONTEXT_ADJ=128; +export CONTEXT_VERB=64; +export CONTEXT_MIX_1=32; +export CONTEXT_MIX_2=16; +export CONTEXT_PHRASE=12; + + +yell() { echo "$0: $*" >&2; } # print script path and all args to stderr +die() { yell "$*"; exit 111; } # same as yell() but non-zero exit status +must() { "$@" || die "cannot $*"; } # runs args as command, reports args if command fails +search_thread() { + # Desc: Apply filters to a file + # Depends: find_nouns(); + # Input: arg1 file path + # Output: stdout search results + + if [[ ! -f "$1" ]]; then die "FATAL:Not a file:$1"; fi; + local fin="$1"; + # yell "STATUS:Starting search_thread() on ${fin}" # debug; + # yell "Processing: ${fin}..."; # debug + + mapfile -t output < <( + find_nouns "$1" | \ + find_adjectives | \ + find_verbs | \ +# find_mix_1 | \ + find_mix_2 | \ + find_phrase | \ + grep -v -- '-$'; # ADJUST ME + ); + + if [[ "${#output[@]}" -gt 0 ]]; then + printf "%s\n" "$(basename "${fin}" )"; + printf "Result: %d lines.\n" "${#output[@]}" + printf "%s\n" "${output[@]}"; + printf "\n"; + fi; + + # yell "STATUS:Finished search_thread() on ${fin}" # debug; +}; +find_nouns() { + # Desc: Find nouns + # Usage: find_nouns [path] + # Input: arg1 text file path + # CONTEXT_NOUN grep parameter + # Output: stdout lines matching grep patterns + + if [[ ! -f "$1" ]]; then die "FATAL:Not a file:$1"; fi; + fin="$1"; + + #yell "STATUS:Starting find_nouns() on $fin" # debug; + + local cmd+=('grep'); + cmd+=('--ignore-case'); + if [[ "$SHOW_FILENAME" == "true" ]]; then cmd+=('--with-filename'); fi; + cmd+=('--line-number'); + cmd+=('--context' "$CONTEXT_NOUN"); + + #declare -p cmd CONTEXT_NOUN 1>&2; # debug + + "${cmd[@]}" \ + -e 'nipple' \ + -e 'womanhood' \ + -e 'manhood' \ + -e 'his member' \ + -e 'slit' \ + -e 'pussy' \ + -e 'vagina' \ + -e 'cock' \ + -e 'shaft' \ + -e 'blood' \ + -e '\ lust' \ + -e 'tongue' \ + -e 'neck' \ + -e 'voyeur' \ + -e 'ecstacy' \ + -e 'tingle' \ + -e 'orgasm' \ + -e 'lips' \ + -- \ + "$fin" ; + # yell "STATUS:Finished find_nouns() on $fin" # debug; +}; # find nouns +find_adjectives() { + # Desc: Find adjectives + # Usage: cat *.txt | find_adjectives + # Input: stdin input lines + # CONTEXT_ADJ grep parameter + # Output: stdout lines matching grep patterns + + local cmd+=('grep'); + cmd+=('--ignore-case'); + cmd+=('--context' "$CONTEXT_ADJ"); + "${cmd[@]}" \ + -e 'handsome' \ + -e 'gorgeous' \ + -e 'beautiful' \ + -e 'bewitching' \ + -e 'seductive' \ + -e 'lusty' \ + -e 'comely' \ + -e 'stunning' \ + -e 'elegant' \ + -e 'exquisite' \ + -e 'luxurious' \ + -e 'ravishing' \ + -e 'magnificent' \ + -e 'lovely' \ + -e 'sexy' \ + -e 'sweet' \ + -e 'sexiest' \ + -e 'sensual' \ + -e 'arousing' \ + -e 'warm' \ + -e 'moist' \ + -- \ + - ; +}; # find adjectives +find_verbs() { + # Desc: Find verbs + # Usage: cat *.txt | find_verbs + # Input: stdin input lines + # CONTEXT_VERB grep parameter + # Output: stdout lines matching grep patterns + grep \ + --ignore-case \ + --context="$CONTEXT_VERB" \ + -e 'love' \ + -e 'nuzzle' \ + -e 'pleasure' \ + -e 'hot' \ + -e 'make\ love' \ + -e 'sex' \ + -e 'fuck' \ + -e 'arouse' \ + -e 'quiver' \ + -- \ + - ; +}; # find verbs +find_mix_1() { + # Desc: Filter mix 1 + # Usage: cat *.txt | find_mix_1 + # Input: stdin input lines + # CONTEXT_VERB grep parameter + # Output: stdout lines matching grep patterns + grep \ + --ignore-case \ + --context="$CONTEXT_MIX_1" \ + -e 'kiss' \ + -e 'breast' \ + -e 'tits' \ + -e 'manhood' \ + -e 'vagina' \ + -- \ + - ; +}; +find_mix_2() { + # Desc: Filter mix 2 + # Usage: cat *.txt | find_mix_2 + # Input: stdin input lines + # CONTEXT_VERB grep parameter + # Output: stdout lines matching grep patterns + grep \ + --ignore-case \ + --context="$CONTEXT_MIX_2" \ + -e 'nipple' \ + -e 'womanhood' \ + -e 'manhood' \ + -e 'slit' \ + -e 'pussy' \ + -e 'vagina' \ + -e 'cock' \ + -e 'shaft' \ + -e '\ lust' \ + -e 'voyeur' \ + -e 'ecstacy' \ + -e 'tingle' \ + -e 'orgasm' \ + -e 'gorgeous' \ + -e 'bewitching' \ + -e 'seductive' \ + -e 'lusty' \ + -e 'stunning' \ + -e 'ravishing' \ + -e 'lovely' \ + -e 'sexy' \ + -e 'sweet' \ + -e 'sexiest' \ + -e 'sensual' \ + -e 'arousing' \ + -e 'moist' \ + -e 'love' \ + -e 'nuzzle' \ + -e 'pleasure' \ + -e 'make\ love' \ + -e 'sex' \ + -e 'fuck' \ + -e 'arouse' \ + -e 'kiss' \ + -e 'breast' \ + -e 'tits' \ + -e 'manhood' \ + -e 'vagina' \ + -e 'lips' \ + -- \ + - ; +}; +find_phrase () { + # Desc: Filter phrase + # Usage: cat *.txt | find_phrase + # Input: stdin input lines + # CONTEXT_VERB grep parameter + # Output: stdout lines matching grep patterns + grep \ + --ignore-case \ + --context="$CONTEXT_PHRASE" \ + --extended-regexp \ + --color=always \ + -e '( his| her) .{,48}my (throat|breasts|pussy|tits|nipple|womanhood|cock|manhood|dick|cunt)' \ + -- \ + - ; +}; # find phrase +main () { + din="$1"; + if [[ ! -d "$din" ]]; then die "FATAL:Not a dir:${din}"; fi; + + find "$din" -type f -name "*.txt" | shuf | head -n "$FIN_MAX" | \ + parallel search_thread '{}' | less --RAW-CONTROL-CHARS -S; +}; +export -f yell die must search_thread find_nouns find_adjectives find_verbs find_mix_1 find_mix_2 find_phrase; + +main "$@"; + + +# find "$1" -type f -name "*.txt" | \ +# shuf | head -n400 | \ +# parallel grep -HEin -C256 -- 'nipple\|womanhood\|manhood\|his\ member\|slit\|pussy\|vagina\|cock\|shaft\|blood\|\ lust\|tongue\|neck\|voyeur\|ecstacy\|tingle\|orgasm\|lips' | \ +# grep -i -C128 -- 'handsome\|gorgeous\|beautiful\|bewitching\|seductive\|lusty\|comely\|stunning\|elegant\|exquisite\|luxurious\|ravishing\|magnificent\|lovely\|sexy\|sweet\|sexiest\|sensual\|arousing\|warm\|moist' | \ +# grep -i -C64 -- 'love\|nuzzle\|pleasure\|hot\|make\ love\|sex\|fuck\|arouse\|quiver' | \ +# grep -i -C32 -- 'kiss\|breast\|tits\|manhood\|vagina' | \ +# 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' | \ +# grep -Ei -C12 --color=always -- '( his| her) .{,48}my (throat|breasts|pussy|tits|nipple|womanhood|cock|manhood|dick|cunt)' | \ +# grep -v -- '-$' | less --RAW-CONTROL-CHARS -S;