public class DocumentIterator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected short |
docType
The type of documents to be created
|
protected java.io.File[] |
files
An array of files in the directory
|
protected int |
position
The current position of the iterator in this array
|
protected boolean |
stem
Whether tokens should be stemmed with Porter stemmer
|
static short |
TYPE_HTML
docType for HTML files
|
static short |
TYPE_TEXT
docType for ASCII text files
|
Constructor and Description |
---|
DocumentIterator(java.io.File dirFile)
Create an iterator for TexFileDocuments
|
DocumentIterator(java.io.File dirFile,
short docType,
boolean stem)
Create an iterator with these attributes
|
DocumentIterator(java.io.File dirFile,
short docType,
boolean stem,
java.io.FilenameFilter filter)
Create an iterator with these attributes
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasMoreDocuments()
Returns true iff there are more documents in this directory
|
static void |
main(java.lang.String[] args)
Test by printing the bag-of-words for each file in the given directory
|
FileDocument |
nextDocument()
Get the next document
|
public static final short TYPE_TEXT
public static final short TYPE_HTML
protected java.io.File[] files
protected int position
protected short docType
protected boolean stem
public DocumentIterator(java.io.File dirFile, short docType, boolean stem, java.io.FilenameFilter filter)
dirFile
- The directory to use as a source of documents.docType
- The type of Document to create. e.g. TYPE_TEXT or TYPE_HTMLstem
- Whether tokens should be stemmed with Porter stemmer.filter
- A filter to select a subset of the docs in the directorypublic DocumentIterator(java.io.File dirFile, short docType, boolean stem)
dirFile
- The directory to use as a source of documents.docType
- The type of Document to create. e.g. TYPE_TEXT or TYPE_HTMLstem
- Whether tokens should be stemmed with Porter stemmer.public DocumentIterator(java.io.File dirFile)
dirFile
- The directory to use as a source of documents.public FileDocument nextDocument()
public boolean hasMoreDocuments()
public static void main(java.lang.String[] args)