This software allows users to retrieve a specific number of words found before and after designated search keywords from a text document.
To use it, simply add "use Text::Context::EitherSide" to your code and implement the following code:
- "my $text" ... "Text::Context::EitherSide->new($text);"
- "$context→as_string("fox")" or "$context→as_string("fox", "jumped")", depending on the amount of context you require.
If you would rather forgo object-oriented code, utilize the "get_context" function. Use this by declaring "use Text::Context::EitherSide qw(get_context);" and adding "get_context(1, $text, "fox", "jumped", "dog")" to your code.
The module is smart enough to ensure the list does not overlap. For example, if your text reads "the quick brown fox jumped over the lazy dog" and you extract two words either side of "fox", "jumped", and "dog," Text::Context::EitherSide will make sure you do not end up with something like "quick brown fox jumped over brown fox jumped over the lazy dog."
Overall, Text::Context::EitherSide is a valuable tool for anyone who often works with large pieces of text and needs to display context without manually extracting multiple words.
Version 1.4: N/A