public class Stopwords extends java.lang.Object implements RevisionHandler
| Constructor and Description |
|---|
Stopwords()
initializes the stopwords (based on Rainbow).
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(java.lang.String word)
adds the given word to the stopword list (is automatically converted to
lower case and trimmed)
|
void |
clear()
removes all stopwords
|
java.util.Enumeration<java.lang.String> |
elements()
Returns a sorted enumeration over all stored stopwords
|
java.lang.String |
getRevision()
Returns the revision string.
|
boolean |
is(java.lang.String word)
Returns true if the given string is a stop word.
|
static boolean |
isStopword(java.lang.String str)
Returns true if the given string is a stop word.
|
static void |
main(java.lang.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(java.io.BufferedReader reader)
Generates a new Stopwords object from the reader.
|
void |
read(java.io.File file)
Generates a new Stopwords object from the given file
|
void |
read(java.lang.String filename)
Generates a new Stopwords object from the given file
|
boolean |
remove(java.lang.String word)
removes the word from the stopword list
|
java.lang.String |
toString()
returns the current stopwords in a string
|
void |
write(java.io.BufferedWriter writer)
Writes the current stopwords to the given writer.
|
void |
write(java.io.File file)
Writes the current stopwords to the given file
|
void |
write(java.lang.String filename)
Writes the current stopwords to the given file
|
public Stopwords()
public void clear()
public void add(java.lang.String word)
word - the word to addpublic boolean remove(java.lang.String word)
word - the word to removepublic boolean is(java.lang.String word)
word - the word to testpublic java.util.Enumeration<java.lang.String> elements()
public void read(java.lang.String filename)
throws java.lang.Exception
filename - the file to read the stopwords fromjava.lang.Exception - if reading failspublic void read(java.io.File file)
throws java.lang.Exception
file - the file to read the stopwords fromjava.lang.Exception - if reading failspublic void read(java.io.BufferedReader reader)
throws java.lang.Exception
reader - the reader to get the stopwords fromjava.lang.Exception - if reading failspublic void write(java.lang.String filename)
throws java.lang.Exception
filename - the file to write the stopwords tojava.lang.Exception - if writing failspublic void write(java.io.File file)
throws java.lang.Exception
file - the file to write the stopwords tojava.lang.Exception - if writing failspublic void write(java.io.BufferedWriter writer)
throws java.lang.Exception
writer - the writer to get the stopwords fromjava.lang.Exception - if writing failspublic java.lang.String toString()
toString in class java.lang.Objectpublic static boolean isStopword(java.lang.String str)
str - the word to testpublic java.lang.String getRevision()
getRevision in interface RevisionHandlerpublic static void main(java.lang.String[] args)
throws java.lang.Exception
args - commandline parametersjava.lang.Exception - if something goes wrong