Exemplo n.º 1
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!");
         }
     }
 }
Exemplo n.º 2
0
 /// <summary> Expert: Creates a token stream for numeric values with the specified
 /// <code>precisionStep</code> using the given {@link 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");
     }
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
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;
		}
Exemplo n.º 5
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);
Exemplo n.º 6
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();
		}
Exemplo n.º 7
0
 public override bool Accept(AttributeSource source)
 {
     return(true);
 }
Exemplo n.º 8
0
 public CharTokenizer(AttributeSource source, System.IO.TextReader input) : base(source, input)
 {
     offsetAtt = (OffsetAttribute)AddAttribute(typeof(OffsetAttribute));
     termAtt   = (TermAttribute)AddAttribute(typeof(TermAttribute));
 }
Exemplo n.º 9
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);
		}
Exemplo n.º 10
0
 internal SinkTokenStream(AttributeSource source, SinkFilter filter) : base(source)
 {
     this.filter = filter;
 }
Exemplo n.º 11
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);
		}
Exemplo n.º 12
0
			internal /*private*/ void  AddState(AttributeSource.State state)
			{
				if (it != null)
				{
					throw new System.SystemException("The tee must be consumed before sinks are consumed.");
				}
				cachedStates.Add(state);
			}
Exemplo n.º 13
0
			internal /*private*/ bool Accept(AttributeSource source)
			{
				return filter.Accept(source);
			}
Exemplo n.º 14
0
			internal SinkTokenStream(AttributeSource source, SinkFilter filter):base(source)
			{
				this.filter = filter;
			}
Exemplo n.º 15
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);
Exemplo n.º 16
0
 public KeywordTokenizer(AttributeSource source, System.IO.TextReader input, int bufferSize) : base(source, input)
 {
     Init(bufferSize);
 }
Exemplo n.º 17
0
 /// <summary>Construct a new WhitespaceTokenizer using a given {@link AttributeSource}. </summary>
 public WhitespaceTokenizer(AttributeSource source, System.IO.TextReader in_Renamed) : base(source, in_Renamed)
 {
 }
Exemplo n.º 18
0
			internal /*private*/ void  SetFinalState(AttributeSource.State finalState)
			{
				this.finalState = finalState;
			}
Exemplo n.º 19
0
		public StandardTokenizer(AttributeSource source, System.IO.TextReader input, bool replaceInvalidAcronym):base(source)
		{
			InitBlock();
			this.scanner = new StandardTokenizerImpl(input);
			Init(input, replaceInvalidAcronym);
		}
Exemplo n.º 20
0
			public override bool Accept(AttributeSource source)
			{
				return true;
			}
Exemplo n.º 21
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();
 }
Exemplo n.º 22
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)
 {
 }
Exemplo n.º 23
0
		/// <summary>Construct a token stream processing the given input using the given AttributeSource. </summary>
		protected internal Tokenizer(AttributeSource source):base(source)
		{
		}
Exemplo n.º 24
0
		/// <summary>Construct a new LetterTokenizer using a given {@link AttributeSource}. </summary>
		public LetterTokenizer(AttributeSource source, System.IO.TextReader in_Renamed):base(source, in_Renamed)
		{
		}
Exemplo n.º 25
0
		/// <summary> Expert: Creates a token stream for numeric values with the specified
		/// <code>precisionStep</code> using the given {@link 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");
		}
Exemplo n.º 26
0
 /// <summary>Construct a token stream processing the given input using the given AttributeSource. </summary>
 protected internal Tokenizer(AttributeSource source) : base(source)
 {
 }
Exemplo n.º 27
0
		/// <summary>Construct a new WhitespaceTokenizer using a given {@link AttributeSource}. </summary>
		public WhitespaceTokenizer(AttributeSource source, System.IO.TextReader in_Renamed):base(source, in_Renamed)
		{
		}
Exemplo n.º 28
0
 internal /*private*/ bool Accept(AttributeSource source)
 {
     return(filter.Accept(source));
 }
Exemplo n.º 29
0
		public CharTokenizer(AttributeSource source, System.IO.TextReader input):base(source, input)
		{
			offsetAtt = (OffsetAttribute) AddAttribute(typeof(OffsetAttribute));
			termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
		}
Exemplo n.º 30
0
 public StandardTokenizer(AttributeSource source, System.IO.TextReader input, bool replaceInvalidAcronym) : base(source)
 {
     InitBlock();
     this.scanner = new StandardTokenizerImpl(input);
     Init(input, replaceInvalidAcronym);
 }
Exemplo n.º 31
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);
 }
Exemplo n.º 32
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);
 }
Exemplo n.º 33
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!");
				}
			}
		}
Exemplo n.º 34
0
		public KeywordTokenizer(AttributeSource source, System.IO.TextReader input, int bufferSize):base(source, input)
		{
			Init(bufferSize);
		}