| AbstractBookAnalyzer.java |
1 /**
2 * Distribution License:
3 * JSword is free software; you can redistribute it and/or modify it under
4 * the terms of the GNU Lesser General Public License, version 2.1 or later
5 * as published by the Free Software Foundation. This program is distributed
6 * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
7 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8 * See the GNU Lesser General Public License for more details.
9 *
10 * The License is available on the internet at:
11 * http://www.gnu.org/copyleft/lgpl.html
12 * or by writing to:
13 * Free Software Foundation, Inc.
14 * 59 Temple Place - Suite 330
15 * Boston, MA 02111-1307, USA
16 *
17 * © CrossWire Bible Society, 2007 - 2016
18 *
19 */
20 package org.crosswire.jsword.index.lucene.analysis;
21
22 import java.util.Set;
23
24 import org.apache.lucene.analysis.Analyzer;
25 import org.crosswire.jsword.book.Book;
26
27 /**
28 * Base class for Analyzers. Note: All analyzers configured in
29 * AnalyzerFactory.properties should be of this type
30 *
31 * @see gnu.lgpl.License The GNU Lesser General Public License for details.
32 * @author sijo cherian
33 * @author DM Smith
34 */
35 public abstract class AbstractBookAnalyzer extends Analyzer {
36
37 public AbstractBookAnalyzer() {
38 this(null);
39 }
40
41 public AbstractBookAnalyzer(Book book) {
42 this.book = book;
43 doStopWords = false;
44 doStemming = true;
45 }
46
47 /**
48 * The book for which analysis is being performed.
49 *
50 * @param newBook
51 */
52 public void setBook(Book newBook) {
53 book = newBook;
54 }
55
56 /**
57 * @return the book for which analysis is being performed.
58 */
59 public Book getBook() {
60 return book;
61 }
62
63 public void setDoStopWords(boolean doIt) {
64 doStopWords = doIt;
65 }
66
67 public boolean getDoStopWords() {
68 return doStopWords;
69 }
70
71 public void setStopWords(Set<?> stopWords) {
72 stopSet = stopWords;
73 }
74
75
76 public void setDoStemming(boolean stemming) {
77 doStemming = stemming;
78 }
79
80 /**
81 * The book against which analysis is performed.
82 */
83 protected Book book;
84
85 protected Set<?> stopSet;
86
87 // for turning on/off stop word removal during analysis
88 protected boolean doStopWords;
89
90 // for turning on/off stemming
91 protected boolean doStemming;
92 }
93