Blame view
egs/rm/s5/local/make_rm_dict.pl
2.48 KB
8dcb6dfcb first commit |
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 |
#!/usr/bin/env perl # Copyright 2010-2011 Yanmin Qian Microsoft Corporation # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED # WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, # MERCHANTABLITY OR NON-INFRINGEMENT. # See the Apache 2 License for the specific language governing permissions and # limitations under the License. # This file takes as input the file pcdsril.txt that comes with the RM # distribution, and creates the dictionary used in RM training. # make_rm_dct.pl pcdsril.txt > dct.txt if (@ARGV != 1) { die "usage: make_rm_dct.pl pcdsril.txt > dct.txt "; } unless (open(IN_FILE, "@ARGV[0]")) { die ("can't open @ARGV[0]"); } while ($line = <IN_FILE>) { chop($line); if (($line =~ /^[a-z]/)) { $line =~ s/\+1//g; @LineArray = split(/\s+/,$line); @LineArray[0] = uc(@LineArray[0]); printf "%-16s", @LineArray[0]; for ($i = 1; $i < @LineArray; $i ++) { if (@LineArray[$i] eq 'q') {} elsif (@LineArray[$i] eq 'zh') { printf "sh "; } elsif (@LineArray[$i] eq 'eng') { printf "ng "; } elsif (@LineArray[$i] eq 'hv') { printf "hh "; } elsif (@LineArray[$i] eq 'em') { printf "m "; } elsif (@LineArray[$i] eq 'axr') { printf "er "; } elsif (@LineArray[$i] eq 'tcl') { if (@LineArray[$i+1] ne 't') { printf "td "; } } elsif (@LineArray[$i] eq 'dcl') { if (@LineArray[$i+1] ne 'd') { printf "dd "; } } elsif (@LineArray[$i] eq 'kcl') { if (@LineArray[$i+1] ne 'k') { printf "kd "; } } elsif (@LineArray[$i] eq 'pcl') { if (@LineArray[$i+1] ne 'p') { printf "pd "; } } elsif (@LineArray[$i] eq 'bcl') { if (@LineArray[$i+1] ne 'b') { printf "b "; } } elsif (@LineArray[$i] eq 'gcl') { if (@LineArray[$i+1] ne 'g') { printf "g "; } } elsif (@LineArray[$i] eq 't') { if (@LineArray[$i+1] ne 's') { printf "@LineArray[$i] "; } else { printf "ts "; $i++; } } else { printf "@LineArray[$i] "; } } printf " "; } } printf "!SIL sil "; close(IN_FILE); |