voxforge.org
VoxForge Dev

Changeset 2625

Show
Ignore:
Timestamp:
06/26/08 21:52:47 (2 months ago)
Author:
kmaclean
Message:

minor rearranging of methods in Dictionary class; and text correction updates in Text class

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/Dictionary.pm

    r2614 r2625  
    3838        return $self; 
    3939}     
     40 
     41=head2 updatePronunciationDictionary  
     42 
     43Update the pronunciation dictionary with the missing word word pronunications  
     44 
     45=cut 
     46 
     47sub 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} 
    4076 
    4177=head1 INSTANCE METHODS (not user accessible) 
     
    239275        $self->{"pronDictionary"} = $pronDictionary; 
    240276          
    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 ); 
    265278        return 1; 
    266279} 
  • Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/Text.pm

    r2608 r2625  
    115115                $line =~ s/\]//g; # remove right bracket         
    116116                $line =~ s/\*//g; # remove star                          
     117                $line =~ s/&c/etcetera/g;  
    117118                # Other cleanup !!!!!! need to change the prompts files directly rather than doing this!!! or add to dictionnary!!! 
    118119                $line =~ s/&/AND/g;