Connecting Tech Pros Worldwide Help | Site Map

out of memory in Perl Builder

  #1  
Old October 23rd, 2008, 04:53 PM
Newbie
 
Join Date: Sep 2008
Posts: 30
Hi, I am writing a word stemming program, the program reads from a *.trec file to get query words in <title></title> tag, then stems the query words and output the result to another *.trec file. But perl builder promts "out of memory":
Expand|Select|Wrap|Line Numbers
  1. use stem;
  2. use WordNet::QueryData;
  3.  
  4. $wn = WordNet::QueryData->new;
  5. $stemmer = stem->new($wn);
  6.  
  7.  
  8. my $topic= "D:\\Program Files\\Perl Builder2\\MYPERL\\TrainingTopics.trec";
  9. my $mytopic="D:\\Program Files\\Perl Builder2\\MYPERL\\myTopics.trec";
  10. open FILE,"$topic" or die $!;
  11. open MYTOPIC,">$mytopic" or die $!;
  12.  
  13. while(my $file=<FILE>)
  14. {
  15.     if($file=~/<title>(.+?)<\/title>/)
  16.     {
  17.         print MYTOPIC &stemming($file);
  18.  
  19.     }
  20.     else
  21.     {
  22.        print MYTOPIC $file;
  23.     }                              
  24. }
  25.  
  26.  
  27.  
  28. sub stemming
  29. {
  30.      my $in = shift;
  31.     my $out = '';
  32.  
  33.     foreach my $token (split /[ ,.:;?!]/, $in)
  34.     {
  35.  
  36.           my @stems = $stemmer->stemWord($token);
  37.  
  38.              $out .= $stems[0] . ' ';
  39.  
  40.     }
  41.      return $out;
  42. }
  43. close FILE;
  44. close MYTOPIC;
  45.  
Thanks a lot!
  #2  
Old October 23rd, 2008, 05:06 PM
numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,543

re: out of memory in Perl Builder


Well, you aren't slurping the file into an array so the size of the file shouldn't make a difference so much.

It makes me wonder how much system memory you have and how many programs are running on your machine. If that it not it, then you will probably need to take this to the PerlBuilder forums as it would be outside of the realms of Perl coding.

Regards,

Jeff

**Note: are you trying to run this from Perl Builder? If so, why not run the script from the command line instead? I personally never trust a program to run my Perl script. I would rather the interpreter do it directly, without a middle man so to speak. As you can see, they always seem to find a way to cause issues.

Regards,

Jeff

Last edited by numberwhun; October 23rd, 2008 at 05:07 PM. Reason: additional information
  #3  
Old October 23rd, 2008, 06:36 PM
KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,097

re: out of memory in Perl Builder


Jeff.... Perl Builder is an IDE (its the one I use), it uses perl to run your perl programs same as any IDE.

That script looks like it would use very little memory so I don't know why its running out of memeory unless that module you are using has some known issues. WordNet::QueryData queries a database, that is possibly where the memory problem is happening. Not sure what to suggest though.
  #4  
Old October 23rd, 2008, 06:55 PM
numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,543

re: out of memory in Perl Builder


Quote:
Originally Posted by KevinADC
Jeff.... Perl Builder is an IDE (its the one I use), it uses perl to run your perl programs same as any IDE.
Oh, ok. Sorry, wasn't aware. I tend to hand code everything and run from the command line. If I do use an IDE, I use either Eclipse (with EPIC plugin for Perl) or Komodo. Both are awesome.

Well, now I know. :)
  #5  
Old October 23rd, 2008, 07:07 PM
Ganon11's Avatar
Moderator
 
Join Date: Oct 2006
Location: New York, United States of America
Posts: 3,444

re: out of memory in Perl Builder


Quote:
Originally Posted by numberwhun
Oh, ok. Sorry, wasn't aware. I tend to hand code everything and run from the command line. If I do use an IDE, I use either Eclipse (with EPIC plugin for Perl) or Komodo. Both are awesome.

Well, now I know. :)
I'm with you, Numberwhun. Notepad++ to edit, cmd.exe to run.
  #6  
Old October 23rd, 2008, 07:27 PM
KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,097

re: out of memory in Perl Builder


Writing simple scripts in a text editor is fine, but using an IDE is essential to any complex code and even not so complex. You can run syntax checks, pipe data in/out of a script (command line or CGI), write and test code on the fly, use the perl debugger in the IDE, step over code, step into code, run timers , pause a script, see and jump to any subroutine in a single glance (may vary IDE to IDE) see all the variables used in a script (may vary IDE to IDE), and much more.

With the IDE you can open multiple scripts and select the one to run and check the output too, all on the fly if you wanted to.

Make your life easier and use an IDE.

In Perl Builder all the builtin perl functions display a basic syntax usage next to the function if you want it to. So you see something like:

split

(this displays in a little window next to the function)
split /PATTERN/,EXPR,LIMIT
split /PATTERN/,EXPR
split /PATTERN/

No need to look at the documentation if you foget the simple usage syntax. That right there is such a big time saver. And if you wanted to read the entire documentation you just click on the little window and a bigger window pops up with the full perl manpage for the function.
  #7  
Old October 24th, 2008, 12:11 AM
numberwhun's Avatar
Site Moderator
 
Join Date: May 2007
Location: New Hampshire
Posts: 2,543

re: out of memory in Perl Builder


Wow, didn't mean to kick you up onto your soap box (j/k). I never said I didn't use an IDE. Komodo has always been my editor of choice but have been playing more with Epic (Eclipse) due to its interesting regex tester.

I agree with you that an IDE is a very useful part of Perl coding, but its not something you cannot live without. The software I support at work is all supported without an IDE, using GVim alone. Some of the files that we make additions to are several thousand lines or more in length.

Regards,

Jeff
  #8  
Old October 24th, 2008, 12:53 AM
Icecrack's Avatar
Expert
 
Join Date: Sep 2008
Location: Sydney, Australia
Posts: 172

re: out of memory in Perl Builder


i use Crimson Editor for my Perl Coding + other Languages. (FREE WARE)
i did use Perl Builder
  #9  
Old October 24th, 2008, 01:05 AM
KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,097

re: out of memory in Perl Builder


Did I forget to mention I work for PerlBuilder? J/K..... I just had too much coffee this morning.
  #10  
Old October 24th, 2008, 01:29 AM
Ganon11's Avatar
Moderator
 
Join Date: Oct 2006
Location: New York, United States of America
Posts: 3,444

re: out of memory in Perl Builder


Quote:
Originally Posted by KevinADC
Did I forget to mention I work for PerlBuilder? J/K..... I just had too much coffee this morning.
*Dare I ask?* What IDE do you suggest? Is PerlBuilder free?
  #11  
Old October 24th, 2008, 01:58 AM
Newbie
 
Join Date: Sep 2008
Posts: 30

re: out of memory in Perl Builder


Quote:
Originally Posted by KevinADC
Jeff.... Perl Builder is an IDE (its the one I use), it uses perl to run your perl programs same as any IDE.

That script looks like it would use very little memory so I don't know why its running out of memeory unless that module you are using has some known issues. WordNet::QueryData queries a database, that is possibly where the memory problem is happening. Not sure what to suggest though.
It has no problem when I just convert one word to its stemming words, but when I try to stemming a number of words from a file, the "out of memory" occurs. I think its probably because the wordnet's database 2. I dont know much about how the database works, hope anyone can give me more suggestion.

PS: You guys are friendly and funny, thank you!
  #12  
Old October 24th, 2008, 02:29 AM
Newbie
 
Join Date: Sep 2008
Posts: 30

re: out of memory in Perl Builder


Since there is no WordNet 3.0 for windows, I download the WordNet 2.1 and change its name to WordNet 3.0... As I said, there was no problem to convert one word to its semming word.
  #13  
Old October 24th, 2008, 03:14 AM
Newbie
 
Join Date: Sep 2008
Posts: 30

re: out of memory in Perl Builder


I find a problem in my program.

Expand|Select|Wrap|Line Numbers
  1. if($file=~/<title>(.+?)<\/title>/)
  2.  
I thinks this sentence shoud pick the content between the tag <title></title>,
not containing the tag itself. But I test my program and I find the tag is contained in my first split word. For example, <title>perl bulider</title>, the first word is "<title>perl" not "perl"
  #14  
Old October 24th, 2008, 03:31 AM
KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,097

re: out of memory in Perl Builder


The regexp is probably OK:

Expand|Select|Wrap|Line Numbers
  1. my $file = "test <title>Perl Builder<\/title> test";
  2. if ($file =~ /<title>(.+?)<\/title>/) {
  3.    print $1;
  4. }
I think the problem is here:

Expand|Select|Wrap|Line Numbers
  1. foreach my $token (split /[ ,.:;?!]/, $in)
There is nothing in the above regexp (split) to split the string into tokens except a space. So it gets split into "<title>Perl" and "Builder<\/title>".
  #15  
Old October 24th, 2008, 05:08 AM
Newbie
 
Join Date: Sep 2008
Posts: 30

re: out of memory in Perl Builder


Quote:
Originally Posted by KevinADC
The regexp is probably OK:

Expand|Select|Wrap|Line Numbers
  1. my $file = "test <title>Perl Builder<\/title> test";
  2. if ($file =~ /<title>(.+?)<\/title>/) {
  3.    print $1;
  4. }
I think the problem is here:

Expand|Select|Wrap|Line Numbers
  1. foreach my $token (split /[ ,.:;?!]/, $in)
There is nothing in the above regexp (split) to split the string into tokens except a space. So it gets split into "<title>Perl" and "Builder<\/title>".
I see your point, you are right! Thank you very much!!
  #16  
Old October 24th, 2008, 06:24 AM
KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,097

re: out of memory in Perl Builder


Quote:
Originally Posted by anklos
I see your point, you are right! Thank you very much!!
You're welcome
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
vb.net vs c#.net, the SQL Saga answers 5 November 16th, 2005 06:37 AM
Firebird and PostgreSQL at the DB Corral. Paul Ganainm answers 29 November 12th, 2005 01:19 AM
Object test = new Object() <-- Java, best way in C++ DrUg13 answers 11 July 22nd, 2005 07:06 AM
benchmarks and questions for new python programmer stormslayer answers 7 July 18th, 2005 11:59 AM