Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

In reply to Re^3: makeing refering faster ? by perldeveloper
in thread makeing refering faster ? by chiburashka

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (1)
As of 2024-04-19 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found