The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl question regarding [ ] hankooknara Shell Programming and Scripting 2 07-01-2007 01:21 PM
perl question BG_JrAdmin Shell Programming and Scripting 1 09-09-2005 04:46 PM
Perl Question Gary Dunn Shell Programming and Scripting 2 12-03-2004 09:37 AM
PERL question frank Shell Programming and Scripting 1 06-18-2002 12:13 AM
Perl question Jubba Shell Programming and Scripting 1 04-01-2002 11:24 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-05-2005
Registered User
 

Join Date: Oct 2005
Posts: 29
PERL question

im trying to retrieve text in between <title> tags of a tagged document, store the text in a temporary file, feed that file into a porter stemmer program, capture the stemmer's output by piping it into an output file, then reconstructing the original tagged document but with the text in <title></title> stemmed.

my problem is that it doesn't run as i expect it to run. im suspecting
that its either the system"" call that's at fault or the temp file themselves..
any help would be greatly appreciated! thanks!

here's the code snippet...

Code:
# read through the tagged document
while (<TOPIC_ORIG>) {
        if (/<title>(.+?)<\/title>/) {
                
                print TOPIC_TEMP "<title>";

                # file to store text between <title> tags prior to stemming
                $INFILE = ">$HOME/bin/stem.in";
                open INFILE or die;
                 
                # file to store output of stemmer
                $OUTFILE = ">$HOME/bin/stem.out";
                open OUTFILE or die;

                # store pre-processed text in stem.in
                print INFILE "$1";
                 
                 # run stemmer
                 system "$HOME/bin/porter-stemmer $HOME/bin/stem.in > $HOME/bin/stem.out";

                # retrieve stemmed text in output file, write to TOPIC_TEMP
                # between title tags.
                while (<OUTFILE>) {
                            print TOPIC_TEMP;
                } 

                # print end-tag
                print TOPIC_TEMP "</title>";

                # close temp files
                close INFILE;
                close OUTFILE;
        } else {
                 #output all other tags and contents
                print TOPIC_TEMP;

        }
}

close TOPIC_ORIG;
close TOPIC_TEMP;
tagged-document sample
Code:
<doc>
<title>some title</title>
..........
</doc>
Reply With Quote
Forum Sponsor
  #2  
Old 10-05-2005
Registered User
 

Join Date: May 2005
Posts: 27
Just looking at the code it looks like your handle for input is directed for output. $INFILE = ">$HOME/bin/stem.in";
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0