예제 #1
0
        public virtual void  TestOffsets()
        {
            TokenStream     stream    = new KeywordAnalyzer().TokenStream("field", new System.IO.StringReader("abcd"));
            OffsetAttribute offsetAtt = (OffsetAttribute)stream.AddAttribute(typeof(OffsetAttribute));

            Assert.IsTrue(stream.IncrementToken());
            Assert.AreEqual(0, offsetAtt.StartOffset());
            Assert.AreEqual(4, offsetAtt.EndOffset());
        }
        internal override void  NewTerm(RawPostingList p0)
        {
            System.Diagnostics.Debug.Assert(docState.TestPoint("TermVectorsTermsWriterPerField.newTerm start"));

            TermVectorsTermsWriter.PostingList p = (TermVectorsTermsWriter.PostingList)p0;

            p.freq = 1;

            if (doVectorOffsets)
            {
                int startOffset = fieldState.offset + offsetAttribute.StartOffset();;
                int endOffset   = fieldState.offset + offsetAttribute.EndOffset();

                termsHashPerField.WriteVInt(1, startOffset);
                termsHashPerField.WriteVInt(1, endOffset - startOffset);
                p.lastOffset = endOffset;
            }

            if (doVectorPositions)
            {
                termsHashPerField.WriteVInt(0, fieldState.position);
                p.lastPosition = fieldState.position;
            }
        }
예제 #3
0
 public override bool IncrementToken()
 {
     if (Lucene.Net.QueryParsers.TestMultiAnalyzer.multiToken > 0)
     {
         termAtt.SetTermBuffer("multi" + (Lucene.Net.QueryParsers.TestMultiAnalyzer.multiToken + 1));
         offsetAtt.SetOffset(prevStartOffset, prevEndOffset);
         typeAtt.SetType(prevType);
         posIncrAtt.SetPositionIncrement(0);
         Lucene.Net.QueryParsers.TestMultiAnalyzer.multiToken--;
         return(true);
     }
     else
     {
         bool next = input.IncrementToken();
         if (next == false)
         {
             return(false);
         }
         prevType        = typeAtt.Type();
         prevStartOffset = offsetAtt.StartOffset();
         prevEndOffset   = offsetAtt.EndOffset();
         System.String text = termAtt.Term();
         if (text.Equals("triplemulti"))
         {
             Lucene.Net.QueryParsers.TestMultiAnalyzer.multiToken = 2;
             return(true);
         }
         else if (text.Equals("multi"))
         {
             Lucene.Net.QueryParsers.TestMultiAnalyzer.multiToken = 1;
             return(true);
         }
         else
         {
             return(true);
         }
     }
 }