|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdanbikel.parser.EventCountsConsumer
public class EventCountsConsumer
An implementation of the Consumer
interface (part of the Switchboard
framework) for counting events (TrainerEvent
instances) produced as
part of the E-step of the EM algorithm (Inside-Outside). Each NumberedObject
consumed by this consumer is expected to contain a CountsTable
containing the expected counts of TrainerEvent
instances.
Field Summary | |
---|---|
static int |
defaultWriteInterval
The default writing interval for this consumer. |
Constructor Summary | |
---|---|
EventCountsConsumer()
Constructs a new event counts consumer. |
|
EventCountsConsumer(boolean asynchronousWrite)
Constructs a new event counts consumer. |
|
EventCountsConsumer(boolean asynchronousWrite,
boolean strictWriteInterval)
Constructs a new event counts consumer. |
Method Summary | |
---|---|
void |
consume(NumberedObject obj)
Tells this consumer to consume the specified object that has been processed by one of the switchboard's clients. |
void |
consumeForDumper(NumberedObject obj)
A helper method used by consume(NumberedObject) to perform
consumption of objects that are periodicially written to an output file by
a separate “dumper” thread. |
void |
dontUseCountThreshold()
Indicates not to use the count threshold specified by Settings.countThreshold . |
int |
getWriteInterval()
Gets the write interval for this consumer. |
void |
newFile(String inputFilename,
String outputFilename)
Indicates that the consumer is about to be consuming objects from the specified input file. |
void |
processingComplete(String inputFilename,
String outputFilename)
Indicates that there are no more sentences whose event counts are to be consumed. |
void |
run()
Allows this object to used as a “dumper” thread for periodically writing consumed objects to an output file. |
void |
setWriteInterval(int writeInterval)
Sets the write interval for this consumer. |
void |
useCountThreshold()
Indicates to use the count threshold specified by Settings.countThreshold , which means that events below that threshold will
be removed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int defaultWriteInterval
Constructor Detail |
---|
public EventCountsConsumer()
getWriteInterval()
sentences.
public EventCountsConsumer(boolean asynchronousWrite)
asynchronousWrite
parameter is true
, then event
counts will be aggregated in an internal CountsTable
, and
after event counts have been aggregated from at least getWriteInterval()
sentences, the events and their aggregate counts will be
passed off to a separate thread for appending to the current output file.
This appending will happen in parallel with the consumption of new events
in a freshly-cleared CountsTable
.
asynchronousWrite
- indicates whether or not to append event counts to
the output file asynchronously (that is, in
parallel) with the consumption of new event
countspublic EventCountsConsumer(boolean asynchronousWrite, boolean strictWriteInterval)
asynchronousWrite
parameter is true
, then event
counts will be aggregated in an internal CountsTable
, and at
periodic intervals, the aggregated event counts will be passed off to a
separate thread for appending to the current output file. This appending
will happen in parallel with the consumption of new events in a
freshly-cleared CountsTable
. The interval between writing to
the output file is determined by the value of getWriteInterval()
. If
asynchronousWrite
is true
and the
strictWriteInterval
parameter is true
, then it is
guaranteed that the internal counts table will contain aggregate counts
from exactly getWriteInterval()
sentences before being handed off to
the output thread. If the strictWriteInterval
parameter is
false
, then the internal counts table will contain events from
at least getWriteInterval()
sentences. If the
asynchronousWrite
parameter is false
then the
value of the strictWriteInterval
parameter will be ignored.
asynchronousWrite
- indicates whether or not to append event counts
to the output file asynchronously (that is, in
parallel) with the consumption of new event
countsstrictWriteInterval
- if asynchronousWrite
is
true
and this parameter is
true
, then it is guaranteed that
the internal counts table will contain aggregate
counts from exactly getWriteInterval()
sentences before being handed off to the output
thread; if this parameter is false
,
then the internal counts table will contain
events from at least getWriteInterval()
sentences; if the
asynchronousWrite
parameter is
false
then the value of this
parameter will be ignoredMethod Detail |
---|
public int getWriteInterval()
public void setWriteInterval(int writeInterval)
public void useCountThreshold()
Settings.countThreshold
, which means that events below that threshold will
be removed.
public void dontUseCountThreshold()
Settings.countThreshold
.
public void newFile(String inputFilename, String outputFilename)
Consumer
newFile
in interface Consumer
inputFilename
- the name of the input file for which object
processing has commencedoutputFilename
- the name of the (optional) output file to be
created from the specified input filepublic void consume(NumberedObject obj)
Consumer
consume
in interface Consumer
obj
- the processed switchboard object to be consumed by this
consumer instancepublic void consumeForDumper(NumberedObject obj)
consume(NumberedObject)
to perform
consumption of objects that are periodicially written to an output file by
a separate “dumper” thread. This method is only used if the
asynchronousWrite
argument to one of the constructors is
true
.
obj
- the object to be consumedpublic void processingComplete(String inputFilename, String outputFilename)
CountsTable
will be appended to the output file before this
method exits.
processingComplete
in interface Consumer
inputFilename
- the input file for which event counts have been
consumedoutputFilename
- the output file for consumed event countspublic void run()
asynchronousWrite
argument of the
constructors that take such an argument is true
, or if
the default constructor is used. A
dumper thread is created by newFile(String, String)
.
run
in interface Runnable
EventCountsConsumer()
,
EventCountsConsumer(boolean)
,
EventCountsConsumer(boolean,boolean)
,
newFile(String,String)
|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |