Fetching contributors…
Cannot retrieve contributors at this time
executable file 81 lines (69 sloc) 1.96 KB
#!/usr/bin/perl -w
# Copyright (C) 2002-2003 Nadav Har'El and Dan Kenigsberg
#
# Merges several dictionaries with prefix hints, into one dictionary with
# or'ed prefix hints.
# Usage: cat dict1 dict2 ... | pmerge -p prefixesout > wordsout
use IO::File;
use Carp;
require "PrefixBits.pl";
# "perl -w" warns about variables only used once (it assumes they are a
# typo). This ugliness gets rid of this warning. Is there a more sensible way?
($PS_L,$PS_B,$PS_VERB,$PS_NONDEF,$PS_IMPER,$PS_MISC)=
($PS_L,$PS_B,$PS_VERB,$PS_NONDEF,$PS_IMPER,$PS_MISC);
use Getopt::Std;
my %opts;
# -p - output prefix file.
if(!getopts('p:', \%opts)){
exit(1);
}
my $out_prefixes=$opts{p};
my $specifier;
my %specifiers;
while(<>){
chomp;
#next if /---/; # TODO: this isn't needed. remove it.
#s/-$//o; # TODO: dan added this. remove it.
s/\+ / /o; # The Makefile was supposed to remove those, but still...
if(/^L/o){
$specifier = $PS_L;
s/^L//o;
} elsif(/^B/o){
$specifier = $PS_B;
s/^B//o;
} elsif(!/^[à-ú]/o){
next; # not a word
} elsif(/-$/o){
# In wolig.pl's simple output (without -d), this specified smichut,
# and we shouldn't allow prefixes with he hayedia. This case is
# useful for smichut words in extrawords.
$specifier = $PS_NONDEF;
s/-$//o;
} elsif(/ ô,/o) {
if(/ .*öéååé/o) {
$specifier = $PS_IMPER;
} elsif(!/ .*äååä/o) {
$specifier = $PS_VERB;
} elsif(/ .*ñîéëåú/o || m:,ëéðåé/:o) {
$specifier = $PS_NONDEF;
} else {
$specifier = $PS_ALL;
}
} elsif(/[ ,][òú],/) {
if (/ .*ñîéëåú/o || m:,ùì/:o || / .*ôøèé/o) {
$specifier = $PS_NONDEF;
} else {
$specifier = $PS_ALL;
}
} else {
$specifier = $PS_ALL;
}
s/ .*$//; # remove all the "-d" explanations after the word
$specifiers{$_} |= $specifier;
}
my @words = sort(keys %specifiers);
my $F = new IO::File;
$F->open($out_prefixes,"w") or croak "Couldn't write -p parameter '$out_prefixes'";
print $F map { chr($specifiers{$_}) } @words;
print map { $_."\n" } @words;
exit 0;