remiah has asked for the wisdom of the Perl Monks concerning the following question:
Hello perl monk.
This is "synlink" table of WordNet. Like this.
synset1 synset2 link 07125096-n 07128527-n hype 07126228-n 07109847-n hype ...I thought I would like to overview how synsets link each other. For that, I have to do a recursive call and it took too much cost for querying SQLite each time, so I load it to a hash like this.
When I load it from database, it took about 3.6 secs. And I found loading from text file is far faster, and it took about 1.2 secs. Here I almost satisfied, but I would like to ask for monk's wisdom.'07125096-n' => [ ['07128527-n', 'hype'], ..... ]
My Question is: 1) Is there a faster way ? 2) Please give me advice when you have experience for wordnet.
My fastest script is simple like below.(commented out for HiRes wrapping my time module)
I put sample text file at here.use strict; use warnings; #use Data::Dumper; #use MyTime; my $href={}; #my $timeinf=MyTime->new(); #$timeinf->push('before open'); open(my $fh, "<", "04.txt") or die $!; while(<$fh>){ chomp; push @{ $href->{ substr($_,0,10)} }, [ substr($_,10,10), subst +r($_,20)]; } close $fh; #$timeinf->push('after load'); #print $timeinf->as_string; print "count=", scalar keys %{$href} ,"\n"; #print "test item:" , Dumper $href->{'01785341-a'} , "\n\n";
regards.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Loading 283600 records (Updated)
by BrowserUk (Patriarch) on Sep 22, 2012 at 13:30 UTC | |
by remiah (Hermit) on Sep 23, 2012 at 02:28 UTC | |
by BrowserUk (Patriarch) on Sep 23, 2012 at 16:05 UTC | |
by remiah (Hermit) on Sep 23, 2012 at 23:10 UTC | |
by Anonymous Monk on Sep 24, 2012 at 03:57 UTC | |
by remiah (Hermit) on Sep 24, 2012 at 10:31 UTC | |
Re: Loading 283600 records (WordNet)
by dsheroh (Monsignor) on Sep 23, 2012 at 09:48 UTC | |
by remiah (Hermit) on Sep 23, 2012 at 11:26 UTC | |
by remiah (Hermit) on Sep 24, 2012 at 10:25 UTC | |
by BrowserUk (Patriarch) on Sep 24, 2012 at 10:45 UTC |
Back to
Seekers of Perl Wisdom