# Routine to take missing.log entries and link to UGNT and ULB.KJV.Strongs use 5.12.0; use File::Slurp; $| = "\n"; use utf8; #use open IN => ":utf8", OUT => ":utf8"; use open IO => ":utf8"; binmode(STDOUT, ":utf8"); use File::Find ; use FindBin '$Bin'; use Cwd ; my ($pwd, $d, $textEditor, $repoPath, $browser) = ($Bin, "\\"); if ($^O eq "darwin" || $^O eq "linux") {$d = "/"} open LOG, ">:utf8", "Logs${d}mine_log.log" or die ("$!"); my ($udf) = "User_defaults.windows.txt"; if ($^O eq "linux") {$udf = "User_defaults.linux.txt"} elsif ($^O eq "darwin") {$udf = "User_defaults.mac.txt"} chdir $Bin; open (my $defaults, "<:utf8", "User${d}$udf") or die "User${d}$udf:\n$!"; GetUserDefaults(); my ($excFile, $topDir, $txtFile, $dataFile, $displayFile, $filePattern, $sn, $xfAbr, $thisULB) = ( "$Bin${d}Exceptions${d}Exceptions_tWs_from_OSHB.txt", "$repoPath${d}en_tw/bible", "$Bin${d}Temp${d}ULB_NASB_Strongs.txt", "$Bin${d}User${d}tW_work_NT.txt", "$Bin${d}Temp${d}mine_results.html", "*\.md" ); my ($missingLine, $bk, $ch, $vs, $ref, $strong, $word, $flag, $tNid, $abbr, $doFlag, $xmlFile, $outputFiles, $lbsBk, $url, $putative, $usfmFile); my (%bkAbr, %wa); my @tWfiles; find( sub { push @tWfiles, $File::Find::name if ( m/^(.*)$filePattern$/ ) }, $topDir) ; open OUT, ">:utf8", "$displayFile" or die; say OUT "
"; ParseLine(); FindURL(); FindVerse($ref); ChecktWPages($word); Finish(); say OUT " "; close OUT; close LOG; print "\n\tDone.\n\n"; sub GetUserDefaults { open (my $defaults, "<:utf8", "$Bin${d}User${d}$udf") or die "$Bin${d}User${d}$udf:\n$!"; while (my $thisLine = <$defaults>) { chomp $thisLine; if ($thisLine =~ /^Text editor: (.*)$/) { $textEditor = "\"$1\""; } elsif ($thisLine =~ /^Repository directory: (.*)$/) { $repoPath = $1 } elsif ($thisLine =~ /^HTML browser: (.*)$/) { $browser = "\"$1\""; } } say LOG "\$textEditor: $textEditor\n\$repoPath: $repoPath\n\$browser: $browser"; die "No text editor found" if $textEditor eq ""; die "No path to repo found" if $repoPath eq ""; if ($^O eq "darwin") {$textEditor = "open -a $textEditor"; $browser = "open -a $browser"} close $defaults; } sub ParseLine { my ($sch, $svs); if ($^O eq "linux" || $^O eq "darwin") { say "\nEnter line from Entries_not_handled.txt:\n"; $missingLine =$line
"; $strong = $1; my $test = $2; if ($test ne "0") {die "\n\t\tStrong's number won't work.\n\n"} unless ($strong =~ /^.+$/) {die "\nThe Strong's number <$strong> is not found.\n"} while ($strong =~ s/([GH])0/$1/) {} if ($strong =~ /^.+$/) { say OUT "$strong
\n"; last } } elsif ($line =~ /\\k-s[^\n]*$url/) { say OUT "$url is part of a phrase
\n"; $flag = 1; } } elsif ($line =~ /\\mt (.*)$/) { $doFlag = 0 } } close $file; } sub FindVerse { my $fileText = read_file("$txtFile", binmode => 'utf8'); say LOG "FindVerse |$strong|."; if ($flag && $fileText =~ /$ref\t[^\n]*\n[^\n]*\n/) { say LOG "$ref\n$&"; say $&; exit 0; } else { if ($fileText =~ /$ref([^\n]*\n )([^\n]*<)$strong(.?>[^\n]*)/) { my ($fore, $precon, $aft) = ($1, $2, $3); say LOG "\$ref: $ref\n\$fore: $fore\n\$precon:\n$precon\n\$aft: $aft"; my $preprecon; if ($precon =~ /^(.*([,>\w\'\"\- —;] |['";\.\?\!]))([\w\-]+) (<[^<>]*> )?<$/) { ($preprecon, $word) = ($1, $3); say LOG "\$&: $&\n\$preprecon: $preprecon\n\$word: $word"; } $preprecon =~ s/</g; $preprecon =~ s/>/>/g; $aft =~ s/</g; $aft =~ s/>/>/g; say OUT "$ref$fore
\n$preprecon$word <$strong$aft
\n"; } else { say OUT "The Strong's code <<$strong>> is not found in $ref.
"; say OUT "${ref}\\t[^\\n]*\\n[^\\n]*
"; #system ("bbfind -g \"${ref}\\t[^\\n]*\\n[^\\n]*\" 'data${d}ULB_NASB_Strongs.txt'") or die "$!"; if ($^O eq "darwin") {system ("find $topDir -name \"*.md\" -exec grep -H --color \"$strong\[, \\n\\r\]\" {} \\;")} #system ("find $topDir -name \"*.md\" -exec grep -H --color \"$strong\$\" {} \\;"); } } return $word; } sub ChecktWPages{ say LOG "<<$word>>"; die "\n\$word is empty.\n" if $word eq ""; my $topDir = "$repoPath${d}en_tw${d}bible"; foreach my $file ( @tWfiles ) { my $fileText = read_file("$file", binmode => 'utf8'); # While finds entries and Strong's numbers while ($fileText =~ /($strong)[^\d]|^(# [^\n]*\b$word\b)/g) { #system `clear`; my $abb = $file; $abb =~ s/.md$//; say OUT "$abb
\n"; $outputFiles .= "$file " } } } sub Finish { say "\nLooking for $strong."; # find $topDir -name "*.md" -exec grep -H '($strong[^\d]|$strong$)' {} + #system ("find $topDir -name \"*.md\" -exec grep -H --color \"$strong\[, \\n\\r\]\" {} \\;"); foreach my $file ( @tWfiles ) { my $fileText = read_file("$file", binmode => 'utf8'); # While finds entries and Strong's numbers if ($fileText =~ /([^\n]*)($strong)([^\n]*)/g) { my ($pre, $found, $post) = ($1, $2, $3); my $abb = $file; $abb =~ s/.md$//; say OUT "$abb: $pre$found$post
\n"; $outputFiles .= "$file " } } say "\nLooking for $putative."; foreach my $file ( @tWfiles ) { my $fileText = read_file("$file", binmode => 'utf8'); # While finds entries and Strong's numbers if ($fileText =~ /#{1,1} ([^\n]*)(\b$putative\b)([^\n]*)/g) { my ($pre, $found, $post) = ($1, $2, $3); my $abb = $file; $abb =~ s/.md$//; say OUT "$abb: $pre$found$post
\n"; $outputFiles .= "$file " } } say "\nLooking for $word."; foreach my $file ( @tWfiles ) { my $fileText = read_file("$file", binmode => 'utf8'); # While finds entries and Strong's numbers if ($fileText =~ /#{1,1} ([^\n]*)(\b$word\b)([^\n]*)/g) { my ($pre, $found, $post) = ($1, $2, $3); my $abb = $file; $abb =~ s/.md$//; say OUT "$abb: $pre$found$post
\n"; $outputFiles .= "$file " } } say "Opening .md files."; if ($^O eq "darwin") { system `$browser https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=$strong`; system `$textEditor $outputFiles`; system `$textEditor $excFile`;} if ($^O eq "linux") { system `$browser https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=$strong &`; system `$textEditor $outputFiles &`; system `$textEditor $excFile &`;} if ($^O eq "MSWin32" || $^O eq "MSWin64" ) { system `START "" $browser https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=$strong`; system `START "" $textEditor $outputFiles`; system `START "" $textEditor $excFile`; system `START "" $browser $displayFile`;} }