KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > search > analysis > NorwegianAnalyzer


1 /*
2  * Copyright 2004 Blandware (http://www.blandware.com)
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */

16 package com.blandware.atleap.search.analysis;
17
18 import org.apache.lucene.analysis.Analyzer;
19 import org.apache.lucene.analysis.TokenStream;
20 import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
21
22 import java.io.Reader JavaDoc;
23
24 /**
25  * <p>Analyzer for Norwegian language</p>
26  * <p><a HREF="NorwegianAnalyzer.java.htm"><i>View Source</i></a></p>
27  * <p/>
28  *
29  * @author Andrey Grebnev <a HREF="mailto:andrey.grebnev@blandware.com">&lt;andrey.grebnev@blandware.com&gt;</a>
30  * @version $Revision: 1.3 $ $Date: 2005/02/24 19:51:22 $
31  */

32 public class NorwegianAnalyzer extends Analyzer {
33
34     private static SnowballAnalyzer analyzer;
35
36     private String JavaDoc NORWEGIAN_STOP_WORDS[] = {
37         "og", "i", "er", "det", "som", "å", "til", "på", "for", "av", "at", "med", "har", "en", "om", "du", "de",
38         "ikke", "no", "vi", "jeg", "kan", "den", "eller", "seg", "men", "et", "dei", "skal", "ein", "blir", "så",
39         "vil", "fra", "var", "alle", "andre", "dette", "hva", "år", "bla"
40     };
41
42     /**
43      * Creates new instance of SpanishAnalyzer
44      */

45     public NorwegianAnalyzer() {
46         analyzer = new SnowballAnalyzer("Norwegian", NORWEGIAN_STOP_WORDS);
47     }
48
49     public NorwegianAnalyzer(String JavaDoc stopWords[]) {
50         analyzer = new SnowballAnalyzer("Norwegian", stopWords);
51     }
52
53     public TokenStream tokenStream(String JavaDoc fieldName, Reader JavaDoc reader) {
54         return analyzer.tokenStream(fieldName, reader);
55     }
56 }
57
Popular Tags