All pastes #182401 Raw Edit

Anonymous

public text v1 · immutable
#182401 ·published 2006-09-25 23:56 UTC
rendered paste body
#!/usr/bin/perl
use strict;
use warnings;

my $file = '/home/felix/Studier/Perl/02_labb/hit1.txt';
# output from the PAROLE corpus

open(INFO, $file);      # Open the file
my @file_array = <INFO>;   # Read it into an array
close(INFO);            # Close the file

foreach my $line (@file_array) {

    $line =~ s/^[\d]*\t[\S \,\.\!\?]*\t(.*)\t[\S \,\.\!\?]*\n?$/$1/igs;
    # regexp replace for PAROLE corpus output http://spraakbanken.gu.se/parole/
    # [msd="AP000N0S"] [msd="N.*"]
    # [word=".*ig.*" & msd="AQ.*"] [msd="N.*"]
   
}

my %seen = ();
my @uniq = ();
foreach my $item (@file_array) {
    if (!$seen{$item}) { 
        $seen{$item} = 1;
        push(@uniq, $item);
    } else {
        $seen{$item}++;
    }
}

my @sorted_list = ();
while (my ($key, $value) = each %seen) {
    if ($value > 1) { # I don't care about 1 occurence
        push (@sorted_list, "$value $key\n");
    }
}

#print reverse sort(@sorted_list);
print sort {int($a) <=> int($b)} @sorted_list;