01: package org.contineo.core.searchengine.crawler;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05:
06: import org.apache.lucene.analysis.Analyzer;
07: import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
08: import org.contineo.core.text.analyze.Stopwords;
09:
10: public class LuceneAnalyzerFactory {
11:
12: private static Map<String, Analyzer> analyzers = new HashMap<String, Analyzer>();
13:
14: static {
15: analyzers.put("en", new SnowballAnalyzer("English", Stopwords
16: .getStopwords("en")));
17: analyzers.put("fr", new SnowballAnalyzer("French", Stopwords
18: .getStopwords("fr")));
19: analyzers.put("de", new SnowballAnalyzer("German", Stopwords
20: .getStopwords("de")));
21: analyzers.put("es", new SnowballAnalyzer("Spanish", Stopwords
22: .getStopwords("es")));
23: analyzers.put("it", new SnowballAnalyzer("Italian", Stopwords
24: .getStopwords("it")));
25: }
26:
27: private LuceneAnalyzerFactory() {
28: }
29:
30: public static Analyzer getAnalyzer(String language) {
31: if ((language == null) || (!analyzers.containsKey(language)))
32: return analyzers.get("en");
33: return analyzers.get(language);
34: }
35: }
|