]> zdv2.bktei.com Git - BK-2020-03.git/blobdiff - unitproc/find_erotica.sh
feat(user/htmlz_to_cbz.sh):Make CBZ from Calibre HTMLZ imgs
[BK-2020-03.git] / unitproc / find_erotica.sh
index 0660d1e5fca6bc6f91031993fc7840aea349a03b..3fd8b2258333f11fa4867d5e9c09266e17a54300 100755 (executable)
@@ -1,18 +1,18 @@
 #!/bin/bash
 # Desc: Searches for erotic phrases in text files in specified working directory
 # Usage: find_erotica.sh [dir]
 #!/bin/bash
 # 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.1.0
+# Depends: GNU Find utils, GNU Parallel 20210822, GNU Grep, GNU Coreutils 8.32, bc
+# Version: 0.2.2
 
 
 
 
-FIN_MAX=400
+FIN_MAX=400;
 export SHOW_FILENAME=false;
 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;
+export CONTEXT_NOUN=128;
+export CONTEXT_ADJ=64;
+export CONTEXT_VERB=32;
+export CONTEXT_MIX_1=32
+export CONTEXT_MIX_2=32
+export CONTEXT_PHRASE=16;
 
 
 yell() { echo "$0: $*" >&2; } # print script path and all args to stderr
 
 
 yell() { echo "$0: $*" >&2; } # print script path and all args to stderr
@@ -29,23 +29,23 @@ search_thread() {
     # yell "STATUS:Starting search_thread() on ${fin}"  # debug;
     # yell "Processing: ${fin}..."; # debug
 
     # yell "STATUS:Starting search_thread() on ${fin}"  # debug;
     # yell "Processing: ${fin}..."; # debug
 
-    mapfile -t output < <(        
+    mapfile -t output < <(
         find_nouns "$1" | \
             find_adjectives | \
             find_verbs | \
 #           find_mix_1 | \
         find_nouns "$1" | \
             find_adjectives | \
             find_verbs | \
 #           find_mix_1 | \
-            find_mix_2 | \
+#           find_mix_2 | \
             find_phrase | \
             grep -v -- '-$'; # ADJUST ME
     );
             find_phrase | \
             grep -v -- '-$'; # ADJUST ME
     );
-    
-    if [[ "${#output[@]}" -gt 0 ]]; then
+
+    if [[ "${#output[@]}" -gt 1 ]]; then
         printf "%s\n" "$(basename "${fin}" )";
         printf "%s\n" "$(basename "${fin}" )";
-        printf "Result: %d lines.\n" "${#output[@]}"        
+        printf "Result: %d lines.\n" "${#output[@]}";
         printf "%s\n" "${output[@]}";
         printf "\n";
     fi;
         printf "%s\n" "${output[@]}";
         printf "\n";
     fi;
-    
+
     # yell "STATUS:Finished search_thread() on ${fin}"  # debug;
 };
 find_nouns() {
     # yell "STATUS:Finished search_thread() on ${fin}"  # debug;
 };
 find_nouns() {
@@ -57,38 +57,48 @@ find_nouns() {
 
     if [[ ! -f "$1" ]]; then die "FATAL:Not a file:$1"; fi;
     fin="$1";
 
     if [[ ! -f "$1" ]]; then die "FATAL:Not a file:$1"; fi;
     fin="$1";
-    
+
     #yell "STATUS:Starting find_nouns() on $fin"  # debug;
     #yell "STATUS:Starting find_nouns() on $fin"  # debug;
-    
+
     local cmd+=('grep');
     cmd+=('--ignore-case');
     local cmd+=('grep');
     cmd+=('--ignore-case');
+    cmd+=('--extended-regexp');
     if [[ "$SHOW_FILENAME" == "true" ]]; then cmd+=('--with-filename'); fi;
     cmd+=('--line-number');
     cmd+=('--context' "$CONTEXT_NOUN");
     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" ;
+    cmd+=('-e' 'nipple');
+    cmd+=('-e' 'areola');
+    cmd+=('-e' 'breast');
+    cmd+=('-e' 'womanhood');
+    cmd+=('-e' 'manhood');
+    cmd+=('-e' 'his member');
+    cmd+=('-e' 'slit');
+    cmd+=('-e' 'pussy');
+    cmd+=('-e' 'vagina');
+    cmd+=('-e' ' cock');
+    cmd+=('-e' 'dildo');
+    cmd+=('-e' 'shaft');
+    cmd+=('-e' 'blood');
+    cmd+=('-e' ' lust');
+    cmd+=('-e' 'tongue');
+    cmd+=('-e' 'neck');
+    cmd+=('-e' 'voyeur');
+    cmd+=('-e' 'ecstacy');
+    cmd+=('-e' 'pleasure');
+    cmd+=('-e' 'tingle');
+    cmd+=('-e' 'orgasm');
+    cmd+=('-e' 'lips');
+    cmd+=('-e' 'lovers');
+    cmd+=('-e' 'hard-on');
+    cmd+=('-e' 'sex');
+    cmd+=('-e' 'throat');
+    cmd+=('-e' 'cleavage');
+    cmd+=('-e' 'kiss');
+    cmd+=('--');
+    cmd+=("$fin");
+    local output; mapfile -t output < <( "${cmd[@]}"; );
+    printf "%s\n" "${output[@]}";
+    #printf "Found %d matching lines for nouns.\n" "${#output[@]}" 1>&2; # debug
     # yell "STATUS:Finished find_nouns() on $fin"  # debug;
 }; # find nouns
 find_adjectives() {
     # yell "STATUS:Finished find_nouns() on $fin"  # debug;
 }; # find nouns
 find_adjectives() {
@@ -98,33 +108,46 @@ find_adjectives() {
     #         CONTEXT_ADJ  grep parameter
     # Output: stdout  lines matching grep patterns
 
     #         CONTEXT_ADJ  grep parameter
     # Output: stdout  lines matching grep patterns
 
-    local cmd+=('grep');    
+    local cmd+=('grep');
     cmd+=('--ignore-case');
     cmd+=('--ignore-case');
+    cmd+=('--extended-regexp');
     cmd+=('--context' "$CONTEXT_ADJ");
     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' \
-        -- \
-        - ;
+    cmd+=('-e' 'handsome');
+    cmd+=('-e' 'gorgeous');
+    cmd+=('-e' 'beautiful');
+    cmd+=('-e' 'bewitching');
+    cmd+=('-e' 'seductive');
+    cmd+=('-e' 'lusty');
+    cmd+=('-e' 'comely');
+    cmd+=('-e' 'stunning');
+    cmd+=('-e' 'elegant');
+    cmd+=('-e' 'exquisite');
+    cmd+=('-e' 'luxurious');
+    cmd+=('-e' 'ravishing');
+    cmd+=('-e' 'magnificent');
+    cmd+=('-e' 'glistening');
+    cmd+=('-e' 'lovely');
+    cmd+=('-e' 'loving');
+    cmd+=('-e' 'sexy|sexual|sexiest');
+    cmd+=('-e' 'sweet');
+    cmd+=('-e' 'sensual');
+    cmd+=('-e' 'arousing');
+    cmd+=('-e' 'warm');
+    cmd+=('-e' 'moist');
+    cmd+=('-e' 'soaked');
+    cmd+=('-e' 'hot');
+    cmd+=('-e' 'gentle');
+    cmd+=('-e' 'supple');
+    cmd+=('-e' 'tender');
+    cmd+=('-e' 'pleasurabl');
+    cmd+=('-e' 'buxom|busty|curvy');
+    cmd+=('-e' 'naked|nude');
+    cmd+=('--');
+    cmd+=('-');
+
+    local output; mapfile -t output < <( "${cmd[@]}"; );
+    printf "%s\n" "${output[@]}";
+    #printf "Found %d matching lines for adjectives.\n" "${#output[@]}" 1>&2; # debug
 }; # find adjectives
 find_verbs() {
     # Desc: Find verbs
 }; # find adjectives
 find_verbs() {
     # Desc: Find verbs
@@ -132,20 +155,32 @@ find_verbs() {
     # Input:  stdin         input lines
     #         CONTEXT_VERB  grep parameter
     # Output: stdout  lines matching grep patterns
     # 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' \
-        -- \
-        - ;    
+
+    local cmd+=('grep');
+    cmd+=('--ignore-case');
+    cmd+=('--extended-regexp');
+    cmd+=('--context' "$CONTEXT_VERB");
+    cmd+=('-e' 'love');
+    cmd+=('-e' 'nuzzle');
+    cmd+=('-e' 'pleasure');
+    cmd+=('-e' 'make love');
+    cmd+=('-e' 'fuck');
+    cmd+=('-e' 'arouse');
+    cmd+=('-e' 'quiver');
+    cmd+=('-e' 'tremble');
+    cmd+=('-e' 'caress');
+    cmd+=('-e' 'knead');
+    cmd+=('-e' 'kiss');
+    cmd+=('-e' 'moan');
+    cmd+=('-e' 'suck|suckle');
+    cmd+=('-e' 'fondle');
+    cmd+=('-e' 'grope');
+    cmd+=('-e' 'feel up|felt up|felt (me|her|him) up');
+    cmd+=('--');
+    cmd+=('-');
+    local output; mapfile -t output < <( "${cmd[@]}"; );
+    printf "%s\n" "${output[@]}";
+    #printf "Found %d matching lines for verbs.\n" "${#output[@]}" 1>&2; # debug
 }; # find verbs
 find_mix_1() {
     # Desc: Filter mix 1
 }; # find verbs
 find_mix_1() {
     # Desc: Filter mix 1
@@ -153,16 +188,19 @@ find_mix_1() {
     # Input:  stdin         input lines
     #         CONTEXT_VERB  grep parameter
     # Output: stdout  lines matching grep patterns
     # 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' \
-        -- \
-        - ;
+    local cmd+=('grep');
+    cmd+=('--ignore-case');
+    cmd+=('--context' "$CONTEXT_MIX_1");
+    cmd+=('-e' 'kiss');
+    cmd+=('-e' 'breast');
+    cmd+=('-e' 'tits');
+    cmd+=('-e' 'manhood');
+    cmd+=('-e' 'vagina');
+    cmd+=('-e' 'sex');
+    cmd+=('--');
+    cmd+=('-');
+    local output; mapfile -t output < <( "${cmd[@]}"; );
+    printf "%s\n" "${output[@]}";
 };
 find_mix_2() {
     # Desc: Filter mix 2
 };
 find_mix_2() {
     # Desc: Filter mix 2
@@ -170,50 +208,54 @@ find_mix_2() {
     # Input:  stdin         input lines
     #         CONTEXT_VERB  grep parameter
     # Output: stdout  lines matching grep patterns
     # 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' \
-        -- \
-        - ;
+
+    local cmd+=('grep');
+    cmd+=('--ignore-case');
+    cmd+=('--context' "$CONTEXT_MIX_2");
+    cmd+=('-e' 'nipple');
+    cmd+=('-e' 'womanhood');
+    cmd+=('-e' 'manhood');
+    cmd+=('-e' 'slit');
+    cmd+=('-e' 'pussy');
+    cmd+=('-e' 'vagina');
+    cmd+=('-e' 'cock');
+    cmd+=('-e' 'shaft');
+    cmd+=('-e' '\ lust');
+    cmd+=('-e' 'voyeur');
+    cmd+=('-e' 'ecstacy');
+    cmd+=('-e' 'tingle');
+    cmd+=('-e' 'orgasm');
+    cmd+=('-e' 'gorgeous');
+    cmd+=('-e' 'bewitching');
+    cmd+=('-e' 'seductive');
+    cmd+=('-e' 'lusty');
+    cmd+=('-e' 'stunning');
+    cmd+=('-e' 'ravishing');
+    cmd+=('-e' 'lovely');
+    cmd+=('-e' 'sexy');
+    cmd+=('-e' 'sweet');
+    cmd+=('-e' 'sexiest');
+    cmd+=('-e' 'sensual');
+    cmd+=('-e' 'arousing');
+    cmd+=('-e' 'moist');
+    cmd+=('-e' 'love');
+    cmd+=('-e' 'nuzzle');
+    cmd+=('-e' 'pleasure');
+    cmd+=('-e' 'make\ love');
+    cmd+=('-e' 'sex');
+    cmd+=('-e' 'fuck');
+    cmd+=('-e' 'arouse');
+    cmd+=('-e' 'kiss');
+    cmd+=('-e' 'breast');
+    cmd+=('-e' 'tits');
+    cmd+=('-e' 'manhood');
+    cmd+=('-e' 'vagina');
+    cmd+=('-e' 'lips');
+    cmd+=('-e' 'lovers');
+    cmd+=('--');
+    cmd+=('-');
+    local output; mapfile -t output < <( "${cmd[@]}"; );
+    printf "%s\n" "${output[@]}";
 };
 find_phrase () {
     # Desc: Filter phrase
 };
 find_phrase () {
     # Desc: Filter phrase
@@ -221,33 +263,31 @@ find_phrase () {
     # Input:  stdin         input lines
     #         CONTEXT_VERB  grep parameter
     # Output: stdout  lines matching grep patterns
     # 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)' \
-        -- \
-        - ;
+
+    local cmd+=('grep');
+    cmd+=('--ignore-case');
+    cmd+=('--context' "$CONTEXT_PHRASE");
+    cmd+=('--extended-regexp');
+    cmd+=('--color=always');
+    cmd+=('-e' '( his| her| my) [^\.|;]{,48}( his| her| my) (breast|pussy|tits|nipple|womanhood|cock( |\.|,)|manhood|dick|cunt)');
+    cmd+=('-e' '( his| her| my) [^\.|;]{,24}nipple.{,24}harden');
+    cmd+=('-e' '(suck|lick)[^\.|;]{,12} (nipple|cock( |\.|,)|dick)');
+    cmd+=('-e' '(slap)[^\.|;]{,12}( ass)');
+    cmd+=('-e' '( his| her| my) [^\.|;]{,12}(cunt|pussy( |\.|,)|cock( |\.|,)|dick|shaft( |\.|,|;))');
+    cmd+=('--');
+    cmd+=('-');
+    local output; mapfile -t output < <( "${cmd[@]}"; );
+    printf "%s\n" "${output[@]}";
+    #printf "Found %d matching lines for phrases in %s.\n" "${#output[@]}" "$fin" 1>&2; # debug
 }; # 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" | \
 }; # 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;
+        #parallel search_thread '{}' | less --RAW-CONTROL-CHARS -S;
+        parallel search_thread '{}';
 };
 export -f yell die must search_thread find_nouns find_adjectives find_verbs find_mix_1 find_mix_2 find_phrase;
 
 main "$@";
 };
 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;