![]() |
|< 1 2 >| | ![]() |
18 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl
use strict;
#use locale;
my %src=();
open (FILE1,'eng_text1.txt') or die ("Pruefen Sie bitte die Name.");
open (FILE2,'eng_text2.txt') or die ("Pruefen Sie bitte die Name.");
while(<FILE2>) {
chomp;
s/\s{2,}/ /go;
$src{$_}=1;
}
#close (FILE2);
my $dst;
while(<FILE1>) {
$dst=$_;
chomp;
lc;
s/[:punct:]//go;
s/\s{2,}/ /go;
print $dst unless ($src{$_});
}
#close(FILE1);
Tie::IxHash arbeiten) ein. Danach durch die zweite Datei gehen und überprüfen, ob zu dem Satz schon ein Eintrag im Hash existiert. Wenn ja, dann mit delete siehe perldoc -f delete) den Satz aus dem Hash löschen.1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl
use strict;
use Tie::IxHash;
tie %hash1,%hash2,"Tie::IxHash,APP";
my %hash1=();
open(APP,"eng_test1.txt");
#open(NEG,'eng_test2.txt');
while(<APP>) {
chomp;
@keys=keys %hash1;
}
close (APP);
open(NEG,"eng_text2.txt");
while(<NEG>) {
chomp;
@keys=keys %hash2;
}
close(NEG);
open(OUT,">saetze_hash.txt")
my @not=();
foreach(keys %hash1){
push(@not,$_) unless exists $hash2{$_};
}
close(OUT);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl
use strict;
use Tie::IxHash;
tie my %hash,"Tie::IxHash";
open(APP,'<',"eng_text1.txt") or die $!;
while(my $line = <APP>){
chomp $line;
$line =~ s/\s+/ /g;
$hash{$line} = 1;
}
close (APP);
open(NEG,'<',"eng_text2.txt") or die $!;
while(my $line = <NEG>) {
chomp $line;
$line =~ s/\s+/ /g;
$line =~ s/\p{IsPunct}//g;
if(exists $hash{$line}){
delete $hash{$line};
}
}
close(NEG);
open(OUT,">saetze_hash.txt") or die $!;
print OUT $_,"\n" for(keys %hash);
close(OUT) or die $!;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl
use warnings;
use strict;
open(EIN, "<Eingabedatei.txt") or die $!;
my %pnr;
while(<EIN>) {
chomp;
my @f = split(/\t/);
$pnr{$f[0]} = 1;
} # while
close(EIN) or die $!;
open(EIN2, "<Eingabedatei2.txt") or die $!;
open(AUS, ">Ausgabedatei.txt") or die $!;
while(<EIN2>) {
my @satz = split(/\t/);
my $vergleich = $satz[0];
print AUS $_ if defined $pnr{$vergleich};
} # while
close(EIN) or die $!;
close(AUS) or die $!;
1;
Quotechomp $line;
$line =~ s/\s+/ /g;
$hash{$line} = 1;
.,"!?
QuoteThe following equivalences to Unicode \p{} constructs and equivalent backslash character classes (if available), will hold:
[:...:] \p{...} backslash
alpha IsAlpha
alnum IsAlnum
ascii IsASCII
blank IsSpace
cntrl IsCntrl
digit IsDigit \d
graph IsGraph
lower IsLower
print IsPrint
punct IsPunct
space IsSpace
IsSpacePerl \s
upper IsUpper
word IsWord
xdigit IsXDigit
Quotepunct
Any punctuation (special) character.
1
2
3
4
5
6
$z=~/"#String:"/;
$q=~/sa[0-9]{3}s[0-9]{2}/;
if ($k>$z and $q<$k)
{
print "$k \n"
};
1
2
3
4
5
6
7
8
Dies ist ein ganz normaler Text
mit Sätzen etc.
#String: "Dieser Satz muss raus genommen werden! Und alle Interpunktionszeichnen sollen auch im neuen File sein.- Komisch, nicht wahr?
sa023s04
und danach geht es weiter...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl
use strict;
use warnings;
my $file = './test.txt';
my $content;
{
local $/;
open(my $fh,'<',$file) or die $!;
$content = <$fh>;
close $fh;
}
$content =~ s/#String:.*?sa\d{3}s\d{2}\n?//sg;
print $content;
![]() |
|< 1 2 >| | ![]() |
18 Einträge, 2 Seiten |