lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven A Rowe <sar...@syr.edu>
Subject RE: FastVectorHighlighter StringIndexOutofBounds bug
Date Mon, 23 May 2011 05:34:45 GMT
Hi WeiWei,

Thanks for the report. 

Can you provide a self-contained unit test that triggers the bug?

Thanks,
Steve

> -----Original Message-----
> From: Weiwei Wang [mailto:ww.wang.cs@gmail.com]
> Sent: Monday, May 23, 2011 1:25 AM
> To: java-user@lucene.apache.org
> Subject: FastVectorHighlighter StringIndexOutofBounds bug
> 
> the following code has a bug of StringIndexOutofBounds when multiple
> matched
> terms need highlight
> 
> private String makeFragment( WeightedFragInfo fragInfo, String src, int
> s,
>       String[] preTags, String[] postTags, Encoder encoder ){
>     StringBuilder fragment = new StringBuilder();
>     int srcIndex = 0;
>     for( SubInfo subInfo : fragInfo.subInfos ){
>       for( Toffs to : subInfo.termsOffsets ){
>         fragment
>           .append( encoder.encodeText( src.substring( srcIndex,
> to.startOffset - s ) ) )
>           .append( getPreTag( preTags, subInfo.seqnum ) )
>           .append( encoder.encodeText( src.substring( to.startOffset - s,
> to.endOffset - s ) ) )
>           .append( getPostTag( postTags, subInfo.seqnum ) );
>         srcIndex = to.endOffset - s;
>       }
>     }
>     fragment.append( encoder.encodeText( src.substring( srcIndex ) ) );
>     return fragment.toString();
>   }--
> 王巍巍
> Cell: 18911288489
> MSN: ww.wang.cs@gmail.com
> Blog: http://whisper.eyesay.org
> 围脖:http://t.sina.com/lolorosa
Mime
View raw message