Example #1
0
            public override bool Accept(AttributeSource a)
            {
                bool b = (a != null && count % modCount == 0);

                count++;
                return(b);
            }
Example #2
0
 private TokenWrapper InitTokenWrapper(AttributeSource input)
 {
     if (onlyUseNewAPI)
     {
         // no wrapper needed
         return(null);
     }
     else
     {
         // if possible get the wrapper from the filter's input stream
         if (input is TokenStream && ((TokenStream)input).tokenWrapper != null)
         {
             return(((TokenStream)input).tokenWrapper);
         }
         // check that all attributes are implemented by the same TokenWrapper instance
         Attribute att = AddAttribute(typeof(TermAttribute));
         if (att is TokenWrapper && AddAttribute(typeof(TypeAttribute)) == att && AddAttribute(typeof(PositionIncrementAttribute)) == att && AddAttribute(typeof(FlagsAttribute)) == att && AddAttribute(typeof(OffsetAttribute)) == att && AddAttribute(typeof(PayloadAttribute)) == att)
         {
             return((TokenWrapper)att);
         }
         else
         {
             throw new System.NotSupportedException("If onlyUseNewAPI is disabled, all basic Attributes must be implemented by the internal class " + "TokenWrapper. Please make sure, that all TokenStreams/TokenFilters in this chain have been " + "instantiated with this flag disabled and do not add any custom instances for the basic Attributes!");
         }
     }
 }
Example #3
0
 /// <summary>
 /// Returns the related attributes. </summary>
 public virtual AttributeSource Attributes()
 {
     if (Atts == null)
     {
         Atts = new AttributeSource();
     }
     return(Atts);
 }
Example #4
0
 /// <summary>
 /// Returns the related attributes. </summary>
 public virtual AttributeSource Attributes()
 {
     if (Atts == null)
     {
         Atts = new AttributeSource();
     }
     return Atts;
 }
Example #5
0
		/// <summary> Re-initialize the state, using this boost value.</summary>
		/// <param name="docBoost">boost value to use.
		/// </param>
		internal void  Reset(float docBoost)
		{
			position = 0;
			length = 0;
			numOverlap = 0;
			offset = 0;
			boost = docBoost;
			attributeSource = null;
		}
Example #6
0
 /// <summary> Expert: Creates a token stream for numeric values with the specified
 /// <c>precisionStep</c> using the given <see cref="AttributeSource" />.
 /// The stream is not yet initialized,
 /// before using set a value using the various set<em>???</em>Value() methods.
 /// </summary>
 public NumericTokenStream(AttributeSource source, int precisionStep) : base(source)
 {
     InitBlock();
     this.precisionStep = precisionStep;
     if (precisionStep < 1)
     {
         throw new System.ArgumentException("precisionStep must be >=1");
     }
 }
 /// <summary> Re-initialize the state, using this boost value.</summary>
 /// <param name="docBoost">boost value to use.
 /// </param>
 internal void  Reset(float docBoost)
 {
     position        = 0;
     length          = 0;
     numOverlap      = 0;
     offset          = 0;
     boost           = docBoost;
     attributeSource = null;
 }
Example #8
0
 /// <summary>
 /// Re-initialize the state
 /// </summary>
 internal void Reset()
 {
     position         = 0;
     length           = 0;
     numOverlap       = 0;
     offset           = 0;
     maxTermFrequency = 0;
     uniqueTermCount  = 0;
     boost            = 1.0f;
     attributeSource  = null;
 }
Example #9
0
 /// <summary>
 /// Re-initialize the state
 /// </summary>
 internal void Reset()
 {
     Position_Renamed = 0;
     Length_Renamed = 0;
     NumOverlap_Renamed = 0;
     Offset_Renamed = 0;
     MaxTermFrequency_Renamed = 0;
     UniqueTermCount_Renamed = 0;
     Boost_Renamed = 1.0f;
     AttributeSource_Renamed = null;
 }
Example #10
0
 /// <summary>
 /// Re-initialize the state
 /// </summary>
 internal void Reset()
 {
     Position_Renamed         = 0;
     Length_Renamed           = 0;
     NumOverlap_Renamed       = 0;
     Offset_Renamed           = 0;
     MaxTermFrequency_Renamed = 0;
     UniqueTermCount_Renamed  = 0;
     Boost_Renamed            = 1.0f;
     AttributeSource_Renamed  = null;
 }
Example #11
0
		/// <summary>Construct a token stream processing the given input using the given AttributeSource. </summary>
		protected internal Tokenizer(AttributeSource source):base(source)
		{
		}
Example #12
0
 public CharTokenizer(AttributeSource source, System.IO.TextReader input) : base(source, input)
 {
     offsetAtt = (OffsetAttribute)AddAttribute(typeof(OffsetAttribute));
     termAtt   = (TermAttribute)AddAttribute(typeof(TermAttribute));
 }
Example #13
0
 public override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts)
 {
     return new SimpleAutomatonTermsEnum(this, terms.Iterator(null));
 }
 /// <summary>Construct a new LowerCaseTokenizer using a given {@link AttributeSource}. </summary>
 public LowerCaseTokenizer(AttributeSource source, System.IO.TextReader in_Renamed) : base(source, in_Renamed)
 {
 }
Example #15
0
 public KeywordTokenizer(AttributeSource source, System.IO.TextReader input, int bufferSize) : base(source, input)
 {
     Init(bufferSize);
 }
Example #16
0
		/// <summary> A TokenStream that uses the same attributes as the supplied one.</summary>
		protected internal TokenStream(AttributeSource input):base(input)
		{
			InitBlock();
			tokenWrapper = InitTokenWrapper(input);
			Check();
		}
 /// <summary> Creates a new StandardTokenizer with a given {@link AttributeSource}. </summary>
 public StandardTokenizer(AttributeSource source, System.IO.TextReader input, bool replaceInvalidAcronym)
     : base(source)
 {
     InitBlock();
     this.scanner = new StandardTokenizerImpl(input);
     Init(input, replaceInvalidAcronym);
 }
Example #18
0
 /// <summary> Creates a new StandardTokenizer with a given {@link AttributeSource}.</summary>
 public StandardTokenizer(Version matchVersion, AttributeSource source, System.IO.TextReader input) : base(source)
 {
     InitBlock();
     this.scanner = new StandardTokenizerImpl(input);
     Init(input, matchVersion);
 }
Example #19
0
 public StandardTokenizer(AttributeSource source, System.IO.TextReader input, bool replaceInvalidAcronym) : base(source)
 {
     InitBlock();
     this.scanner = new StandardTokenizerImpl(input);
     Init(input, replaceInvalidAcronym);
 }
Example #20
0
 /// <summary>Construct a new WhitespaceTokenizer using a given <see cref="AttributeSource" />. </summary>
 public WhitespaceTokenizer(AttributeSource source, System.IO.TextReader @in)
     : base(source, @in)
 {
 }
	    protected CharTokenizer(AttributeSource source, System.IO.TextReader input):base(source, input)
		{
            offsetAtt = AddAttribute<IOffsetAttribute>();
            termAtt = AddAttribute<ITermAttribute>();
		}
 /// <summary>Construct a new WhitespaceTokenizer using a given {@link AttributeSource}. </summary>
 public WhitespaceTokenizer(AttributeSource source, System.IO.TextReader in_Renamed) : base(source, in_Renamed)
 {
 }
 protected CharTokenizer(AttributeSource source, System.IO.TextReader input) : base(source, input)
 {
     offsetAtt = AddAttribute <IOffsetAttribute>();
     termAtt   = AddAttribute <ITermAttribute>();
 }
 public CharTokenizer(AttributeSource source, System.IO.TextReader input)
     : base(source, input)
 {
     offsetAtt = (OffsetAttribute) AddAttribute(typeof(OffsetAttribute));
     termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
 }
Example #25
0
		/// <summary> Creates a new StandardTokenizer with a given {@link AttributeSource}.</summary>
		public StandardTokenizer(Version matchVersion, AttributeSource source, System.IO.TextReader input):base(source)
		{
			InitBlock();
			this.scanner = new StandardTokenizerImpl(input);
			Init(input, matchVersion);
		}
 /*private*/
 internal bool Accept(AttributeSource source)
 {
     return filter.Accept(source);
 }
Example #27
0
 /// <summary>
 /// Construct the enumeration to be used, expanding the
 ///  pattern term.  this method should only be called if
 ///  the field exists (ie, implementations can assume the
 ///  field does exist).  this method should not return null
 ///  (should instead return <seealso cref="TermsEnum#EMPTY"/> if no
 ///  terms match).  The TermsEnum must already be
 ///  positioned to the first matching term.
 /// The given <seealso cref="AttributeSource"/> is passed by the <seealso cref="RewriteMethod"/> to
 /// provide attributes, the rewrite method uses to inform about e.g. maximum competitive boosts.
 /// this is currently only used by <seealso cref="TopTermsRewrite"/>
 /// </summary>
 public abstract TermsEnum GetTermsEnum(Terms terms, AttributeSource atts);
 public KeywordTokenizer(AttributeSource source, System.IO.TextReader input, int bufferSize)
     : base(source, input)
 {
     Init(bufferSize);
 }
			public override bool Accept(AttributeSource a)
			{
				TermAttribute termAtt = (TermAttribute) a.GetAttribute(typeof(TermAttribute));
				return termAtt.Term().ToUpper().Equals("Dogs".ToUpper());
			}
Example #30
0
 /// <summary> A TokenStream that uses the same attributes as the supplied one.</summary>
 protected internal TokenStream(AttributeSource input) : base(input)
 {
     InitBlock();
     tokenWrapper = InitTokenWrapper(input);
     Check();
 }
Example #31
0
 protected override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts)
 {
     return new SimpleAutomatonTermsEnum(this, terms.GetEnumerator());
 }
 public override bool Accept(AttributeSource a)
 {
     ITermAttribute termAtt = a.GetAttribute<ITermAttribute>();
     return termAtt.Term.ToUpper().Equals("Dogs".ToUpper());
 }
 public override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts)
 {
     return new TermRangeTermsEnumAnonymousInnerClassHelper(this, terms.Iterator(null), new BytesRef("2"), new BytesRef("7"));
 }
Example #34
0
 /// <summary>Construct a token stream processing the given input using the given AttributeSource. </summary>
 protected internal Tokenizer(AttributeSource source) : base(source)
 {
 }
Example #35
0
 /// <summary> Expert: Creates a token stream for numeric values with the specified
 /// <c>precisionStep</c> using the given <see cref="AttributeSource" />.
 /// The stream is not yet initialized,
 /// before using set a value using the various set<em>???</em>Value() methods.
 /// </summary>
 public NumericTokenStream(AttributeSource source, int precisionStep)
     : base(source)
 {
     InitBlock();
     this.precisionStep = precisionStep;
     if (precisionStep < 1)
         throw new System.ArgumentException("precisionStep must be >=1");
 }
            public override bool Accept(AttributeSource a)
            {
                TermAttribute termAtt = (TermAttribute)a.GetAttribute(typeof(TermAttribute));

                return(termAtt.Term().ToUpper().Equals("Dogs".ToUpper()));
            }
Example #37
0
 /// <summary>Construct a new LetterTokenizer using a given <see cref="AttributeSource" />. </summary>
 public LetterTokenizer(AttributeSource source, System.IO.TextReader @in)
     : base(source, @in)
 {
 }
			internal SinkTokenStream(AttributeSource source, SinkFilter filter)
                : base(source)
			{
				this.filter = filter;
			}
Example #39
0
		/// <summary>Construct a token stream processing the given input using the given AttributeSource. </summary>
		protected internal Tokenizer(AttributeSource source, System.IO.TextReader input):base(source)
		{
			this.input = CharReader.Get(input);
		}
			internal /*private*/ void  AddState(AttributeSource.State state)
			{
				if (it != null)
				{
					throw new System.SystemException("The tee must be consumed before sinks are consumed.");
				}
				cachedStates.AddLast(state);
			}
		/// <summary>Construct a new WhitespaceTokenizer using a given {@link AttributeSource}. </summary>
		public WhitespaceTokenizer(AttributeSource source, System.IO.TextReader in_Renamed):base(source, in_Renamed)
		{
		}
			public override bool Accept(AttributeSource source)
			{
				return true;
			}
 public override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts)
 {
     return new SimplePrefixTermsEnum(this, terms.Iterator(null), Prefix);
 }
 public override bool Accept(AttributeSource a)
 {
     bool b = (a != null && count % modCount == 0);
     count++;
     return b;
 }
Example #45
0
 /// <summary>Construct a token stream processing the given input using the given AttributeSource. </summary>
 protected internal Tokenizer(AttributeSource source, System.IO.TextReader input) : base(source)
 {
     this.input = CharReader.Get(input);
 }
Example #46
0
 /// <summary>
 /// Returns the <seealso cref="MultiTermQuery"/>s <seealso cref="TermsEnum"/> </summary>
 /// <seealso cref= MultiTermQuery#getTermsEnum(Terms, AttributeSource) </seealso>
 protected internal virtual TermsEnum GetTermsEnum(MultiTermQuery query, Terms terms, AttributeSource atts)
 {
     return(query.GetTermsEnum(terms, atts)); // allow RewriteMethod subclasses to pull a TermsEnum from the MTQ
 }
			/// <summary> Returns true, iff the current state of the passed-in <see cref="AttributeSource" /> shall be stored
			/// in the sink. 
			/// </summary>
			public abstract bool Accept(AttributeSource source);
Example #48
0
 /// <summary> Returns true, iff the current state of the passed-in {@link AttributeSource} shall be stored
 /// in the sink.
 /// </summary>
 public abstract bool Accept(AttributeSource source);
			internal /*private*/ bool Accept(AttributeSource source)
			{
				return filter.Accept(source);
			}
Example #50
0
 internal SinkTokenStream(AttributeSource source, SinkFilter filter) : base(source)
 {
     this.filter = filter;
 }
			internal /*private*/ void  SetFinalState(AttributeSource.State finalState)
			{
				this.finalState = finalState;
			}
Example #52
0
 internal /*private*/ bool Accept(AttributeSource source)
 {
     return(filter.Accept(source));
 }
		/// <summary>Construct a new LowerCaseTokenizer using a given <see cref="AttributeSource" />. </summary>
		public LowerCaseTokenizer(AttributeSource source, System.IO.TextReader @in)
			: base(source, @in)
		{
		}
Example #54
0
 public override bool Accept(AttributeSource source)
 {
     return(true);
 }
Example #55
0
            public override bool Accept(AttributeSource a)
            {
                ITermAttribute termAtt = a.GetAttribute <ITermAttribute>();

                return(termAtt.Term.ToUpper().Equals("Dogs".ToUpper()));
            }
Example #56
0
		/// <summary>Construct a new LowerCaseTokenizer using a given {@link AttributeSource}. </summary>
		public LowerCaseTokenizer(AttributeSource source, System.IO.TextReader in_Renamed):base(source, in_Renamed)
		{
		}
Example #57
0
		private TokenWrapper InitTokenWrapper(AttributeSource input)
		{
			if (onlyUseNewAPI)
			{
				// no wrapper needed
				return null;
			}
			else
			{
				// if possible get the wrapper from the filter's input stream
				if (input is TokenStream && ((TokenStream) input).tokenWrapper != null)
				{
					return ((TokenStream) input).tokenWrapper;
				}
				// check that all attributes are implemented by the same TokenWrapper instance
				Attribute att = AddAttribute(typeof(TermAttribute));
				if (att is TokenWrapper && AddAttribute(typeof(TypeAttribute)) == att && AddAttribute(typeof(PositionIncrementAttribute)) == att && AddAttribute(typeof(FlagsAttribute)) == att && AddAttribute(typeof(OffsetAttribute)) == att && AddAttribute(typeof(PayloadAttribute)) == att)
				{
					return (TokenWrapper) att;
				}
				else
				{
					throw new System.NotSupportedException("If onlyUseNewAPI is disabled, all basic Attributes must be implemented by the internal class " + "TokenWrapper. Please make sure, that all TokenStreams/TokenFilters in this chain have been " + "instantiated with this flag disabled and do not add any custom instances for the basic Attributes!");
				}
			}
		}
		/// <summary>Construct a new WhitespaceTokenizer using a given <see cref="AttributeSource" />. </summary>
		public WhitespaceTokenizer(AttributeSource source, System.IO.TextReader @in)
			: base(source, @in)
		{
		}