I am hoping you guys can help me out for school I have to create a Perl script that takes out text from one file (a transcript) then try's to find the same word in a dictionary file that contains the word and and its pronunciation spelling and then writes the word with the pronunciation spelling into a new file. Below is an example.

YES NOW YOU KNOW IF IF EVERYBODY LIKE IN AUGUST WHEN EVERYBODY'S ON VACATION OR SOMETHING WE CAN DRESS A LITTLE MORE CASUAL OR

It would have to find each word in this text in a dictionary file such as this

YERKEY Y ER1 K IY0

YERMAN Y ER1 M AH0 N

YERXA Y ER1 K S AH0

YES Y EH1 S

YESES Y EH1 S IH0 Z

and report back all the terms with the pronunciation.

This is is a continuing of last semesters work I found a script one person created but when I run it its not outputting at all to the new file its only printing the first section on my terminal screen. I have never done perl scripting before and am trying to learn on the fly as the teacher won't help us out. Anything you guys could do would be immensely appreciated. Thanks

#!/usr/bin/perl if( $#ARGV != 2 ) { print "Compares the list of words in a file to the words in a dict +ionary 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 = <DICT_FILE>; close( DICT_FILE ); while( <WORD_FILE> ) { 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;

In reply to Matching Text by Chad C

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.