2 * Copyright 2004 The Apache Software Foundation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using Token
= Lucene
.Net
.Analysis
.Token
;
18 using TokenFilter
= Lucene
.Net
.Analysis
.TokenFilter
;
19 using TokenStream
= Lucene
.Net
.Analysis
.TokenStream
;
20 namespace Lucene
.Net
.Analysis
.DE
23 /// <summary> A filter that stems German words. It supports a table of words that should
24 /// not be stemmed at all. The stemmer used can be changed at runtime after the
25 /// filter object is created (as long as it is a GermanStemmer).
28 /// <author> Gerhard Schwarz
30 /// <version> $Id: GermanStemFilter.cs,v 1.2 2005/01/17 19:54:27 joeshaw Exp $
32 public sealed class GermanStemFilter
: TokenFilter
34 /// <summary> The actual token in the input stream.</summary>
35 private Token token
= null;
36 private GermanStemmer stemmer
= null;
37 private System
.Collections
.Hashtable exclusionSet
= null;
39 public GermanStemFilter(TokenStream in_Renamed
) : base(in_Renamed
)
41 stemmer
= new GermanStemmer();
44 /// <summary> Builds a GermanStemFilter that uses an exclusiontable.</summary>
45 /// <deprecated> Use {@link #GermanStemFilter(Lucene.Net.Analysis.TokenStream, java.util.Set)} instead.
47 public GermanStemFilter(TokenStream in_Renamed
, System
.Collections
.Hashtable exclusiontable
):this(in_Renamed
)
49 exclusionSet
= new System
.Collections
.Hashtable(new System
.Collections
.Hashtable(exclusiontable
));
52 /// <returns> Returns the next token in the stream, or null at EOS
54 public override Token
Next()
56 if ((token
= input
.Next()) == null)
60 // Check the exclusiontable
61 else if (exclusionSet
!= null && exclusionSet
.Contains(token
.TermText()))
67 System
.String s
= stemmer
.Stem(token
.TermText());
68 // If not stemmed, dont waste the time creating a new token
69 if (!s
.Equals(token
.TermText()))
71 return new Token(s
, token
.StartOffset(), token
.EndOffset(), token
.Type());
77 /// <summary> Set a alternative/custom GermanStemmer for this filter.</summary>
78 public void SetStemmer(GermanStemmer stemmer
)
82 this.stemmer
= stemmer
;
86 /// <summary> Set an alternative exclusion list for this filter.</summary>
87 /// <deprecated> Use {@link #SetExclusionSet(java.util.Set)} instead.
89 public void SetExclusionTable(System
.Collections
.Hashtable exclusiontable
)
91 exclusionSet
= new System
.Collections
.Hashtable(new System
.Collections
.Hashtable(exclusiontable
));
94 /// <summary> Set an alternative exclusion list for this filter.</summary>
95 public void SetExclusionSet(System
.Collections
.Hashtable exclusionSet
)
97 this.exclusionSet
= exclusionSet
;