Speech:Summer 2012 dictionary.pl


 * Home
 * Information

dictionary.pl Perl Script
This script takes a word list and finds all the corresponding words in the master dictionary and then outputs a new dictionary file that consists only of words in the word list.

Source Code
!/usr/bin/perl

if($#ARGV != 2 ) {       print "Compares the list of words in a file to the words in a dictionary and outputs the words available with pronunciations\n"; print "perl GenerateDictionary WordFile DictionaryFile OutputFile\n"; exit; }

open( WORD_FILE, "<$ARGV[0]" );

open( DICT_FILE, "<$ARGV[1]" );

open( OUTP_FILE, ">>$ARGV[2]" );

@theDICT = ;

close( DICT_FILE );

while(  ) {       my($line) = $_;

chomp($line); foreach( @theDICT ) {               $tmpLine = $_; @items = split( / /, $tmpLine );

if( @items[0] eq $line ) {                       print $line."\t".$tmpLine; print OUTP_FILE $tmpLine; }

}

}

close( WORD_FILE ); close( OUTP_FILE ); exit;