public class Stopwords extends Object implements RevisionHandler
Constructor and Description |
---|
Stopwords()
initializes the stopwords (based on Rainbow).
|
Modifier and Type | Method and Description |
---|---|
void |
add(String word)
adds the given word to the stopword list (is automatically converted to
lower case and trimmed)
|
void |
clear()
removes all stopwords
|
Enumeration |
elements()
Returns a sorted enumeration over all stored stopwords
|
String |
getRevision()
Returns the revision string.
|
boolean |
is(String word)
Returns true if the given string is a stop word.
|
static boolean |
isStopword(String str)
Returns true if the given string is a stop word.
|
static void |
main(String[] args)
Accepts the following parameter:
-i file
loads the stopwords from the given file -o file saves the stopwords to the given file -p outputs the current stopwords on stdout Any additional parameters are interpreted as words to test as stopwords. |
void |
read(BufferedReader reader)
Generates a new Stopwords object from the reader.
|
void |
read(File file)
Generates a new Stopwords object from the given file
|
void |
read(String filename)
Generates a new Stopwords object from the given file
|
boolean |
remove(String word)
removes the word from the stopword list
|
String |
toString()
returns the current stopwords in a string
|
void |
write(BufferedWriter writer)
Writes the current stopwords to the given writer.
|
void |
write(File file)
Writes the current stopwords to the given file
|
void |
write(String filename)
Writes the current stopwords to the given file
|
public Stopwords()
public void clear()
public void add(String word)
word
- the word to addpublic boolean remove(String word)
word
- the word to removepublic boolean is(String word)
word
- the word to testpublic Enumeration elements()
public void read(String filename) throws Exception
filename
- the file to read the stopwords fromException
- if reading failspublic void read(File file) throws Exception
file
- the file to read the stopwords fromException
- if reading failspublic void read(BufferedReader reader) throws Exception
reader
- the reader to get the stopwords fromException
- if reading failspublic void write(String filename) throws Exception
filename
- the file to write the stopwords toException
- if writing failspublic void write(File file) throws Exception
file
- the file to write the stopwords toException
- if writing failspublic void write(BufferedWriter writer) throws Exception
writer
- the writer to get the stopwords fromException
- if writing failspublic String toString()
public static boolean isStopword(String str)
str
- the word to testpublic String getRevision()
getRevision
in interface RevisionHandler
public static void main(String[] args) throws Exception
args
- commandline parametersException
- if something goes wrongCopyright © 2019 University of Waikato, Hamilton, NZ. All rights reserved.