001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.search.lucene2.analyzer;
020
021import java.io.Reader;
022
023import org.apache.lucene.analysis.Analyzer;
024import org.apache.lucene.analysis.TokenStream;
025import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
026
027
028/**
029 * <p>Analyzer for Italian language</p>
030 */
031public final class ItalianAnalyzer extends Analyzer {
032
033        private final static char A_GRAPH=(char)224;
034        private final static char E_GRAPH=(char)232;
035        private final static char I_GRAPH=(char)236;
036        private final static char O_GRAPH=(char)242;
037        private final static char U_GRAPH=(char)249;
038        
039
040        private final static char E_EGU=(char)233;
041        
042        
043        private static SnowballAnalyzer analyzer;
044
045        private final static String[] STOP_WORDS = { "a", "abbia",
046                    "abbiamo", "abbiano", "abbiate", "ad", "agl", "agli", "ai",
047                    "al", "all", "alla", "alle", "allo", "anche", "avemmo",
048                    "avendo", "avesse", "avessero", "avessi", "avessimo",
049                    "aveste", "avesti", "avete", "aveva", "avevamo", "avevano",
050                    "avevate", "avevi", "avevo", "avr"+A_GRAPH, "avrai", "avranno",
051                    "avrebbe", "avrebbero", "avrei", "avremmo", "avremo",
052                    "avreste", "avresti", "avrete", "avr"+O_GRAPH, "avuta", "avute",
053                    "avuti", "avuto", "c", "che", "chi", "ci", "coi", "come",
054                    "con", "contro", "cui", "da", "dagl", "dagli", "dai",
055                    "dal", "dall", "dalle", "dallo", "degl", "degli", "dei",
056                    "del", "dell", "della", "delle", "dello", "di", "dov",
057                    "dove", "e", ""+E_GRAPH, "ebbe", "ebbero", "ebbi", "ed", "erano",
058                    "eravamo", "eravate", "eri", "ero", "essendo", "fa", "f"+A_GRAPH,
059                    "facciamo", "facciano", "faccio", "facemmo", "facendo",
060                    "facesse", "facessero", "facessi", "facessimo", "faceste",
061                    "facesti", "faceva", "facevamo", "facevano", "facevate",
062                    "facevi", "facevo", "fai", "fanno", "far"+A_GRAPH, "farai",
063                    "faranno", "farebbe", "farebbero", "farei", "faremmo",
064                    "faremo", "fareste", "faresti", "farete", "far"+O_GRAPH, "fece",
065                    "fecero", "fossero", "fossimo", "foste", "fosti", "fu",
066                    "fui", "fummo", "furono", "gli", "ha", "hai", "hanno",
067                    "ho", "i", "il", "in", "io", "l", "la", "l"+A_GRAPH, "le", "lei",
068                    "li", "l"+I_GRAPH, "lo", "loro", "lui", "ma", "mi", "mia", "mie",
069                    "miei", "mio", "ne", "negl", "negli", "nei", "nel", "nell",
070                    "nella", "nelle", "nello", "noi", "non", "nostra",
071                    "nostre", "nostri", "nostro", "o", "per", "perch"+E_EGU, "pi"+U_GRAPH,
072                    "quale", "quanta", "quante", "quanti", "quanto", "quella",
073                    "quelle", "quelli", "quello", "questa", "queste", "questi",
074                    "questo", "sar"+A_GRAPH, "sarai", "saranno", "sarebbe",
075                    "sarebbero", "sarei", "saremmo", "saremo", "sareste",
076                    "saresti", "sarete", "sar"+O_GRAPH, "se", "sei", "si", "s"+I_GRAPH,
077                    "sia", "siamo", "siano", "siate", "siete", "sono", "sta",
078                    "stai", "stando", "stanno", "star"+A_GRAPH, "starai", "staranno",
079                    "starebbe", "starebbero", "starei", "staremmo", "staremo",
080                    "stareste", "staresti", "starete", "star"+O_GRAPH, "stava",
081                    "stavamo", "stavano", "stavate", "stavi", "stavo",
082                    "stemmo", "stesse", "stessero", "stessi", "stessimo",
083                    "steste", "stesti", "stette", "stettero", "stetti", "stia",
084                    "stiamo", "stiano", "stiate", "sto", "su", "sua", "sue",
085                    "sugl", "sugli", "sui", "sul", "sull", "sulla", "sulle",
086                    "sullo", "suo", "suoi", "ti", "tra", "tu", "tua", "tue",
087                    "tuo", "tuoi", "tutti", "tutto", "un", "una", "uno", "vi",
088                    "voi", "vostra", "vostre", "vostri", "vostro" };
089
090
091        /**
092         * Creates new instance of SpanishAnalyzer
093         */
094        public ItalianAnalyzer() {
095                analyzer = new SnowballAnalyzer("Italian", STOP_WORDS);
096        }
097
098        public ItalianAnalyzer(String stopWords[]) {
099                analyzer = new SnowballAnalyzer("Italian", stopWords);
100        }
101
102        @Override
103        public TokenStream tokenStream(String fieldName, Reader reader) {
104                return analyzer.tokenStream(fieldName, reader);
105        }
106}