public class DefaultStopList extends AbstractCloneableSerializable implements StopList
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Set<java.lang.String> |
words
The set of words in the stop list, all in lower-case.
|
| Constructor and Description |
|---|
DefaultStopList()
Creates a new, empty
DefaultStopList. |
DefaultStopList(java.lang.Iterable<java.lang.String> words)
Creates a new
DefaultStopList with the given set of words. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(java.lang.String word)
Adds a word to the stop list.
|
void |
addAll(java.lang.Iterable<java.lang.String> words)
Adds all of the given words to the stop list.
|
DefaultStopList |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
boolean |
contains(java.lang.String word)
Returns true if the given word is in the stop list.
|
boolean |
contains(Term term)
Returns true if the given term is in the stop list.
|
boolean |
contains(Termable term)
Determines if the given term is contained in this stop list.
|
java.util.Set<java.lang.String> |
getWords()
Gets the set of words in the stop list.
|
static DefaultStopList |
loadFromText(java.io.BufferedReader reader)
Loads a stop list by reading in from the given reader and treating each
line as a word.
|
static DefaultStopList |
loadFromText(java.io.File file)
Loads a stop list by reading in a given file and treating each line as
a word.
|
static DefaultStopList |
loadFromText(java.net.URI uri)
Loads a stop list by reading in a given file and treating each line as
a word.
|
static DefaultStopList |
loadFromText(java.net.URL url)
Loads a stop list by reading in a given file and treating each line as
a word.
|
static DefaultStopList |
loadFromText(java.net.URLConnection connection)
Loads a stop list by reading in a given file and treating each line as
a word.
|
void |
saveAsText(java.io.File file)
Saves the stop list to the given file.
|
void |
saveAsText(java.io.PrintStream out)
Saves the stop list to the given stream.
|
protected void |
setWords(java.util.Set<java.lang.String> words)
Sets the set of words in the stop list.
|
protected java.util.Set<java.lang.String> words
public DefaultStopList()
DefaultStopList.public DefaultStopList(java.lang.Iterable<java.lang.String> words)
DefaultStopList with the given set of words.words - The words to add to the stop list.public DefaultStopList clone()
AbstractCloneableSerializableObject class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone() to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone() as the basis for your implementation.clone in interface CloneableSerializableclone in class AbstractCloneableSerializablepublic void add(java.lang.String word)
word - The word to add to the stop list.public void addAll(java.lang.Iterable<java.lang.String> words)
words - The words to add.public boolean contains(Termable term)
StopListpublic boolean contains(Term term)
term - A term.public boolean contains(java.lang.String word)
word - A word.public java.util.Set<java.lang.String> getWords()
protected void setWords(java.util.Set<java.lang.String> words)
words - The set of words in the stop list.public void saveAsText(java.io.File file)
throws java.io.IOException
file - The file to save the stop list to.java.io.IOException - If there is an IO error.public void saveAsText(java.io.PrintStream out)
throws java.io.IOException
out - The stream to write the stop words to.java.io.IOException - If there is an IO error.public static DefaultStopList loadFromText(java.io.File file) throws java.io.IOException
file - The file to read in.java.io.IOException - If there is an IO error.public static DefaultStopList loadFromText(java.net.URI uri) throws java.io.IOException
uri - The file to read in.java.io.IOException - If there is an IO error.public static DefaultStopList loadFromText(java.net.URL url) throws java.io.IOException
url - The file to read in.java.io.IOException - If there is an IO error.public static DefaultStopList loadFromText(java.net.URLConnection connection) throws java.io.IOException
connection - The connection to the file to read in.java.io.IOException - If there is an IO error.public static DefaultStopList loadFromText(java.io.BufferedReader reader) throws java.io.IOException
reader - The reader to read the stop words from. Does not close the reader.java.io.IOException - If there is an IO error.