KickJava   Java API By Example, From Geeks To Geeks.

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


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 Spanish language</p>
26  * <p><a HREF="SpanishAnalyzer.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.2 $ $Date: 2005/02/24 19:51:22 $
31  */

32 public class SpanishAnalyzer extends Analyzer {
33
34     private static SnowballAnalyzer analyzer;
35
36     private String JavaDoc SPANISH_STOP_WORDS[] = {
37
38         "un", "una", "unas", "unos", "uno", "sobre", "todo", "tambien", "tras",
39         "otro", "algun", "alguno", "alguna",
40
41         "algunos", "algunas", "ser", "es", "soy", "eres", "somos", "sois", "estoy",
42         "esta", "estamos", "estais",
43
44         "estan", "en", "para", "atras", "porque", "por que", "estado", "estaba",
45         "ante", "antes", "siendo",
46
47         "ambos", "pero", "por", "poder", "puede", "puedo", "podemos", "podeis",
48         "pueden", "fui", "fue", "fuimos",
49
50         "fueron", "hacer", "hago", "hace", "hacemos", "haceis", "hacen", "cada",
51         "fin", "incluso", "primero",
52
53         "desde", "conseguir", "consigo", "consigue", "consigues", "conseguimos",
54         "consiguen", "ir", "voy", "va",
55
56         "vamos", "vais", "van", "vaya", "bueno", "ha", "tener", "tengo", "tiene",
57         "tenemos", "teneis", "tienen",
58
59         "el", "la", "lo", "las", "los", "su", "aqui", "mio", "tuyo", "ellos",
60         "ellas", "nos", "nosotros", "vosotros",
61
62         "vosotras", "si", "dentro", "solo", "solamente", "saber", "sabes", "sabe",
63         "sabemos", "sabeis", "saben",
64
65         "ultimo", "largo", "bastante", "haces", "muchos", "aquellos", "aquellas",
66         "sus", "entonces", "tiempo",
67
68         "verdad", "verdadero", "verdadera", "cierto", "ciertos", "cierta",
69         "ciertas", "intentar", "intento",
70
71         "intenta", "intentas", "intentamos", "intentais", "intentan", "dos", "bajo",
72         "arriba", "encima", "usar",
73
74         "uso", "usas", "usa", "usamos", "usais", "usan", "emplear", "empleo",
75         "empleas", "emplean", "ampleamos",
76
77         "empleais", "valor", "muy", "era", "eras", "eramos", "eran", "modo", "bien",
78         "cual", "cuando", "donde",
79
80         "mientras", "quien", "con", "entre", "sin", "trabajo", "trabajar",
81         "trabajas", "trabaja", "trabajamos",
82
83         "trabajais", "trabajan", "podria", "podrias", "podriamos", "podrian",
84         "podriais", "yo", "aquel", "mi",
85
86         "de", "a", "e", "i", "o", "u"};
87
88     /**
89      * Creates new instance of SpanishAnalyzer
90      */

91     public SpanishAnalyzer() {
92         analyzer = new SnowballAnalyzer("Spanish", SPANISH_STOP_WORDS);
93     }
94
95     public SpanishAnalyzer(String JavaDoc stopWords[]) {
96         analyzer = new SnowballAnalyzer("Spanish", stopWords);
97     }
98
99     public TokenStream tokenStream(String JavaDoc fieldName, Reader JavaDoc reader) {
100         return analyzer.tokenStream(fieldName, reader);
101     }
102 }
103
Popular Tags