Text::Context::EitherSide

Get n words either side of search keywords
Download

Text::Context::EitherSide Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Tony Bowden
  • Publisher web site:
  • http://search.cpan.org/~sri/

Text::Context::EitherSide Tags


Text::Context::EitherSide Description

Get n words either side of search keywords Text::Context::EitherSide is a Perl module to get n words either side of search keywords.SYNOPSIS use Text::Context::EitherSide; my $text = "The quick brown fox jumped over the lazy dog"; my $context = Text::Context::EitherSide->new($text); $context->as_string("fox") # "... quick brown fox jumped over ..." $context->as_string("fox", "jumped") # "... quick brown fox jumped over the ..." my $context = Text::Context::EitherSide->new($text, context => 1); # 1 word on either side $context->as_string("fox", "jumped", "dog"); # "... brown fox jumped over ... lazy dog",Or, if you don't believe in all this OO rubbish: use Text::Context::EitherSide qw(get_context); get_context(1, $text, "fox", "jumped", "dog") # "... brown fox jumped over ... lazy dog"Suppose you have a large piece of text - typically, say, a web page or a mail message. And now suppose you've done some kind of full-text search on that text for a bunch of keywords, and you want to display the context in which you found the keywords inside the body of the text.A simple-minded way to do that would be just to get the two words either side of each keyword. But hey, don't be too simple minded, because you've got to make sure that the list doesn't overlap. If you have the quick brown fox jumped over the lazy dogand you extract two words either side of "fox", "jumped" and "dog", you really don't want to end up with quick brown fox jumped over brown fox jumped over the the lazy dogso you need a small amount of smarts. This module has a small amount of smarts. Requirements: · Perl


Text::Context::EitherSide Related Software