Floyd,

This bug would affect applications using the optional "term vectors" for 
judging the degree similarity between a group of search results.

In a quick survey of the source it seems this problem would only be a concern 
if your application uses SegmentTermPostionVector, SegmentTermVector, 
TermFreqVector, or QueryTermVector.


-- Neal

-----Original Message-----
From: Floyd Wu [mailto:[email protected]]
Sent: Sunday, May 31, 2009 9:18 PM
To: [email protected]
Subject: Re: bug in SegmentTermVector.IndexOf ?

Hi there,

What is the primary effects of this bug?

Floyd

2009/5/30 Franklin Simmons <[email protected]>

> Greetings,
>
>
>
> I hope I have this all wrong;  I haven't seen this issue raised.
>
>
>
> At index time term vectors are sorted using String.CompareOrdinal.
> However method IndexOf  of class SegmentTermVector invokes
> System.Array.BinarySearch, which is using String.Compare:
>
>
>
> public virtual int IndexOf(System.String termText)
>
> {
>
>                                if (terms == null)
>
>                                                return - 1;
>
> int res = System.Array.BinarySearch(terms, termText);
>
> return res >= 0 ? res : - 1;
>
> }
>
>
>
>
>
> As implemented this method always (for me, anyway) returns a negative
> number.  The modification below works, but I need to know if this is
> actually a bug and if so, what is the correct fix.
>
>
>
>
>
> public class SegmentTermVector : TermFreqVector
>
> {
>
>                . . .
>
>
>
> private class TermVectorComparer : System.Collections.IComparer
>
> {
>
> public int Compare(object a, object b)
>
> {
>
> return String.CompareOrdinal((string)a, (string)b);
>
> }
>
> }
>
>
>
> public virtual int IndexOf(System.String termText)
>
> {
>
>                                if (terms == null)
>
>                                                return - 1;
>
> int res = System.Array.BinarySearch(terms, termText, new
> TermVectorComparer());
>
> return res >= 0 ? res : - 1;
>
> }
>
>
>
> . . .
>
> }
>
>
>
>
>
> Franklin Simmons
>
>
>
>

Reply via email to