mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-25 12:52:29 +03:00
get-by-line-number.perl
This commit is contained in:
commit
da6ade7d94
33
contrib/other-builds/extract-mixed-syntax/learnable/equal.perl
Executable file
33
contrib/other-builds/extract-mixed-syntax/learnable/equal.perl
Executable file
@ -0,0 +1,33 @@
|
||||
#! /usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
|
||||
sub trim($);
|
||||
|
||||
my $file1 = $ARGV[0];
|
||||
my $file2 = $ARGV[1];
|
||||
|
||||
open (FILE1, $file1);
|
||||
open (FILE2, $file2);
|
||||
|
||||
my $countEqual = 0;
|
||||
while (my $line1 = <FILE1>) {
|
||||
my $line2 = <FILE2>;
|
||||
if (trim($line1) eq trim($line2)) {
|
||||
++$countEqual;
|
||||
}
|
||||
}
|
||||
|
||||
print $countEqual ."\n";
|
||||
|
||||
|
||||
######################
|
||||
# Perl trim function to remove whitespace from the start and end of the string
|
||||
sub trim($) {
|
||||
my $string = shift;
|
||||
$string =~ s/^\s+//;
|
||||
$string =~ s/\s+$//;
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
29
contrib/other-builds/extract-mixed-syntax/learnable/get-by-line-number.perl
Executable file
29
contrib/other-builds/extract-mixed-syntax/learnable/get-by-line-number.perl
Executable file
@ -0,0 +1,29 @@
|
||||
#! /usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
|
||||
binmode(STDIN, ":utf8");
|
||||
binmode(STDOUT, ":utf8");
|
||||
binmode(STDERR, ":utf8");
|
||||
|
||||
my $fileLineNum = $ARGV[0];
|
||||
open (FILE_LINE_NUM, $fileLineNum);
|
||||
|
||||
my $nextLineNum = <FILE_LINE_NUM>;
|
||||
|
||||
my $lineNum = 1;
|
||||
while (my $line = <STDIN>) {
|
||||
if (defined($nextLineNum) && $lineNum == $nextLineNum) {
|
||||
# matches. output line
|
||||
chomp($line);
|
||||
print "$line\n";
|
||||
|
||||
# next line number
|
||||
$nextLineNum = <FILE_LINE_NUM>;
|
||||
}
|
||||
|
||||
++$lineNum;
|
||||
}
|
||||
|
||||
|
||||
|
@ -168,8 +168,8 @@ float ChartTranslationOptionList::GetBestScore(const ChartCellLabel *chartCell)
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
const ChartHypothesis &bestHypo = **(stack->begin());
|
||||
return bestHypo.GetTotalScore();
|
||||
const ChartHypothesis &bestHypo = **(stack->begin());
|
||||
return bestHypo.GetTotalScore();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ bool RuleTableLoaderStandard::Load(FormatType format
|
||||
// parse source & find pt node
|
||||
|
||||
// constituent labels
|
||||
Word *sourceLHS;
|
||||
Word *sourceLHS = NULL;
|
||||
Word *targetLHS;
|
||||
|
||||
// create target phrase obj
|
||||
@ -251,6 +251,9 @@ bool RuleTableLoaderStandard::Load(FormatType format
|
||||
TargetPhraseCollection &phraseColl = GetOrCreateTargetPhraseCollection(ruleTable, sourcePhrase, *targetPhrase, sourceLHS);
|
||||
phraseColl.Add(targetPhrase);
|
||||
|
||||
// not implemented correctly in memory pt. just delete it for now
|
||||
delete sourceLHS;
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
|
@ -59,3 +59,5 @@ sub DeleteScore
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user