That's exactly what I was looking for!

As a purely academic exercise do you have any pointers on how to make a 
Fragmenter that displays text before the match? Can Lucene backtrack? I've 
glanced at Token and saw that it had a StartOffset member. I can't think of a 
use for such a Fragmenter...just curious.



----- Original Message ----
From: Michael Mitiaguin <[EMAIL PROTECTED]>
To: lucene-net-user@incubator.apache.org
Sent: Monday, October 6, 2008 1:33:52 AM
Subject: Re: How to make Highlighter return more pre and post text of a 
fragment?

Ron,

Have a look at
http://www.archivum.info/[EMAIL PROTECTED]/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 <[EMAIL PROTECTED]>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
>
>

Reply via email to