You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Ron Grabowski <ro...@yahoo.com> on 2008/10/06 06:40:09 UTC
How to make Highlighter return more pre and post text of a fragment?
Is there a way to configure Highlighter to return more pre and post text? For example suppose I'm searching text for "bank" from Alice in Wonderland:
her sister
on the *bank*, and of having nothing
I would like to get more post and pre text from my result:
Alice was beginning to get very tired of sitting by her sister
on the *bank*, and of having nothing to do: once or twice she had
peeped into the book her sister was reading, but it had
I've tried various calls to GetBestFragments:
string[] highlightedFragments = highlighter.GetBestFragments(new StandardAnalyzer(), aliceInWonderland, 1);
including bumping the 1 parameter to a larger number but the returned array only has one item in it. I'm not looking for other matches in the text; I want to expand the best matched fragment to give the user more context about the match.
Thanks,
Ron
Re: How to make Highlighter return more pre and post text of a fragment?
Posted by Michael Mitiaguin <mi...@gmail.com>.
Ron,
Have a look at
http://www.archivum.info/java-dev@lucene.apache.org/2008-01/msg00111.html
Probably you need to do similar changes if you want greater control of
fragments or at least instantiate Fragmenter with a parameter ( fragment
size) which should call a respective constructor.
public class SimpleFragmenter : Fragmenter
{
private const int DEFAULT_FRAGMENT_SIZE = 100;
private int currentNumFrags;
private int fragmentSize;
public SimpleFragmenter():this(DEFAULT_FRAGMENT_SIZE)
{
}
/// <summary> </summary>
/// <param name="fragmentSize">size in bytes of each fragment
/// </param>
public SimpleFragmenter(int fragmentSize)
{
this.fragmentSize = fragmentSize;
}
Regards
Michael
On Mon, Oct 6, 2008 at 4:40 PM, Ron Grabowski <ro...@yahoo.com>wrote:
> Is there a way to configure Highlighter to return more pre and post text?
> For example suppose I'm searching text for "bank" from Alice in Wonderland:
>
> her sister
> on the *bank*, and of having nothing
>
> I would like to get more post and pre text from my result:
>
> Alice was beginning to get very tired of sitting by her sister
> on the *bank*, and of having nothing to do: once or twice she had
> peeped into the book her sister was reading, but it had
>
> I've tried various calls to GetBestFragments:
>
> string[] highlightedFragments = highlighter.GetBestFragments(new
> StandardAnalyzer(), aliceInWonderland, 1);
>
> including bumping the 1 parameter to a larger number but the returned array
> only has one item in it. I'm not looking for other matches in the text; I
> want to expand the best matched fragment to give the user more context about
> the match.
>
> Thanks,
> Ron
>
>