Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: makeing refering faster ?

by perldeveloper (Scribe)
on Aug 16, 2004 at 15:23 UTC ( [id://383328]=note: print w/replies, xml ) Need Help??


in reply to Re^2: makeing refering faster ?
in thread makeing refering faster ?

Well, I'm answering now... You'd need to change the code to place information about the words that bind the sentences among each other inside the @temp array. This means something like this:
my %referencedSentences = (); foreach my $j (@{$words[$i]}) { if (($j ne "$j") || ($j ne "v")) { if (exists $sentences->{$j}) { %referencedSentences{%j} = $sentences->{$j}; } } } push (@temp, \%referencedSentences);
So, to clarify, here is the logical structure of the @temp array:
  • @temp contains the sentence no. i at position 2 * i and a hash indexed by words that other sentences start with at position 2 * i + 1. Assume sentence my $sentence = $temp[2 * 10] and its hash my $hash = $temp[2 * 10 + 1]
  • The hash contains all words in the sentence that other sentences start with. You can get a list of these words like this: my @listOfWordsOtherSentencesStartWith = keys %{$hash}. Say a word (my $word) belongs to this list of words. Then, $hash->{$word} returns a reference to an array that contains the indices (starting from 0) of all sentences that start with word $word. So to get a list of these sentences, you'd write: my @listOfSentencesThatStartWithThisWord = @{$hash->{$word}}
  • To get a list of all sentences referenced by a sentence, you'd write something like
    my @list; foreach my $refToIndicesArray (values %{$hash}) { push (@list, @{$refToIndicesArray}); }
I hope that answers your questions and good luck with your Perl project. Don't hesitate to ask again, though.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://383328]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-16 18:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found