lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Harwood (JIRA)" <>
Subject [jira] Commented: (LUCENE-627) highlighter problems with overlapping tokens
Date Thu, 13 Jul 2006 22:11:30 GMT
    [ ] 

Mark Harwood commented on LUCENE-627:

>>The original token stream is a valid one though right? 

I don't think so, see below...

       List lst = new ArrayList(); 
        Token t; 
        t = new Token("i",0,1); 
        t = new Token("pod",1,4); 
        t = new Token("ipod",0,4); 
!! Missing a t.setPositionIncrement(0) here.
        t = new Token("foo",5,8); 
        iter = lst.iterator(); 

Having fixed the above I believe this change below is all that is required to fix the highlighter:

	boolean isDistinct(Token token)
//		return token.startOffset()>=endOffset;
		return token.getPositionIncrement()>0;

All my Junit  tests pass with this change - can you verify this is true for you too?
This change would break highlighting for any analyzers that had position increments but whose
offsets somehow overlapped - text would potentially be duplicated in the same way you originally
reported your problem. I can't verify this to be true for CJK analyzers etc so feel a little
uneasy about committing this. 


> highlighter problems with overlapping tokens
> --------------------------------------------
>          Key: LUCENE-627
>          URL:
>      Project: Lucene - Java
>         Type: Bug

>   Components: Other
>     Versions: 2.0.1
>     Reporter: Yonik Seeley

> The lucene highlighter has problems when tokens that overlap are generated.
> For example, if analysis of iPod generates the tokens "i", "pod", "ipod" (with pod and
ipod in the same position),
> then the highlighter will output this as iipod, regardless of if any of those tokens
are highlighted.
> Discovered via

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message