-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update scripts to update lexicon and augmented strong
- Loading branch information
1 parent
703317b
commit 1952a2e
Showing
6 changed files
with
187 additions
and
129 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...s/src/main/resources/scripts_to_prep_lexicon_augmented_strong/1.5_deleteExtraAugStrong.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/perl | ||
|
||
use warnings; | ||
use strict; | ||
use List::MoreUtils qw(firstidx); | ||
|
||
my $number_args = $#ARGV + 1; | ||
if ($number_args != 2) { | ||
print "Please provide the file name of the augstrongs file and a list of Strong to ignore as command line arguments.\n"; | ||
exit; | ||
} | ||
my $lastStrong = ""; | ||
my $inputFile = $ARGV[0]; | ||
my %augStrong; | ||
my %allAugInAStrong; | ||
my %refs; | ||
open (FH, '<', $inputFile) or die "Could not open input file: $inputFile"; | ||
my $outputFile = $inputFile . ".out"; | ||
open (OUT, '>', $outputFile) or die "Could not open output file"; | ||
$inputFile = $ARGV[1]; | ||
open (FH2, '<', $inputFile) or die "Could not open input file: $inputFile"; | ||
my @strongToSkip = (); | ||
while (<FH2>) { | ||
chomp($_); | ||
push(@strongToSkip, $_); | ||
} | ||
close (FH2); | ||
my $skip = 0; | ||
while (<FH>) { | ||
chomp($_); | ||
$_ =~ s/\r//; | ||
my $line = $_; | ||
if ($line =~ m/^\@AugmentedStrong=\t/) { | ||
my $currentStrong = $'; | ||
if ( grep( /^$currentStrong$/, @strongToSkip ) ) { | ||
print "found it $currentStrong\n"; | ||
$skip = 1; | ||
} | ||
else { | ||
$skip = 0; | ||
} | ||
} | ||
if (!($skip)) { | ||
print OUT $line . "\n"; | ||
} | ||
} | ||
close (FH); | ||
close(OUT); |
File renamed without changes.
119 changes: 0 additions & 119 deletions
119
step-tools/src/main/resources/scripts_to_prep_lexicon_augmented_strong/1b_checkAugStrong.pl
This file was deleted.
Oops, something went wrong.
123 changes: 123 additions & 0 deletions
123
...ols/src/main/resources/scripts_to_prep_lexicon_augmented_strong/2.5_deleteExtraLexicon.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#!/usr/bin/perl | ||
|
||
use warnings; | ||
use strict; | ||
|
||
my $number_args = $#ARGV + 1; | ||
if ($number_args != 2) { | ||
print "Please provide the file name of the lexicon file and a list of Strong to ignore as command line arguments.\n"; | ||
exit; | ||
} | ||
|
||
my %lastVerse; | ||
my %processedStrongNum; | ||
my $inputFile = $ARGV[0]; | ||
my $outFile = $inputFile . ".out"; | ||
open (FH, '<', $inputFile) or die "Could not open input file: $inputFile"; | ||
open (OF, '>', $outFile) or die "Could not open output file: $outFile"; | ||
$inputFile = $ARGV[1]; | ||
open (FH2, '<', $inputFile) or die "Could not open input file: $inputFile"; | ||
my @strongToSkip = (); | ||
while (<FH2>) { | ||
chomp($_); | ||
push(@strongToSkip, $_); | ||
} | ||
|
||
my $lastStrongNum = ""; | ||
my $currNum = ""; | ||
my @out = (); | ||
my $foundStrNo = 0; | ||
my $founddStrNo = 0; | ||
my $dStrNoLine = ""; | ||
my $strNoLine = ""; | ||
my $lineNum = 0; | ||
while (<FH>) { | ||
$lineNum ++; | ||
chomp($_); | ||
$_ =~ s/\r//; | ||
my $line = $_; | ||
if ($line =~ /==============$/) { | ||
my $err = ""; | ||
if ((!$foundStrNo) && ($lineNum > 1)) { $err = " StrNo"; print "Did not find $err around line $lineNum\n";} | ||
if (!$founddStrNo) { $err .= " dStrNo";} | ||
my $currentStrong = $dStrNoLine; | ||
$currentStrong =~ s/^\@dStrNo=\t//; | ||
if ( grep( /^$currentStrong$/, @strongToSkip ) ) { | ||
print "found it $currentStrong\n"; | ||
} | ||
else { | ||
for (@out) { | ||
my $outLine = $_; | ||
if ($outLine =~ /==============$/) { | ||
print OF $outLine . "\n"; | ||
my $lineToPrint = $dStrNoLine; | ||
if ($lineToPrint ne "") { | ||
$lineToPrint =~ s/^\@dStrNo=\t/\@StrNo=\t/; | ||
} | ||
else { $lineToPrint = $strNoLine; } | ||
print OF $lineToPrint . "\n"; | ||
} | ||
elsif ($outLine !~ /^\@StrNo=\t/) { | ||
print OF $outLine . "\n"; | ||
} | ||
} | ||
} | ||
@out = (); | ||
$foundStrNo = 0; | ||
$founddStrNo = 0; | ||
$dStrNoLine = ""; | ||
$strNoLine = ""; | ||
$currNum = ""; | ||
} | ||
elsif ($line =~ /^\@StrNo=\t/) { | ||
my $newLine = $'; | ||
if ($currNum ne "") { | ||
print "unmatch StrNo: " . $currNum . ", linenum: $lineNum\n"; | ||
$currNum = ""; | ||
exit; | ||
} | ||
$foundStrNo = 1; | ||
$currNum = $newLine; | ||
$strNoLine = $line; | ||
} | ||
elsif ($line =~ m/^\@dStrNo=\t/) { | ||
my $newNum = $'; | ||
my $newNumChop = $newNum; | ||
if ($newNum =~ /([GH]\d+)[A-Z]$/) { | ||
$newNumChop = $1; | ||
} | ||
$dStrNoLine = $line; | ||
if (($currNum ne $newNumChop) && | ||
(uc $currNum ne uc $newNum) && | ||
($currNum !~ /^[GH]\d+[abcdefg]$/) && | ||
($currNum !~ /^[GH]\d+$/)) { | ||
print "different num at: " . $lineNum . " " . $currNum . " " . $newNum . "\n"; | ||
} | ||
$currNum = ""; | ||
$founddStrNo = 1; | ||
} | ||
push @out, $line; | ||
} | ||
my $currentStrong = $dStrNoLine; | ||
$currentStrong =~ s/^\@dStrNo=\t//; | ||
if ( grep( /^$currentStrong$/, @strongToSkip ) ) { | ||
print "found it $currentStrong\n"; | ||
} | ||
else { | ||
for (@out) { | ||
my $outLine = $_; | ||
if ($outLine =~ /==============$/) { | ||
print OF $outLine . "\n"; | ||
my $lineToPrint = $dStrNoLine; | ||
if ($lineToPrint ne "") { | ||
$lineToPrint =~ s/^\@dStrNo=\t/\@StrNo=\t/; | ||
} | ||
else { $lineToPrint = $strNoLine; } | ||
print OF $lineToPrint . "\n"; | ||
} | ||
elsif ($outLine !~ /^\@StrNo=\t/) { | ||
print OF $outLine . "\n"; | ||
} | ||
} | ||
} | ||
print "Updated lexicon information is in: $outFile\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters