forked from WycliffeAssociates/en_tw
167 lines
4.7 KiB
Perl
167 lines
4.7 KiB
Perl
# 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";
|
|
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"`;
|
|
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";
|
|
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
|