opennlp.maxent
Class FileEventStream

java.lang.Object
  extended by opennlp.maxent.FileEventStream
All Implemented Interfaces:
EventStream
Direct Known Subclasses:
RealValueFileEventStream

public class FileEventStream
extends java.lang.Object
implements EventStream

Class for using a file of events as an event stream. The format of the file is one event perline with each line consisting of outcome followed by contexts (space delimited).

Author:
Tom Morton

Constructor Summary
FileEventStream(java.io.File file)
          Creates a new file event stream from the specified file.
FileEventStream(java.lang.String fileName)
           
FileEventStream(java.lang.String fileName, java.lang.String encoding)
          Creates a new file event stream from the specified file name.
 
Method Summary
 boolean hasNext()
          Test whether there are any Events remaining in this EventStream.
static void main(java.lang.String[] args)
          Trains and writes a model based on the events in the specified event file.
 Event nextEvent()
          Returns the next Event object held in this EventStream.
static java.lang.String toLine(Event event)
          Generates a string representing the specified event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileEventStream

public FileEventStream(java.lang.String fileName,
                       java.lang.String encoding)
                throws java.io.IOException
Creates a new file event stream from the specified file name.

Parameters:
fileName - the name fo the file containing the events.
Throws:
java.io.IOException - When the specified file can not be read.

FileEventStream

public FileEventStream(java.lang.String fileName)
                throws java.io.IOException
Throws:
java.io.IOException

FileEventStream

public FileEventStream(java.io.File file)
                throws java.io.IOException
Creates a new file event stream from the specified file.

Parameters:
file - the file containing the events.
Throws:
java.io.IOException - When the specified file can not be read.
Method Detail

hasNext

public boolean hasNext()
Description copied from interface: EventStream
Test whether there are any Events remaining in this EventStream.

Specified by:
hasNext in interface EventStream
Returns:
true if this EventStream has more Events

nextEvent

public Event nextEvent()
Description copied from interface: EventStream
Returns the next Event object held in this EventStream.

Specified by:
nextEvent in interface EventStream
Returns:
the Event object which is next in this EventStream

toLine

public static java.lang.String toLine(Event event)
Generates a string representing the specified event.

Parameters:
event - The event for which a string representation is needed.
Returns:
A string representing the specified event.

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Trains and writes a model based on the events in the specified event file. the name of the model created is based on the event file name.

Parameters:
args - eventfile [iterations cuttoff]
Throws:
java.io.IOException - when the eventfile can not be read or the model file can not be written.


Copyright © 2005 Jason Baldridge, Gann Bierner, and Thomas Morton. All Rights Reserved.