in reply to Text::Context or alternatives?
This seems to provide more context (no pun intended) for the code snippet you showed:
for my $word (@{ $self->{keywords} }) { my $word_score = 0; $word_score += 1 + ($content =~ tr/ / /) if $content =~ /\b\Q$ +word\E\b/i; $matches{$word} = $word_score; }
That seems to be iterating over the list of keywords, and calculating a score per keyword.
It might be that the same could be accomplished with greater efficiency if the algorithm were turned onto the words in $content rather than the keywords, and then determine if each word in $content matches a keyword from the hash. If so, then apply the tr/// count.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Text::Context or alternatives?
by moritz (Cardinal) on Nov 09, 2011 at 08:41 UTC | |
by Dave Howorth (Scribe) on Nov 09, 2011 at 11:00 UTC | |
by Dave Howorth (Scribe) on Nov 10, 2011 at 11:03 UTC | |
|
Re^2: Text::Context or alternatives?
by Dave Howorth (Scribe) on Nov 08, 2011 at 17:21 UTC | |
by davido (Cardinal) on Nov 08, 2011 at 22:37 UTC | |
by Dave Howorth (Scribe) on Nov 09, 2011 at 09:38 UTC |