configurable language for SnowballPorterFilterFactory: SOLR-27

git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@422737 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2006-07-17 15:17:53 +00:00
parent 64ae21e1c2
commit 8e9950debb
2 changed files with 23 additions and 7 deletions

View File

@ -27,6 +27,8 @@ New Features
the same position. (SOLR-11 / yonik, hossman)
15. Added highlighting to SolrPluginUtils and implemented in StandardRequestHandler
and DisMaxRequestHandler (SOLR-24 / Mike Klaas via hossman,yonik)
16. SnowballPorterFilterFactory language is configurable via the "language"
attribute, with the default being "English". (Bertrand Delacretaz via yonik, SOLR-27)
Changes in runtime behavior
1. classes reorganized into different packages, package names changed to Apache

View File

@ -13,22 +13,36 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.solr.analysis;
import java.util.Map;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.snowball.SnowballFilter;
import org.apache.solr.core.SolrCore;
/**
* Factory for SnowballFilters, with configurable language
*
* Browsing the code, SnowballFilter uses reflection to adapt to Lucene... don't
* use this if you are concerned about speed. Use EnglishPorterFilterFactory.
*
* @author yonik
* @version $Id$
*/
public class SnowballPorterFilterFactory extends BaseTokenFilterFactory {
public TokenStream create(TokenStream input) {
// Browsing the code, SnowballFilter uses reflection to adapt to Lucene...
// don't use this if you are concerned about speed. Use EnglishPorterFilterFactory.
// TODO: make language configurable
return new SnowballFilter(input,"English");
public class SnowballPorterFilterFactory extends BaseTokenFilterFactory {
private String language = "English";
public void init(Map<String, String> args) {
super.init(args);
final String cfgLanguage = args.get("language");
if(cfgLanguage!=null) language = cfgLanguage;
SolrCore.log.fine("SnowballPorterFilterFactory: language=" + language);
}
public TokenStream create(TokenStream input) {
return new SnowballFilter(input,language);
}
}