Deleted old foul versions.
This commit is contained in:
parent
91435e9ef5
commit
e0c85a468b
|
@ -1,276 +0,0 @@
|
|||
# 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";
|
||||
use File::Find ;
|
||||
use Cwd ;
|
||||
|
||||
my ($pwd, $d, $textEditor, $repoPath, $browser) = (cwd(), "\\");
|
||||
if ($^O eq "darwin" || $^O eq "linux") {$d = "/"}
|
||||
|
||||
my ($udf) = "User_defaults.windows.txt";
|
||||
if ($^O eq "linux") {$udf = "User_defaults.linux.txt"}
|
||||
elsif ($^O eq "darwin") {$udf = "User_defaults.mac.txt"}
|
||||
|
||||
open (my $defaults, "<:utf8", "User${d}$udf") or die "User${d}$udf:\n$!";
|
||||
|
||||
GetUserDefaults();
|
||||
|
||||
my ($outputFiles, $topDir, $txtFile, $dataFile, $displayFile, $filePattern) = (
|
||||
"$repoPath${d}en_tw/bible${d}",
|
||||
"$repoPath${d}en_tw/bible",
|
||||
"Temp${d}ULB_NASB_Strongs.txt",
|
||||
"User${d}tW_work_NT.txt",
|
||||
"Temp${d}mine_results.html",
|
||||
"*\.md"
|
||||
);
|
||||
|
||||
my ($missingLine, $bk, $ch, $vs, $ref, $url, $strong, $word, $flag, $putative, $tNid, $abbr, $doFlag, $usfmFile, $lbsBk);
|
||||
my @tWfiles;
|
||||
|
||||
find( sub { push @tWfiles, $File::Find::name if ( m/^(.*)$filePattern$/ ) }, $topDir) ;
|
||||
|
||||
open LOG, ">:utf8", "Logs${d}mine.log.log" or die;
|
||||
open OUT, ">:utf8", "$displayFile" or die;
|
||||
|
||||
say OUT "<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=\"UTF-8\"/>
|
||||
</head>
|
||||
<body>
|
||||
";
|
||||
|
||||
ParseLine();
|
||||
FindURL();
|
||||
FindVerse($ref);
|
||||
ChecktWPages($word);
|
||||
Finish();
|
||||
|
||||
say OUT "
|
||||
</body>
|
||||
</html>";
|
||||
close OUT;
|
||||
close LOG;
|
||||
print "\n\tDone.\n\n";
|
||||
|
||||
sub GetUserDefaults {
|
||||
open (my $defaults, "<:utf8", "User${d}$udf") or die "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, \$repoPath: $repoPath";
|
||||
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 {
|
||||
say "\n\n\033[0;1;31mEnter line from Entries_not_handled.txt:\033[m\n";
|
||||
$missingLine = <STDIN>; # I moved chomp to a new line to make it more readable
|
||||
chomp $missingLine; # Get rid of newline character at the end
|
||||
exit 0 if ($missingLine eq ""); # If empty string, exit.
|
||||
#$missingLine = "Mark 11:6 kt/command";
|
||||
if ($missingLine =~ /^(([^:]*) (\d+):(\d+))\t([^\/]*\/([^\t]*))/) {
|
||||
($ref, $bk, $ch, $vs, $url, $putative) = ($1, $2, $3, $4, $5, $6);
|
||||
$outputFiles .= "${url}.md ";
|
||||
say LOG "\$bk: $bk";
|
||||
open (my $file, "<:utf8", "$dataFile") or die "$dataFile:\n$!";
|
||||
|
||||
while (my $line = <$file>) {
|
||||
chomp $line;
|
||||
if ($line =~ /^(# )?([^\t]*)\t([^\t]*)\t([^\t]*)$/) {
|
||||
my ($fullBk, $numBk, $abr) = ($2, $3, $4);
|
||||
say LOG "\$fullBk: |$fullBk|, \$numBk: $numBk, \$abr: $abr, \$bk: |$bk|";
|
||||
if ($fullBk eq $bk) {
|
||||
say LOG "\$fullBk: |$fullBk|, \$bk: |$bk|";
|
||||
$lbsBk = $abr;
|
||||
if ($numBk =~ /(\d\d)-(...)/) {
|
||||
$abbr = lc $2;
|
||||
say LOG "\$abbr: $abbr";
|
||||
if ($^O eq "darwin") {system `open -a /Applications/Logos.app "logos4:TextComparison;ref=BibleESV.$lbsBk${ch}.$vs;res=esv,niv2011,niv,nasb95,nrsv,gs-netbible,nlt,leb,kjv1900"`}
|
||||
my $mxl;
|
||||
if ($bk eq "Psalms?") {$mxl = 3}
|
||||
else {$mxl = 2}
|
||||
while (length $ch < $mxl) {$ch =~ s/^/0/}
|
||||
while (length $vs < $mxl) {$vs =~ s/^/0/}
|
||||
}
|
||||
$usfmFile = "$repoPath${d}UGNT${d}${numBk}.usfm";
|
||||
say LOG "\$abbr${d}\$ch${d}\$vs: $abbr${d}$ch${d}$vs";
|
||||
if ($^O eq "darwin") {system `$textEditor $repoPath${d}en_tn${d}$abbr${d}$ch${d}$vs.md`}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close $file;
|
||||
|
||||
} else {
|
||||
die "\n\tInput unreadable.\n"
|
||||
}
|
||||
say LOG "Looking for $putative in $usfmFile";
|
||||
say LOG "\$missingLine: $missingLine, \$ref: $ref, \$bk: $bk, \$ch: $ch, \$vs: $vs, \$url: $url\n\n";
|
||||
}
|
||||
sub FindURL {
|
||||
|
||||
my ($thisChap, $thisVers);
|
||||
|
||||
open (my $file, "<:utf8", "$usfmFile") or die "$usfmFile:\n$!";
|
||||
|
||||
while (my $line = <$file>) {
|
||||
chomp $line;
|
||||
if ($line =~ /\\mt (.*)$/) {
|
||||
my $thisBook = $1;
|
||||
if ($thisBook eq $bk) {
|
||||
say LOG "\$thisBook: $thisBook\t\$bk: $bk";
|
||||
$doFlag = 1;
|
||||
} else {
|
||||
say LOG "\nThe wrong book is being searched.\n"
|
||||
}
|
||||
} elsif ($doFlag && $line =~ /^\\c (\d+)$/) {
|
||||
$thisChap = $1
|
||||
} elsif ($doFlag && $line =~ /^\\v (\d+)$/) {
|
||||
$thisVers = $1
|
||||
} elsif ($doFlag && $thisChap == $ch && $thisVers == $vs) {
|
||||
say LOG "\$thisChap:\$thisVers: $thisChap:$thisVers \$line: $line";
|
||||
if ($line =~ /strong="([GH]....)(.).*$url/) {
|
||||
say OUT "<p>$line</p>";
|
||||
$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 "<p><span style=\"color:red\">$strong</span></p>\n";
|
||||
last
|
||||
}
|
||||
} elsif ($line =~ /\\k-s[^\n]*$url/) {
|
||||
say OUT "<p><span style=\"color:red\">$url</span> is part of a phrase</p>\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 "<p>$ref$fore</p>\n<p>$preprecon<span style=\"color:red\">$word</span> <<span style=\"color:red\">$strong</span>$aft</p>\n";
|
||||
}
|
||||
else {
|
||||
say OUT "<p>The Strong's code <<<span style=\"color:red\">$strong</span>>> is not found in $ref.</p>";
|
||||
say OUT "<p>${ref}\\t[^\\n]*\\n[^\\n]*</p>";
|
||||
#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 "<p>$abb</p>\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 "<p>$abb: $pre<span style=\"color:red\">$found</span>$post</p>\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 "<p>$abb: $pre<span style=\"color:red\">$found</span>$post</p>\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 "<p>$abb: $pre<span style=\"color:red\">$found</span>$post</p>\n";
|
||||
$outputFiles .= "$file "
|
||||
}
|
||||
}
|
||||
say "Opening .md files.";
|
||||
if ($^O eq "darwin") {system `$browser https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=$strong`}
|
||||
say "\$browser: $browser, \$displayFile: $displayFile, \$textEditor: $textEditor \$outputFiles: $outputFiles";
|
||||
if ($^O eq "darwin") {system `$browser $displayFile`}
|
||||
if ($^O eq "darwin") {system `$textEditor $outputFiles`}
|
||||
}
|
|
@ -1,228 +0,0 @@
|
|||
# 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";
|
||||
use File::Find ;
|
||||
use Cwd ;
|
||||
|
||||
my ($pwd, $^O, $d, $textEditor, $repoPath) = (cwd(), $^O, "\\");
|
||||
if ($^O eq "darwin" || $^O eq "linux") {$d = "/"}
|
||||
|
||||
open OUT, ">:utf8", "Temp${d}mine_results.html" or die;
|
||||
#binmode(STDOUT, "encoding(UTF-8)");
|
||||
|
||||
GetUserDefaults();
|
||||
|
||||
my ($outputFiles, $topDir, $usfmFile, $txtFile, $lbsBk, $dataFile, $doFlag) = (
|
||||
"$repoPath${d}en_tw/bible${d}",
|
||||
"$repoPath${d}en_tw/bible",
|
||||
"",
|
||||
"Temp${d}ULB.NASB.Strongs.txt",
|
||||
"",
|
||||
"User${d}tW_work_NT.txt"
|
||||
);
|
||||
|
||||
my ($missingLine, $bk, $ch, $vs, $ref, $url, $strong, $word, $flag, $putative, $tNid, $abbr);
|
||||
|
||||
open LOG, ">:utf8", "Logs${d}mine.log.log" or die;
|
||||
#open OUT, ">:utf8", $outputFile or die;
|
||||
|
||||
ParseLine();
|
||||
FindURL();
|
||||
FindVerse($ref);
|
||||
ChecktWPages($word);
|
||||
Finish();
|
||||
#close OUT;
|
||||
close LOG;
|
||||
|
||||
print "\n\tDone.\n\n";
|
||||
|
||||
sub GetUserDefaults {
|
||||
open (my $defaults, "<:utf8", "data${d}UserDefaults") or die "data${d}UserDefaults:\n$!";
|
||||
|
||||
while (my $thisLine = <$defaults>) {
|
||||
chomp $thisLine;
|
||||
if ($thisLine =~ /^Text editor: (.*)$/) {
|
||||
$textEditor = $1;
|
||||
} elsif ($thisLine =~ /^Repository directory: (.*)$/) {
|
||||
$repoPath = $1
|
||||
}
|
||||
}
|
||||
|
||||
say LOG "\$textEditor: $textEditor, \$repoPath: $repoPath";
|
||||
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"}
|
||||
|
||||
close $defaults;
|
||||
}
|
||||
|
||||
sub ParseLine {
|
||||
say OUT "\n\n\033[0;1;31mEnter line from missing.log:\033[m\n";
|
||||
$missingLine = <STDIN>; # I moved chomp to a new line to make it more readable
|
||||
chomp $missingLine; # Get rid of newline character at the end
|
||||
exit 0 if ($missingLine eq ""); # If empty string, exit.
|
||||
#$missingLine = "Mark 11:6 kt/command";
|
||||
if ($missingLine =~ /^(([^:]*) (\d+):(\d+))\t([^\/]*\/([^\t]*))/) {
|
||||
($ref, $bk, $ch, $vs, $url, $putative) = ($1, $2, $3, $4, $5, $6);
|
||||
$outputFiles .= "${url}.md ";
|
||||
say LOG "\$bk: $bk";
|
||||
open (my $file, "<:utf8", "$dataFile") or die "$dataFile:\n$!";
|
||||
|
||||
while (my $line = <$file>) {
|
||||
chomp $line;
|
||||
if ($line =~ /^(# )?([^\t]*)\t([^\t]*)\t([^\t]*)$/) {
|
||||
my ($fullBk, $numBk, $abr) = ($2, $3, $4);
|
||||
say LOG "\$fullBk: |$fullBk|, \$numBk: $numBk, \$abr: $abr, \$bk: |$bk|";
|
||||
if ($fullBk eq $bk) {
|
||||
say LOG "\$fullBk: |$fullBk|, \$bk: |$bk|";
|
||||
$lbsBk = $abr;
|
||||
if ($numBk =~ /(\d\d)-(...)/) {
|
||||
$abbr = lc $2;
|
||||
say LOG "\$abbr: $abbr";
|
||||
my $mxl;
|
||||
if ($bk eq "Psalms?") {$mxl = 3}
|
||||
else {$mxl = 2}
|
||||
while (length $ch < $mxl) {$ch =~ s/^/0/}
|
||||
while (length $vs < $mxl) {$vs =~ s/^/0/}
|
||||
}
|
||||
$usfmFile = "$repoPath${d}UGNT${d}${numBk}.usfm";
|
||||
say LOG "\$abbr${d}\$ch${d}\$vs: $abbr${d}$ch${d}$vs";
|
||||
if ($^O eq "darwin") {system `$textEditor $repoPath${d}en_tn${d}$abbr${d}$ch${d}$vs.md`}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close $file;
|
||||
|
||||
} else {
|
||||
die "\n\tInput unreadable.\n"
|
||||
}
|
||||
say LOG "Looking for $putative in $usfmFile";
|
||||
say LOG "\$missingLine: $missingLine, \$ref: $ref, \$bk: $bk, \$ch: $ch, \$vs: $vs, \$url: $url\n\n";
|
||||
#system `open -a /Applications/Logos.app "logosres:esv;ref=BibleESV.$lbsBk${ch}.$vs"`;
|
||||
if ($^O eq "darwin") {system `open -a /Applications/Logos.app "logos4:TextComparison;ref=BibleESV.$lbsBk${ch}.$vs;res=esv,niv2011,niv,nasb95,nrsv,gs-netbible,nlt,leb,kjv1900"}
|
||||
`;
|
||||
}
|
||||
sub FindURL {
|
||||
|
||||
my ($thisChap, $thisVers);
|
||||
|
||||
open (my $file, "<:utf8", "$usfmFile") or die "$usfmFile:\n$!";
|
||||
|
||||
while (my $line = <$file>) {
|
||||
chomp $line;
|
||||
if ($line =~ /\\mt (.*)$/) {
|
||||
my $thisBook = $1;
|
||||
if ($thisBook eq $bk) {
|
||||
say LOG "\$thisBook: $thisBook\t\$bk: $bk";
|
||||
$doFlag = 1;
|
||||
} else {
|
||||
say LOG "\nThe wrong book is being searched.\n"
|
||||
}
|
||||
} elsif ($doFlag && $line =~ /^\\c (\d+)$/) {
|
||||
$thisChap = $1
|
||||
} elsif ($doFlag && $line =~ /^\\v (\d+)$/) {
|
||||
$thisVers = $1
|
||||
} elsif ($doFlag && $thisChap == $ch && $thisVers == $vs) {
|
||||
say LOG "$thisChap:$thisVers $line";
|
||||
if ($line =~ /strong="([GH]....)(.).*$url/) {
|
||||
say OUT "\n\$line:\n$line\n";
|
||||
$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 "\033[0;1;31m$strong\033[m\n";
|
||||
last
|
||||
}
|
||||
} elsif ($line =~ /\\k-s[^\n]*$url/) {
|
||||
say OUT "\n\t$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";
|
||||
}
|
||||
say "$ref$fore$preprecon\033[0;0;32m$word\033[m <\033[0;1;31m$strong\033[m$aft\n";
|
||||
}
|
||||
else {
|
||||
say "\n\nThe Strong's code <<$strong>> is not found in $ref.\n\n";
|
||||
if ($^O eq "darwin") {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\]\" {} \\;")}
|
||||
}
|
||||
}
|
||||
return $word;
|
||||
}
|
||||
|
||||
sub ChecktWPages{
|
||||
|
||||
say LOG "<<$word>>";
|
||||
die "\n\$word is empty.\n" if $word eq "";
|
||||
my $topDir = "$repoPath${d}en_tw${d}bible";
|
||||
|
||||
my @filesToRun = ();
|
||||
my $filePattern = '*.md' ;
|
||||
find( sub { push @filesToRun, $File::Find::name if ( m/^(.*)$filePattern$/ ) }, $topDir) ;
|
||||
|
||||
foreach my $file ( @filesToRun ) {
|
||||
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 "\033[0;1;31m$abb\033[m";
|
||||
$outputFiles .= "$file "
|
||||
}
|
||||
}
|
||||
}
|
||||
sub Finish {
|
||||
say "\nLooking for $strong.";
|
||||
# find $topDir -name "*.md" -exec grep -H '($strong[^\d]|$strong$)' {} +
|
||||
if ($^O eq "darwin") {system ("find $topDir -name \"*.md\" -exec grep -H --color \"$strong\[, \\n\\r\]\" {} \\;")}
|
||||
if ($^O eq "darwin") {system ("find $topDir -name \"*.md\" -exec grep -H --color \"$strong\$\" {} \\;")}
|
||||
#system ("find $topDir -name \"*.md\" -exec grep -H --color \"\($strong\[, \\n\\r\]\|$strong\$\)\" {} \\;");
|
||||
say "\nLooking for $putative.";
|
||||
#system ("find $topDir -name \"*.md\" -exec grep -Hi --color \"^# $putative\[^A-Za-z\]\" {} \\;");
|
||||
#system ("find $topDir -name \"*.md\" -exec grep -Hi --color \"^# .*\[^A-Za-z\]$putative\[^A-Za-z\]\" {} \\;");
|
||||
if ($^O eq "darwin") {system ("find $topDir -name \"*.md\" -exec egrep -Hi --color \"^# (.*\[^A-Za-z\])?$putative\[^A-Za-z\]\" {} \\;")}
|
||||
say "\nLooking for $word.";
|
||||
#system ("find $topDir -name \"*.md\" -exec grep -Hi --color \"^#$word\[^A-Za-z\]\" {} \\;");
|
||||
#system ("find $topDir -name \"*.md\" -exec grep -Hi --color \"^# .*\[^A-Za-z\]$word\[^A-Za-z\]\" {} \\;");
|
||||
if ($^O eq "darwin") {system ("find $topDir -name \"*.md\" -exec egrep -Hi --color \"^# (.*\[^A-Za-z\])?$word\[^A-Za-z\]\" {} \\;")};
|
||||
say "Opening .md files.";
|
||||
if ($^O eq "darwin") {system `open -a /Applications/Firefox.app https://www.blueletterbible.org/lang/lexicon/lexicon.cfm?strongs=$strong`}
|
||||
if ($^O eq "darwin") {system `open -a /Applications/BBEdit.app $outputFiles`}
|
||||
}
|
|
@ -1,166 +0,0 @@
|
|||
# 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";
|
||||
use File::Find ;
|
||||
use Cwd ;
|
||||
|
||||
binmode(STDOUT, "encoding(UTF-8)");
|
||||
|
||||
|
||||
my ($outputFiles, $topDir, $xmlFile, $txtFile, $lbsBk, $dataFile, $xmlDir, $doFlag) = (
|
||||
"/Users/Henry/Documents/git.Door43/en_tw/bible/",
|
||||
"/Users/Henry/Documents/git.Door43/en_tw/bible",
|
||||
"",
|
||||
"/Users/Henry/Google Drive/WA/Test/data/ULB.NASB.Strongs.txt",
|
||||
"",
|
||||
"/Users/Henry/Google Drive/WA/Test/data/tW.work.OT.dat",
|
||||
"/Users/Henry/Google Drive/WA/OSHB"
|
||||
);
|
||||
|
||||
my ($missingLine, $bk, $ch, $vs, $ref, $sn, $strong, $word, $flag, $tNid, $abbr, $xfAbr);
|
||||
my (%bkAbr, %bkFull, %wa);
|
||||
|
||||
open LOG, ">:utf8", "/Users/Henry/Google Drive/WA/Test/out/mine.log.log" or die;
|
||||
#open OUT, ">:utf8", $outputFile or die;
|
||||
|
||||
while (<DATA>) {
|
||||
chomp;
|
||||
if (/([^\t]*)\t([^\t]*)\t([^\t]*)/) {
|
||||
$bkAbr{$1} = $2;
|
||||
$bkFull{$2} = $1;
|
||||
$wa{$1} = $3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ParseLine();
|
||||
#FindURL();
|
||||
FindVerse($ref);
|
||||
#ChecktWPages($word);
|
||||
#Finish();
|
||||
#close OUT;
|
||||
close LOG;
|
||||
|
||||
print "\n\tDone.\n\n";
|
||||
|
||||
sub ParseLine {
|
||||
say "\n\n\033[0;1;31mEnter line from missing.log:\033[m\n";
|
||||
$missingLine = <STDIN>; # I moved chomp to a new line to make it more readable
|
||||
chomp $missingLine; # Get rid of newline character at the end
|
||||
exit 0 if ($missingLine eq ""); # If empty string, exit.
|
||||
#$missingLine = "Mark 11:6 kt/command";
|
||||
if ($missingLine =~ /^(([^:]*) (\d+):(\d+))\t(\d+)/) {
|
||||
($ref, $bk, $ch, $vs, $sn, $xfAbr) = ($1, $2, $3, $4, $5, $bkAbr{$1});
|
||||
say LOG "\$bk: $bk";
|
||||
open (my $file, "<:utf8", "$dataFile") or die "$dataFile:\n$!";
|
||||
|
||||
while (my $line = <$file>) {
|
||||
chomp $line;
|
||||
if ($line =~ /^(# )?([^\t]*)\t([^\t]*)\t([^\t]*)$/) {
|
||||
my ($fullBk, $numBk, $abr) = ($2, $3, $4);
|
||||
say LOG "\$fullBk: |$fullBk|, \$numBk: $numBk, \$abr: $abr, \$bk: |$bk|";
|
||||
if ($fullBk eq $bk) {
|
||||
say LOG "\$fullBk: |$fullBk|, \$bk: |$bk|";
|
||||
$lbsBk = $abr;
|
||||
$abbr = lc $numBk;
|
||||
say LOG "\$abbr: $abbr";
|
||||
my $mxl;
|
||||
if ($bk eq "Psalms?") {$mxl = 3}
|
||||
else {$mxl = 2}
|
||||
while (length $ch < $mxl) {$ch =~ s/^/0/}
|
||||
while (length $vs < $mxl) {$vs =~ s/^/0/}
|
||||
$xmlFile = "/Users/Henry/Google Drive/WA/OSHB/${numBk}.xml";
|
||||
say LOG "\$abbr/\$ch/\$vs: $abbr/$ch/$vs";
|
||||
if ($^O eq "darwin") {system `open -a /Applications/BBEdit.app /Users/Henry/Documents/git.Door43/en_tn/$wa{$fullBk}/$ch/$vs.md`}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close $file;
|
||||
|
||||
} else {
|
||||
die "\n\tInput unreadable.\n"
|
||||
}
|
||||
#say LOG "Looking for $sn in $xmlFile";
|
||||
#say "Looking to open \$lbsBk\${ch}.\$vs: $lbsBk${ch}.$vs";
|
||||
# say LOG "\$missingLine: $missingLine, \$ref: $ref, \$bk: $bk, \$ch: $ch, \$vs: $vs, \$url: $url\n\n";
|
||||
#system `open -a /Applications/Logos.app "logosres:esv;ref=BibleESV.$lbsBk${ch}.$vs"`;
|
||||
if ($^O eq "darwin") {system `open -a /Applications/Logos.app "logos4:TextComparison;ref=BibleESV.$lbsBk${ch}.$vs;res=esv,niv2011,niv,nasb95,nrsv,gs-netbible,nlt,leb,kjv1900"`}
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
say "$ref$fore$preprecon\033[0;0;32m$word\033[m <\033[0;1;31m$strong\033[m$aft\n";
|
||||
}
|
||||
else {
|
||||
say "\n\nThe Strong's code <<$strong>> is not found in $ref.\n\n";
|
||||
if ($^O eq "darwin") {system ("bbfind -g \"${ref}\\t[^\\n]*\\n[^\\n]*\" '/Users/Henry/Google Drive/WA/Test/data/ULB.NASB.Strongs.txt'") or die "$!"}
|
||||
system ("find $topDir -name \"*.md\" -exec grep -H --color \"$strong\[, \\n\\r\]\" {} \\;");
|
||||
#system ("find $topDir -name \"*.md\" -exec grep -H --color \"$strong\$\" {} \\;");
|
||||
}
|
||||
}
|
||||
return $word;
|
||||
}
|
||||
|
||||
__DATA__
|
||||
1 Chronicles 1Chr 1ch
|
||||
1 Kings 1Kgs 1ki
|
||||
1 Samuel 1Sam 1sa
|
||||
2 Chronicles 2Chr 2ch
|
||||
2 Kings 2Kgs 2ki
|
||||
2 Samuel 2Sam 2sa
|
||||
Amos Amos amo
|
||||
Daniel Dan dan
|
||||
Deuteronomy Deut deu
|
||||
Ecclesiastes Eccl ecc
|
||||
Esther Esth est
|
||||
Exodus Exod exo
|
||||
Ezekiel Ezek ezk
|
||||
Ezra Ezra ezr
|
||||
Genesis Gen gen
|
||||
Habakkuk Hab hab
|
||||
Haggai Hag hag
|
||||
Hosea Hos hos
|
||||
Isaiah Isa isa
|
||||
Jeremiah Jer jer
|
||||
Job Job job
|
||||
Joel Joel jol
|
||||
Jonah Jonah jon
|
||||
Joshua Josh jos
|
||||
Judges Judg jdg
|
||||
Lamentations Lam lam
|
||||
Leviticus Lev lev
|
||||
Malachi Mal mal
|
||||
Micah Mic mic
|
||||
Nahum Nah nam
|
||||
Nehemiah Neh neh
|
||||
Numbers Num num
|
||||
Obadiah Obad oba
|
||||
Proverbs Prov pro
|
||||
Psalms Ps psa
|
||||
Ruth Ruth rut
|
||||
Song of Songs Song sng
|
||||
Zechariah Zech zec
|
||||
Zephaniah Zeph zep
|
|
@ -1,579 +0,0 @@
|
|||
# Produces list of tWs for each verse by linking OSHB to ULB through tWs.
|
||||
|
||||
# Taken from tWs.from.UGNT.7.pl, with changes needed because that used USFM
|
||||
# and this uses XML
|
||||
|
||||
# The output from this script is useful for the interleaved PDFs used in MAST.
|
||||
# This version uses an exception file to handle places where the OSHB points to
|
||||
# a tW page different from that on which the ULB term appears.
|
||||
|
||||
# Make sure the correct input file is $ULBfile. Run script.
|
||||
# Output is in $output file.
|
||||
# Check the $missing
|
||||
# file for needed corrections, probably lines needing to be added to the
|
||||
# $exceptions file.
|
||||
|
||||
|
||||
|
||||
use 5.12.0;
|
||||
use File::Slurp;
|
||||
use File::Find ;
|
||||
use Cwd ;
|
||||
use FindBin '$Bin';
|
||||
use utf8;
|
||||
#use open IN => ":utf8", OUT => ":utf8";
|
||||
use open IO => ":utf8";
|
||||
use List::MoreUtils qw(uniq);
|
||||
|
||||
my ($pwd, $d) = ($Bin, "/");
|
||||
if ($^O eq "MSWin32") {
|
||||
$d = "\\";
|
||||
$pwd =~ s/\//\\/g;
|
||||
}
|
||||
|
||||
my ($udf) = "User_defaults.windows.txt";
|
||||
if ($^O eq "linux") {$udf = "User_defaults.linux.txt"}
|
||||
elsif ($^O eq "darwin") {$udf = "User_defaults.mac.txt"}
|
||||
|
||||
open (my $defaults, "<:utf8", "$pwd${d}User${d}$udf") or die "$pwd${d}User${d}$udf:\n$!";
|
||||
|
||||
my ($cv, $ULBfile, $exceptions, $missing, $log, $output, $workFile, $verseMap) =
|
||||
("00000",
|
||||
"Temp${d}Extract.txt",
|
||||
"Exceptions${d}Exceptions_tWs_from_OSHB.txt",
|
||||
"Output${d}Entries_not_handled.txt",
|
||||
"Logs${d}log.log",
|
||||
"Output${d}tWs_for_PDF.txt",
|
||||
"User${d}tW_work_OT.txt",
|
||||
"OSHB${d}VerseMap.xml",
|
||||
);
|
||||
|
||||
my ($OSHBfile, $topTwDir, $textEditor, $repoPath, $topSourceLangDir);
|
||||
|
||||
my (%entries, %text, %ref, %order, %pages, %listOfPages, %sourcePage, %checkPages, %foundPages, %substitutedPages,
|
||||
%specifiedText, %realPage, %checkPage, %workEntries, %vsn, %StrongNum, %fullText, %ulbOrder, %bkAbr, %bkFull, %relevantSNs,
|
||||
%SNsInCV, %entriesThisSN, %entriesThisPage, %pagesThisSN, %pageThisEntry, %adjust, %newRef);
|
||||
|
||||
my $book;
|
||||
my (@OSHBfileList);
|
||||
|
||||
# ==============================
|
||||
|
||||
chdir("$pwd");
|
||||
open LOG, ">:utf8", "$log" or die "\$log: $log: $!";
|
||||
open OUT, ">:utf8", $output or die "$!";
|
||||
open MISSING, ">$missing" or die "$!";
|
||||
|
||||
|
||||
while (<DATA>) {
|
||||
chomp;
|
||||
if (/([^\t]*)\t([^\t]*)/) {
|
||||
$bkAbr{$2} = $1;
|
||||
$bkFull{$1} = $2;
|
||||
}
|
||||
}
|
||||
|
||||
GetUserDefaults();
|
||||
GetULBBooksToProcess();
|
||||
CheckForRemaps();
|
||||
ReadExceptions();
|
||||
PairtWEntriesTotWPageAndUniqSNs();
|
||||
ReadLinkedSNs();
|
||||
LinkULBtoCV();
|
||||
LinkSNsToULBtextViaEntries();
|
||||
#Output();
|
||||
|
||||
close MISSING;
|
||||
close OUT;
|
||||
close LOG;
|
||||
|
||||
if ($^O eq "darwin") {system ("$textEditor $missing")}
|
||||
|
||||
print "\n\tDone.\n\n";
|
||||
|
||||
# ==============================
|
||||
|
||||
sub GetUserDefaults {
|
||||
open (my $defaults, "<:utf8", "User${d}$udf") or die "User${d}$udf:\n$!";
|
||||
|
||||
while (my $thisLine = <$defaults>) {
|
||||
chomp $thisLine;
|
||||
if ($thisLine =~ /^Text editor: (.*)$/) {
|
||||
$textEditor = $1;
|
||||
if ($^O eq "darwin") {
|
||||
$textEditor = "open -a $textEditor"
|
||||
}
|
||||
} elsif ($thisLine =~ /^Repository directory: (.*)$/) {
|
||||
$repoPath = $1;
|
||||
#say $repoPath; die;
|
||||
}
|
||||
}
|
||||
|
||||
say LOG "\$textEditor: $textEditor\n\$repoPath: $repoPath";
|
||||
die "No text editor found" if $textEditor eq "";
|
||||
die "No path to repo found" if $repoPath eq "";
|
||||
|
||||
($topTwDir, $topSourceLangDir) = ("$repoPath${d}en_tw${d}bible", "$repoPath${d}OSHB");
|
||||
|
||||
close $defaults;
|
||||
}
|
||||
|
||||
sub GetULBBooksToProcess {
|
||||
say LOG "GetULBBooksToProcess";
|
||||
open (my $file, "<:utf8", "$workFile") or die "$workFile:\n$!";
|
||||
|
||||
while (my $line = <$file>) {
|
||||
chomp $line;
|
||||
say LOG $line;
|
||||
if ($line =~ /^[^#][^\t]*\t[^\t]*\t([^\t]*)\t[^\t]*$/) {
|
||||
$OSHBfile = "$topSourceLangDir${d}$1.xml";
|
||||
push @OSHBfileList, $OSHBfile;
|
||||
}
|
||||
}
|
||||
|
||||
close $file;
|
||||
say LOG "\@OSHBfileList: @OSHBfileList"
|
||||
}
|
||||
|
||||
sub CheckForRemaps {
|
||||
say "Checking for remaps in $repoPath${d}$verseMap";
|
||||
#/media/henry/92C6F7E3C6F7C58F/Users/henry/Documents/WA_Repo/OSHB/VerseMap.xml:
|
||||
#/media/henry/92C6F7E3C6F7C58F/Users/henry/WA_Repo/OSHB/VerseMap.xml
|
||||
open (my $file, "<:utf8", "$repoPath${d}$verseMap") or die "$repoPath${d}$verseMap:\n$!";
|
||||
|
||||
while (my $thisLine = <$file>) {
|
||||
chomp $thisLine;
|
||||
#say LOG $thisLine;
|
||||
if ($thisLine =~ /<verse wlc="([^\.]*)\.(\d+)\.(\d+)" kjv="([^\.]*)\.(\d+)\.(\d+)" type="full"\/>/) {
|
||||
#say LOG "*\t$thisLine";
|
||||
my ($oldB, $oldC, $oldV, $newB, $newC, $newV) =($bkFull{$1}, $2, $3, $bkFull{$4}, $5, $6);
|
||||
my $oldie = "$oldB $oldC:$oldV";
|
||||
$newRef{$oldie} = "$newB $newC:$newV";
|
||||
say LOG "**\t" . "\$newRef{$oldie}: " . $newRef{"$oldB $oldC:$oldV"}
|
||||
}
|
||||
}
|
||||
|
||||
close $file;
|
||||
}
|
||||
|
||||
sub ReadExceptions {
|
||||
say "Reading exceptions";
|
||||
say LOG "ReadExceptions from \$exceptions: $exceptions";
|
||||
open (my $file, "<:utf8", "$exceptions") or die "$exceptions:\n$!";
|
||||
|
||||
while (my $line = <$file>) {
|
||||
chomp $line;
|
||||
if ($line =~ /^([^#\n][^\t\n]*)\t([^\t\n]*\t[^\t\n]*)$/) {
|
||||
my ($rf, $oldNew) = ($1, $2);
|
||||
say LOG "\$line: $line, \$rf: $rf, \$oldNew: $oldNew";
|
||||
($adjust{$rf}) .= "$oldNew, ";
|
||||
$specifiedText{$rf} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
close $file;
|
||||
|
||||
}
|
||||
|
||||
sub PairtWEntriesTotWPageAndUniqSNs {
|
||||
say "Pairing tW entries with tW pages and unique Strong's numbers";
|
||||
my (@filesToRun, @relevantSNs) = ();
|
||||
my $filePattern = '*.md' ;
|
||||
find (sub {push @filesToRun, $File::Find::name if (m/^(.*)$filePattern$/)}, $topTwDir) ;
|
||||
@filesToRun = sort @filesToRun;
|
||||
say LOG "\@filesToRun: @filesToRun";
|
||||
foreach my $file (@filesToRun) {
|
||||
$file =~ s/\//\\/g unless $^O eq "linux" || $^O eq "darwin";
|
||||
my ($thisList, $shortFile) = ("", $file);
|
||||
#say "|$shortFile|\t|$topTwDir|";
|
||||
$shortFile =~ s/^\Q$topTwDir${d}\E//;
|
||||
$shortFile =~ s/\.md$//;
|
||||
$shortFile =~ s/\Q$d\E/,/;
|
||||
#say "|$shortFile|"; die;
|
||||
#if ($shortFile =~ /^(kt|names)/) {
|
||||
my $fileText = read_file("$file", binmode => 'utf8');
|
||||
if ($fileText =~ /^# ([^\n]*)\r?\n/) {
|
||||
$thisList = $1;
|
||||
chomp $thisList;
|
||||
say LOG "\$thisList = |$thisList|";
|
||||
$thisList =~ s/ \([^\)]*\)//g;
|
||||
$entriesThisPage{$shortFile} = $thisList;
|
||||
my @ULBEntries = split /, /, $thisList;
|
||||
foreach my $ULB (@ULBEntries) {
|
||||
$pageThisEntry{$ULB} = $shortFile;
|
||||
}
|
||||
my @tempArray = split /, /, $thisList;
|
||||
foreach my $slice (@tempArray) {
|
||||
$sourcePage{$slice} = $shortFile;
|
||||
#say LOG "$slice: $sourcePage{$slice}";
|
||||
}
|
||||
}
|
||||
if ($fileText =~ /Strong's(.*)$/ms) {
|
||||
my $SNs = $1;
|
||||
while ($SNs =~ s/[H](\d*)//) {
|
||||
push @relevantSNs, $1;
|
||||
$entriesThisSN{$1} .= "$thisList, ";
|
||||
$pagesThisSN{$1} .= "$shortFile, ";
|
||||
}
|
||||
}
|
||||
@relevantSNs = uniq(@relevantSNs);
|
||||
foreach (@relevantSNs) {
|
||||
$relevantSNs{$_} = "$_";
|
||||
#say LOG $relevantSNs{$_}
|
||||
}
|
||||
#}
|
||||
#say LOG "|$shortFile|: \t |$entriesThisPage{$shortFile}|"
|
||||
}
|
||||
#say LOG "====";
|
||||
#say LOG "====";
|
||||
}
|
||||
|
||||
sub LinkULBtoCV {
|
||||
say "Linking ULB to chapter and verse";
|
||||
say LOG "LinkULBtoCV, \$ULBfile: $ULBfile";
|
||||
open IN, "$ULBfile" or die "$ULBfile: $!";
|
||||
while (<IN>) {
|
||||
#say LOG $_;
|
||||
if (/^([^\t]*)\t(.*)$/) {
|
||||
$cv ++;
|
||||
($text{$1}, $fullText{$1}) = ($2, $2);
|
||||
$ref{$cv} = $1;
|
||||
$order{$1} = $cv;
|
||||
}
|
||||
#say LOG "First \$ref{$cv}: $ref{$cv}\n\$text{$ref{$cv}}: $text{$ref{$cv}}";
|
||||
}
|
||||
close IN;
|
||||
foreach my $key (sort keys %ref) {
|
||||
#say LOG "\$key: $key:, \$ref{$key}: $ref{$key}, \$text{$ref{$key}}: $text{$ref{$key}}"
|
||||
}
|
||||
}
|
||||
|
||||
sub ReadLinkedSNs {
|
||||
say "Reading linked Strong's numbers";
|
||||
my ($flag, $OSHBfile) = ("","");
|
||||
foreach $OSHBfile (@OSHBfileList) {
|
||||
#say LOG "opening \$^OHB $OSHBfile";
|
||||
open IN, "$OSHBfile" or die "$OSHBfile can't be opened\n\n";
|
||||
my ($thisBook, $thisChap, $thisVers, $thisRef);
|
||||
my (@pages);
|
||||
while (<IN>) {
|
||||
chomp;
|
||||
if (/<verse osisID="([^\.]*).(\d+).(\d+)">/) {
|
||||
my ($bk, $ch, $vs) = ($1, $2, $3);
|
||||
say LOG "#>\t$bk $ch:$vs";
|
||||
#if (exists $newRef{"$bk $ch:$vs"}) {
|
||||
# $thisRef = $newRef{"$bk $ch:$vs"}
|
||||
#} else {
|
||||
($thisRef) = ("$bkFull{$bk} $ch:$vs");
|
||||
#}
|
||||
say LOG "##\t$bk $ch:$vs, $thisRef";
|
||||
}
|
||||
else {
|
||||
while (/<w lemma="(\w\/)?(\d+)( \w)?"/g) {
|
||||
#say LOG $_;
|
||||
my ($thisNum) = ($2);
|
||||
say LOG "\t\$thisNum: $thisNum, \$SNsInCV{$thisRef}: $SNsInCV{$thisRef}";
|
||||
if (exists $relevantSNs{$thisNum}) {
|
||||
$SNsInCV{$thisRef} .= "$thisNum " unless ($SNsInCV{$thisRef} =~ /\b$thisNum\b/);
|
||||
}
|
||||
say LOG ">\t\$thisNum: $thisNum, \$SNsInCV{$thisRef}: $SNsInCV{$thisRef}";
|
||||
}
|
||||
}
|
||||
}
|
||||
close IN;
|
||||
}
|
||||
my %temp;
|
||||
foreach my $oldRef (sort keys %SNsInCV) {
|
||||
if (exists $newRef{$oldRef}) {
|
||||
$temp{$newRef{$oldRef}} = $SNsInCV{$oldRef};
|
||||
delete $SNsInCV{$oldRef};
|
||||
}
|
||||
}
|
||||
foreach my $changedRef (sort keys %temp) {
|
||||
$SNsInCV{$changedRef} = $temp{$changedRef}
|
||||
}
|
||||
}
|
||||
|
||||
sub LinkSNsToULBtextViaEntries {
|
||||
say "Linking Strong's numbers to ULB text via tW page entries";
|
||||
say LOG "sub LinkSNsToULBtextViaEntries called";
|
||||
foreach my $thisRef (sort keys %ref) {
|
||||
say LOG "\nLinkSNsToULBtextViaEntries: \$thisRef: $thisRef\t\$ref{$thisRef}: $ref{$thisRef}";
|
||||
(%workEntries, %ulbOrder) = ();
|
||||
my %workPage;
|
||||
my ($thisCV, $checkList, $tempString, $outString) = ($ref{$thisRef}, "", "", "");
|
||||
say OUT "$thisCV:";
|
||||
my (@allEntries);
|
||||
$listOfPages{$thisCV} = "";
|
||||
#say LOG "\$SNsInCV{$thisCV}: |$SNsInCV{$thisCV}|\n$text{$thisCV}";
|
||||
say LOG "\t\$SNsInCV{$thisCV}: >$SNsInCV{$thisCV}<";
|
||||
$SNsInCV{$thisCV} =~ s/^ +//;
|
||||
$SNsInCV{$thisCV} =~ s/ +$//;
|
||||
$SNsInCV{$thisCV} =~ s/ {2,}/ /g;
|
||||
say LOG "*\t\$SNsInCV{$thisCV}: >$SNsInCV{$thisCV}<";
|
||||
if (exists $specifiedText{$thisCV}) {
|
||||
#say LOG "*\t\$SNsInCV{$thisCV}: $SNsInCV{$thisCV}";
|
||||
|
||||
$SNsInCV{$thisCV} = Adjust($SNsInCV{$thisCV}, $thisCV);
|
||||
|
||||
$SNsInCV{$thisCV} =~ s/^ +(.*) +$/$1/;
|
||||
$SNsInCV{$thisCV} =~ s/ {2,}/ /g;
|
||||
say LOG "**\t\$SNsInCV{$thisCV}: >$SNsInCV{$thisCV}<";
|
||||
}
|
||||
#say LOG "<>\t<>\t\$SNsInCV{$thisCV}: |$SNsInCV{$thisCV}|";
|
||||
my @regArray = split / /, $SNsInCV{$thisCV};
|
||||
say LOG "\@regArray: >@regArray<";
|
||||
foreach my $thisNum (@regArray) {
|
||||
my ($found, $specPage);
|
||||
say LOG "\n\n\$thisNum: >$thisNum<\t\$entriesThisSN{$thisNum}: >$entriesThisSN{$thisNum}<";
|
||||
if ($thisNum =~ /\d+(\[([\w \-\']+)\])/) {
|
||||
$outString .= "$1($pageThisEntry{$2})\n";
|
||||
next;
|
||||
} elsif ($thisNum =~ /\d+(\(([\w\/]+)\))/) {
|
||||
$specPage .= $2;
|
||||
say LOG "\$specPage: $specPage";
|
||||
}
|
||||
if ($specPage) {
|
||||
$workEntries{$thisNum} = $entriesThisPage{$specPage};
|
||||
} else {
|
||||
$workEntries{$thisNum} = $entriesThisSN{$thisNum};
|
||||
}
|
||||
$workEntries{$thisNum} =~ s/, $//;
|
||||
#say LOG "**\t\$thisNum: >$thisNum<\t\$workEntries{$thisNum}: >$workEntries{$thisNum}<";
|
||||
my @beforeArray = split /, /, $workEntries{$thisNum};
|
||||
my @sortedArray = reverse sort { substr($a,0,1) <=> substr($b,0,1)
|
||||
|| length($a) <=> length($b)
|
||||
|| $a <=> $b }
|
||||
@beforeArray;
|
||||
$" = "\n\t";
|
||||
#say LOG "\@sortedArray: @sortedArray\n\$outString: $outString\n\$text{$ref{$thisRef}}: $text{$ref{$thisRef}}";
|
||||
foreach my $entry (@sortedArray) {
|
||||
my $testEntry = $entry;
|
||||
#print LOG "\$entry: $entry. Becomes ";
|
||||
while ($testEntry =~ s/^(.*) \.\.\. (.*)/($1)\\b(.*?)\\b($2)/) {}
|
||||
#print LOG "\$testEntry: |$testEntry| ";
|
||||
if ($testEntry =~ /\(\.\*\?\)/ && $text{$thisCV} =~ s/\b($testEntry)\b/$3/i) {
|
||||
say LOG "\n===\n$thisNum |$testEntry| is found in first test.\n===";
|
||||
$outString .= "[$entry]($pageThisEntry{$entry})\n";
|
||||
say LOG $outString . "\n" . $text{$thisCV};
|
||||
$found = 1;
|
||||
goto Breakout;
|
||||
} elsif ($text{$thisCV} =~ s/\b($testEntry)\b//i) {
|
||||
say LOG "\n===\n$thisNum |$testEntry| is found in second test.\n===";
|
||||
$outString .= "[$entry]($pageThisEntry{$entry})\n";
|
||||
say LOG $outString . "\n" . $text{$thisCV};
|
||||
$found = 1;
|
||||
goto Breakout;
|
||||
} else {
|
||||
#say LOG "and is not found in\n$text{$ref{$thisRef}}";
|
||||
}
|
||||
}
|
||||
Breakout:
|
||||
say MISSING "$thisCV $thisNum" unless ($found);
|
||||
next if $found;
|
||||
}
|
||||
say LOG "\t\$outString: $outString";
|
||||
$outString = ProperOrderOutString($outString, $thisCV);
|
||||
say LOG "<>\t\$outString: $outString";
|
||||
say OUT "$outString";
|
||||
#say LOG "sub LinkSNsToULBtextViaEntries finished";
|
||||
}
|
||||
}
|
||||
|
||||
sub Adjust {
|
||||
my ($snsOld, $ref, $snsNew, $addToSnsNew) = ($_[0], $_[1], "", "");
|
||||
say LOG "\$specifiedText{$ref}: $specifiedText{$ref}\n\$snsOld: $snsOld";
|
||||
my (%tempEntries);
|
||||
#say LOG ">\t\$sns: |$sns|";
|
||||
#say LOG ">\t\$specifiedText{$ref}: |$specifiedText{$ref}|";
|
||||
$snsOld =~ s/^ +LinkSNsToULBtextViaEntries//;
|
||||
my @oldArray = split / /, $snsOld;
|
||||
#say LOG "\$adjust{$ref}: $adjust{$ref}";
|
||||
my @preadjustments = split /, /, $adjust{$ref};
|
||||
foreach my $adjustment (@preadjustments) {
|
||||
#say LOG "<><>\t\$adjustment: >$adjustment<";
|
||||
if ($adjustment =~ /([^\t]*)\t\|\|$/) { # delete this from list to look for
|
||||
my $found = $1;
|
||||
$snsOld =~ s/\b$found\b ?//;
|
||||
say LOG "\$found: $found should be deleted from \$snsOld: $snsOld";
|
||||
} elsif ($adjustment =~ /^\|\|\t(.*)/) { # add this to list to look for
|
||||
my $adj = $1;
|
||||
say LOG "\$adjustment: $adjustment, \$adj: $adj";
|
||||
if ($adj =~ /([^\t]*)\t([^\t]*)/) {
|
||||
$snsNew = "[$1]($pageThisEntry{$2})"
|
||||
} else {
|
||||
$snsNew .= "$adj "
|
||||
}
|
||||
} elsif ($adjustment =~ /^(\d+)\t(\w+)$/) { # add specified word
|
||||
my ($found1, $found2) = ($1, $2);
|
||||
#$addToSnsNew .= "$1\[$2\] ";
|
||||
$snsOld =~ s/$found1/$found1\[$found2\]/;
|
||||
say LOG "\$snsOld: $snsOld";
|
||||
} elsif (($adjustment =~ /^(\d+)\t([\/\d\w]+)$/)) { # add specified page
|
||||
#$addToSnsNew .= "$1\{$2\} "
|
||||
my ($found1, $found2) = ($1, $2);
|
||||
$snsOld =~ s/$found1/$found1\($found2\)/;
|
||||
say LOG "\$snsOld: $snsOld";
|
||||
}
|
||||
}
|
||||
say LOG "\$snsNew: >$snsNew<\n\$snsOld+\$snsNew: >$snsOld< >$snsNew<";
|
||||
$snsNew = "$snsOld $snsNew";
|
||||
return $snsNew;
|
||||
}
|
||||
|
||||
sub Output {
|
||||
say "Outputting";
|
||||
#say LOG "Output subRoutine called";
|
||||
foreach my $key (sort keys %ref) {
|
||||
my %donePages;
|
||||
my $thisRef = $ref{$key};
|
||||
#print LOG "\$key: $key\t\$thisRef: $thisRef\t";
|
||||
#say LOG "\$SNsInCV{$thisRef}: |$SNsInCV{$thisRef}|";
|
||||
$SNsInCV{$thisRef} =~ s/^ +//;
|
||||
$SNsInCV{$thisRef} =~ s/ +$//;
|
||||
$SNsInCV{$thisRef} =~ s/ {2,}/ /;
|
||||
#say LOG "\$SNsInCV{$thisRef}: |$SNsInCV{$thisRef}|";
|
||||
#say LOG "\$listOfPages{$thisRef}: |$listOfPages{$thisRef}|";
|
||||
#$listOfPages{$thisRef} =~ s/^ +//;
|
||||
#$listOfPages{$thisRef} =~ s/ +$//;
|
||||
#$listOfPages{$thisRef} =~ s/ {2,}/ /;
|
||||
#say LOG "\$listOfPages{$thisRef}: |$listOfPages{$thisRef}|";
|
||||
my @array = split /\n/, $listOfPages{$thisRef};
|
||||
#say LOG "\@array: |@array|";
|
||||
my @sorted =
|
||||
sort sort { lc($a) cmp lc($b) }
|
||||
@array;
|
||||
#say LOG "\@sorted: |@sorted|";
|
||||
$" = "\n";
|
||||
$listOfPages{$thisRef} = "@sorted";
|
||||
say LOG "\$listOfPages{$thisRef}: $listOfPages{$thisRef}\n\$checkPages{$thisRef}: $checkPages{$thisRef}";
|
||||
#say OUT "$thisRef: $listOfPages{$thisRef}\n";
|
||||
$checkPages{$thisRef} =~ s/^ +//;
|
||||
$checkPages{$thisRef} =~ s/ +$//;
|
||||
$checkPages{$thisRef} =~ s/ {2,}/ /;
|
||||
$checkPages{$thisRef} =~ s/ \|\|//;
|
||||
say LOG "\$checkPages{$thisRef}:\t|$checkPages{$thisRef}|";
|
||||
my @checkArray = split / /, $checkPages{$thisRef};
|
||||
shift @sorted;
|
||||
#say LOG "\@checkArray: |@checkArray|";
|
||||
#say LOG "\@sorted: |@sorted|";
|
||||
#shift @sorted;
|
||||
#say LOG "\@sorted: |@sorted|";
|
||||
foreach my $slice (@sorted) {
|
||||
#print LOG "\$slice: $slice\t";
|
||||
$slice =~ s/\[.*?\]\((.*?)\)/$1/;
|
||||
#say LOG "\t\$slice: $slice";
|
||||
$donePages{$slice} = $slice;
|
||||
#say LOG "\t\$donePages{$slice}: $donePages{$slice}"
|
||||
}
|
||||
#say LOG "\@checkArray: |@checkArray|";
|
||||
foreach my $slice (@checkArray) {
|
||||
#say LOG "\$slice: $slice";
|
||||
unless (exists $donePages{$slice}) {
|
||||
#say LOG "\$thisRef: $thisRef\t\$slice:$slice";
|
||||
#say MISSING "$thisRef\t$slice\t||";
|
||||
say MISSING "$thisRef\t$slice";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub Substitute {
|
||||
foreach my $key (sort keys %pages) {
|
||||
say LOG "\$key: $key\t\$SNsInCV{$key}: $SNsInCV{$key}";
|
||||
if (exists $substitutedPages{$key}) {
|
||||
#say LOG "\$substitutedPages{$key}: $substitutedPages{$key}";
|
||||
$substitutedPages{$key} =~ s/, $//;
|
||||
my @array = split /, /, $substitutedPages{$key};
|
||||
foreach my $slice (@array) {
|
||||
#say LOG "\$slice: $slice";
|
||||
if ($slice =~ /([^\t]*)\t([^\t]*)/) {
|
||||
#say LOG "\n\$key: $key";
|
||||
my ($old, $new) = ($1, $2);
|
||||
#say LOG "\$old: >$old<\t\$new: >$new<";
|
||||
#say LOG "\$SNsInCV{$key}: >>$SNsInCV{$key}<<";
|
||||
if ($old eq "||") {
|
||||
$SNsInCV{$key} .= "$new ";
|
||||
$checkPages{$key} = $SNsInCV{$key};
|
||||
}
|
||||
elsif ($new eq "||") {
|
||||
$SNsInCV{$key} =~ s/$old //;
|
||||
$checkPages{$key} = $SNsInCV{$key};
|
||||
}
|
||||
else {
|
||||
$SNsInCV{$key} =~ s/$old/$new/;
|
||||
$checkPages{$key} = $SNsInCV{$key};
|
||||
}
|
||||
$SNsInCV{$key} =~ s/ \|\|//g;
|
||||
#say LOG "\$SNsInCV{$key}: >>>$SNsInCV{$key}<<<";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$checkPages{$key} = $SNsInCV{$key};
|
||||
}
|
||||
say LOG "<>\t\$key: $key\t\$SNsInCV{$key}: $SNsInCV{$key}";
|
||||
}
|
||||
}
|
||||
sub ProperOrderOutString {
|
||||
my @unordered = split /\n/, $_[0];
|
||||
my ($thisCV, $outS) = ($_[1], "");
|
||||
my (%orderedSet);
|
||||
foreach my $thisSet (@unordered) {
|
||||
say LOG "\t>\t$thisSet";
|
||||
if ($thisSet =~ /(\[([^\]]*)\])(\([^\)]*\))/) {
|
||||
my ($ulb, $fileLoc) = ($2, $3);
|
||||
$ulb =~ s/ \.\.\. /.*?/g;
|
||||
say LOG "\t>>\t\$ulb: $ulb, \$fileLoc: $fileLoc, \$fullText{$thisCV}\n$fullText{$thisCV}";
|
||||
if ($fullText{$thisCV} =~ /^(.*?)\b($ulb)\b(.*)$/) {
|
||||
say LOG "\t>>>\t$&";
|
||||
my ($order) = (length $1);
|
||||
$orderedSet{$order} = $thisSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach my $key (sort {$a<=>$b} keys %orderedSet) {
|
||||
$outS .= "$orderedSet{$key}\n"
|
||||
}
|
||||
return $outS;
|
||||
}
|
||||
|
||||
__DATA__
|
||||
1Chr 1 Chronicles
|
||||
1Kgs 1 Kings
|
||||
1Sam 1 Samuel
|
||||
2Chr 2 Chronicles
|
||||
2Kgs 2 Kings
|
||||
2Sam 2 Samuel
|
||||
Amos Amos
|
||||
Dan Daniel
|
||||
Deut Deuteronomy
|
||||
Eccl Ecclesiastes
|
||||
Esth Esther
|
||||
Exod Exodus
|
||||
Ezek Ezekiel
|
||||
Ezra Ezra
|
||||
Gen Genesis
|
||||
Hab Habakkuk
|
||||
Hag Haggai
|
||||
Hos Hosea
|
||||
Isa Isaiah
|
||||
Jer Jeremiah
|
||||
Job Job
|
||||
Joel Joel
|
||||
Jonah Jonah
|
||||
Josh Joshua
|
||||
Judg Judges
|
||||
Lam Lamentations
|
||||
Lev Leviticus
|
||||
Mal Malachi
|
||||
Mic Micah
|
||||
Nah Nahum
|
||||
Neh Nehemiah
|
||||
Num Numbers
|
||||
Obad Obadiah
|
||||
Prov Proverbs
|
||||
Ps Psalms
|
||||
Ruth Ruth
|
||||
Song Song of Songs
|
||||
Zech Zechariah
|
||||
Zeph Zephaniah
|
Loading…
Reference in New Issue