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.
'07125096-n' => [ ['07128527-n', 'hype'], ..... ]
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.

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)

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";
I put sample text file at here.

regards.


In reply to Loading 283600 records (WordNet) by remiah

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.