Created
July 20, 2017 17:49
-
-
Save jimregan/eecdec1b822ce445cfd9e2692f547096 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use utf8; | |
open(IN, "<", "$ARGV[0]"); | |
binmode(IN, ":encoding(latin-1)"); | |
#open(OUT, ">", "collisions.txt"); | |
#binmode(OUT, ":utf8"); | |
binmode(STDOUT, ":utf8"); | |
binmode(STDERR, ":utf8"); | |
my %p2g = (); | |
while(<IN>) { | |
chomp; | |
s/^\(//; | |
my ($word, $pos, $pronraw) = split/\t/; | |
next if ($pos eq 'pos'); | |
my $pron = $pronraw; | |
$pron =~ s/[0-9]\)//g; | |
$pron =~ s/[()]//g; | |
$pron =~ s/^ //; | |
$pron =~ s/\r//; | |
$pron =~ s/ $//; | |
my $value = $word . '__' . $pos; | |
if(exists $p2g{$pron}) { | |
if ($p2g{$pron} =~ /$value/) { | |
#print STDERR "DUP: $p2g{$pron} $value\n"; | |
} else { | |
$p2g{$pron} .= ", $value"; | |
} | |
} else { | |
$p2g{$pron} = $value; | |
} | |
} | |
for my $pron (keys %p2g) { | |
print $pron . "\t" . $p2g{$pron} . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment