2 # pattern_mminput - convert patterns for Remi Coulom's MM tool
4 # First, run pattern_enumerate, then feed it to this one. The script will
5 # also use the pattern.fdict file generated by pattern_enumerate, so direct
6 # piping probably will not work.
8 # We use two-pass approach mainly basically to find out how many features
9 # of certain kind there are.
11 # See mm/README for format of generated output.
13 my @fi, @fc, @fn; # start indices, counts, maps
16 my $df = "patterns.fdict";
17 open D
, $df or die "$df: $!";
20 my ($si, $fi, $fpi, $fn, $fp) = (/^(.*?) (.*?):(.*?) (.*?):(.*?)$/);
22 defined $fi[$fi] or $fi[$fi] = $si;
30 foreach my $i (0 .. $#fi) {
31 print $fc[$i]." ".$fn[$i]."\n";
38 my @patterns = split(/\) \(/, $_);
41 foreach my $pat (@patterns) {
42 my @feats = split(/ /, $pat);
44 foreach my $feat (@feats) {
45 my ($fi, $fp) = split(/:/, $feat);
46 push @tfeats, $fi[$fi] + $fp;
48 push @teams, join(' ', @tfeats);
51 foreach my $i (0 .. $#teams) {
52 print $teams[$i]."\n";