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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
|
#!/usr/bin/perl
# Copyright (c) 1995 Alistair Conkie. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
#
# Purpose: To convert from CUVOALD format to Edinburgh format
#
# Specifics:
#
# All words have been converted to use [A-Za-z'-], any foreign
# characters are deleted.
#
# The final-r is left in in all cases.
#
# Capital letters are maintained.
#
# A small internal dictionary to avoid rare transcriptions
# of common words.
#
# For perhaps 200-300 words there are alternate transcriptions
# that depend on Part-of-Speech information. This information is
# not currently available, so the transcription selected may
# be wrong.
#####################################################################
# For some words we don't want the CUVOALD definition (or more likely
# we don't want one of them) so to be sure we have our own minature
# dictionary
%mini_dico = (
'am', '* aa m',
'an', '* a n',
'do', 'd * uu',
'does', 'd * u z',
'ins', '* i n z',
'lame', 'l * ai m',
'mate', 'm * ai t',
'no', 'n * oa',
'nos', 'n * oa z',
'put', 'p * oo t',
'puts', 'p * oo t s',
're', 'r * ee',
'ret', 'r * e t',
'sake', 's * ai k',
);
$stress = "'";
$i = 0;
while(<>) {
@line = split(//,$_);
# neglect everything except words and transcriptions
$hw = join('',@line[0..22]);
$tr = join('',@line[23..45]);
$syl = $line[69];
# still need to get rid of blanks and drop double words
@words = split(' ',$hw);
if($#words ne 0) {
next;
} else {
$word = $words[0];
$tr =~ /(\S+)\s*/;
$tr = $1;
if($syl eq 1) {
$tr = alv2edin("$stress$tr");
} else {
$tr = alv2edin($tr);
}
$tr = adj_stress($tr);
# list of banned characters...
$word =~ s/"//g;
$word =~ s/<//g;
$word =~ s/^//g;
$word =~ s/_//g;
$word =~ s/\`//g;
$word =~ s/\~//g;
if(defined($mini_dico{$word})) {
print "$word $mini_dico{$word}\n";
} else {
print "$word $tr\n";
}
}
$i++;
print STDERR "$i\r";
}
# dbmclose(%OXFORD);
sub alv2edin {
local($inp) = $_[0];
# try everything, prefer longest
$out = '';
@inp = split(//,$inp);
while($#inp != -1) {
$c = shift(@inp);
if($c eq 'p') {
$out .= "p ";
} elsif ($c eq 't') {
if($inp[0] eq 'S'){
shift(@inp);
$out .= "ch ";
} else {
$out .= "t ";
}
} elsif ($c eq 'd') {
if($inp[0] eq 'Z'){
shift(@inp);
$out .= "j ";
} else {
$out .= "d ";
}
} elsif($c eq 'b') {
$out .= "b ";
} elsif($c eq 'k') {
$out .= "k ";
} elsif($c eq 'm') {
$out .= "m ";
} elsif($c eq 'n') {
$out .= "n ";
} elsif($c eq 'l') {
$out .= "l ";
} elsif($c eq 'r') {
$out .= "r ";
} elsif($c eq 'R') {
$out .= "r ";
} elsif($c eq 'f') {
$out .= "f ";
} elsif($c eq 'v') {
$out .= "v ";
} elsif($c eq 's') {
$out .= "s ";
} elsif($c eq 'z') {
$out .= "z ";
} elsif($c eq 'h') {
$out .= "h ";
} elsif($c eq 'w') {
$out .= "w ";
} elsif($c eq 'g') {
$out .= "g ";
} elsif($c eq 'N') {
$out .= "ng ";
} elsif($c eq 'T') {
$out .= "th ";
} elsif($c eq 'D') {
$out .= "dh ";
} elsif($c eq 'S') {
$out .= "sh ";
} elsif($c eq 'Z') {
$out .= "zh ";
} elsif($c eq 'j') {
$out .= "y ";
} elsif($c eq 'a') {
if($inp[0] eq 'I'){
shift(@inp);
$out .= "ie ";
} elsif($inp[0] eq 'U'){
shift(@inp);
$out .= "ou ";
} else {
$out .= "BUG ";
}
} elsif($c eq 'e') {
if($inp[0] eq 'I'){
shift(@inp);
$out .= "ai ";
} elsif($inp[0] eq '@'){
shift(@inp);
$out .= "air ";
} else {
$out .= "e ";
}
} elsif($c eq 'U') {
if($inp[0] eq '@'){
shift(@inp);
$out .= "oor ";
} else {
$out .= "oo ";
}
} elsif($c eq 'I') {
if($inp[0] eq '@'){
shift(@inp);
$out .= "eer ";
} else {
$out .= "i ";
}
} elsif($c eq '@') {
if($inp[0] eq 'U'){
shift(@inp);
$out .= "oa ";
} else {
$out .= "a ";
}
} elsif($c eq 'o') {
if($inp[0] eq 'I'){
shift(@inp);
$out .= "oi ";
} else {
$out .= "BUG ";
}
} elsif($c eq 'i') {
$out .= "ee ";
} elsif($c eq 'A') {
$out .= "ar ";
} elsif($c eq 'O') {
$out .= "aw ";
} elsif($c eq 'u') {
$out .= "uu ";
} elsif($c eq '3') {
$out .= "er ";
} elsif($c eq '&') {
$out .= "aa ";
} elsif($c eq 'V') {
$out .= "u ";
} elsif($c eq '0') {
$out .= "o ";
} elsif($c eq "'") {
$out .= "* ";
} elsif($c eq ',') {
$out .= "~ ";
} elsif($c eq '+') {
$out .= "+ ";
} elsif($c eq '-') {
$out .= "- ";
} else {
$out .= "BUG ";
}
}
chop($out);
return($out);
}
sub adj_stress {
my $t = $_[0];
$t =~ s/\* ([ bcdfghjklmnpqrstvwxyz]*) ([aeiou])/\. $1 \* $2/g;
$t =~ s/\~ ([ bcdfghjklmnpqrstvwxyz]*) ([aeiou])/\. $1 \~ $2/g;
$t =~ s/^\. //g;
$t =~ s/\- \. /\- /g;
$t =~ s/\| \. /\- /g;
$t =~ s/\+ \. /\- /g;
$t;
}
|