| | 40 | |
|---|
| | 41 | =head2 updatePronunciationDictionary |
|---|
| | 42 | |
|---|
| | 43 | Update the pronunciation dictionary with the missing word word pronunications |
|---|
| | 44 | |
|---|
| | 45 | =cut |
|---|
| | 46 | |
|---|
| | 47 | sub updatePronunciationDictionary { # public |
|---|
| | 48 | my ($class, $pronDictionary,$newWordsPronunciations )= @_; |
|---|
| | 49 | |
|---|
| | 50 | open(DICTIONARY,">>$pronDictionary") or confess ("cannot open $pronDictionary file"); |
|---|
| | 51 | open(MISSINGWORDSOUT,"<$newWordsPronunciations") or confess ("cannot open $newWordsPronunciations file"); |
|---|
| | 52 | #print "adding the following words to VoxForge Pronunciation Dictionary\n"; |
|---|
| | 53 | while (my $line = <MISSINGWORDSOUT>) { |
|---|
| | 54 | next if ($line =~ /^(\s)*$/); # skip blank lines |
|---|
| | 55 | if ($line =~ /\w/) { |
|---|
| | 56 | #print $line; |
|---|
| | 57 | print DICTIONARY $line; |
|---|
| | 58 | } |
|---|
| | 59 | } |
|---|
| | 60 | close MISSINGWORDSOUT; |
|---|
| | 61 | close DICTIONARY; |
|---|
| | 62 | |
|---|
| | 63 | open(DICTIONARY,"$pronDictionary") or confess ("cannot open $pronDictionary file"); |
|---|
| | 64 | my(@lines) = <DICTIONARY>; # read file into list |
|---|
| | 65 | close(DICTIONARY); |
|---|
| | 66 | |
|---|
| | 67 | open(DICTIONARY,">$pronDictionary") or confess ("cannot open $pronDictionary file"); |
|---|
| | 68 | @lines = sort(@lines); # sort the list |
|---|
| | 69 | my($line); |
|---|
| | 70 | foreach $line (@lines) { # loop thru list |
|---|
| | 71 | print DICTIONARY "$line"; # print in sort order |
|---|
| | 72 | } |
|---|
| | 73 | close(DICTIONARY); |
|---|
| | 74 | return 1; |
|---|
| | 75 | } |
|---|
| 241 | | open(DICTIONARY,">>$pronDictionary") or confess ("cannot open $pronDictionary file"); |
|---|
| 242 | | open(MISSINGWORDSOUT,"<$missing_words_out") or confess ("cannot open $missing_words_out file"); |
|---|
| 243 | | #print "adding the following words to VoxForge Pronunciation Dictionary\n"; |
|---|
| 244 | | while (my $line = <MISSINGWORDSOUT>) { |
|---|
| 245 | | next if ($line =~ /^(\s)*$/); # skip blank lines |
|---|
| 246 | | if ($line =~ /\w/) { |
|---|
| 247 | | #print $line; |
|---|
| 248 | | print DICTIONARY $line; |
|---|
| 249 | | } |
|---|
| 250 | | } |
|---|
| 251 | | close MISSINGWORDSOUT; |
|---|
| 252 | | close DICTIONARY; |
|---|
| 253 | | |
|---|
| 254 | | open(DICTIONARY,"$pronDictionary") or confess ("cannot open $pronDictionary file"); |
|---|
| 255 | | my(@lines) = <DICTIONARY>; # read file into list |
|---|
| 256 | | close(DICTIONARY); |
|---|
| 257 | | |
|---|
| 258 | | open(DICTIONARY,">$pronDictionary") or confess ("cannot open $pronDictionary file"); |
|---|
| 259 | | @lines = sort(@lines); # sort the list |
|---|
| 260 | | my($line); |
|---|
| 261 | | foreach $line (@lines) { # loop thru list |
|---|
| 262 | | print DICTIONARY "$line"; # print in sort order |
|---|
| 263 | | } |
|---|
| 264 | | close(DICTIONARY); |
|---|
| | 277 | updatePronunciationDictionary("", $pronDictionary,$missing_words_out ); |
|---|