edu.mit.jmwe.harness
Class TestHarness

java.lang.Object
  extended by edu.mit.jmwe.harness.TestHarness
All Implemented Interfaces:
ITestHarness

public class TestHarness
extends Object
implements ITestHarness

Runs an IMWEDetector over a corpus and compares the multi-word expressions the detector finds to the multi-word expressions found in the answer key. Stores results of the runs in a result builder.

Since:
jMWE 1.0.0
Version:
$Id: TestHarness.java 619 2011-05-08 20:21:37Z markaf $
Author:
N. Kulkarni, M.A. Finlayson

Constructor Summary
protected TestHarness()
          This constructor is marked protected so that this class may be subclassed, but not directly instantiated.
 
Method Summary
static TestHarness getInstance()
          Returns the singleton instance of this class, instantiating if necessary.
<T extends IToken,S extends IMarkedSentence<T>>
void
run(IMWEDetector detector, IResultBuilder<T,S> result, Iterator<S> itr, IAnswerKey answers, IProgressBar pb)
          Runs the detector in the test harness and stores the results in the provided result builder.
<T extends IToken,S extends IMarkedSentence<T>>
void
run(Map<IMWEDetector,IResultBuilder<T,S>> detectors, Iterator<S> itr, IAnswerKey answers, IProgressBar pb)
          Runs the detectors in the test harness and stores the results in the associated result builder.
protected
<T extends IToken,S extends IMarkedSentence<T>>
List<IMWE<T>>
runDetector(IMWEDetector detector, IResultBuilder<T,S> builder, S sent, List<IMWE<T>> answers)
          Runs the detector over a single sentence, storing the result as an ISentenceResult in the given result builder.
protected
<T extends IToken,S extends IMarkedSentence<T>>
void
runDetectors(Map<IMWEDetector,IResultBuilder<T,S>> detectors, S sent, List<IMWE<T>> answers)
          Runs a set of detectors on the specified sentence, comparing the results to the specified answers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestHarness

protected TestHarness()
This constructor is marked protected so that this class may be subclassed, but not directly instantiated.

Since:
jMWE 1.0.0
Method Detail

getInstance

public static TestHarness getInstance()
Returns the singleton instance of this class, instantiating if necessary.

Returns:
the singleton instance of this class
Since:
jMWE 1.0.0

run

public <T extends IToken,S extends IMarkedSentence<T>> void run(IMWEDetector detector,
                                                                IResultBuilder<T,S> result,
                                                                Iterator<S> itr,
                                                                IAnswerKey answers,
                                                                IProgressBar pb)
Description copied from interface: ITestHarness
Runs the detector in the test harness and stores the results in the provided result builder.

Specified by:
run in interface ITestHarness
Type Parameters:
T - the type of tokens in the IMarkedSentence objects the harness runs over
S - the type of unit the harness runs over. Is parameterized by tokens of type T.
Parameters:
detector - the detector being tested. May not be null
result - the builder in which the results should be stored; may not be null
itr - an iterator over the units the detector will be tested on. May not be null.
answers - an answer key that can be used to find the answer multi-word expressions in a unit. May not be null.
pb - a progress bar to which the harness should report progress. May be null

run

public <T extends IToken,S extends IMarkedSentence<T>> void run(Map<IMWEDetector,IResultBuilder<T,S>> detectors,
                                                                Iterator<S> itr,
                                                                IAnswerKey answers,
                                                                IProgressBar pb)
Description copied from interface: ITestHarness
Runs the detectors in the test harness and stores the results in the associated result builder.

Specified by:
run in interface ITestHarness
Type Parameters:
T - the type of tokens in the IMarkedSentence objects the harness runs over
S - the type of unit the harness runs over. Is parameterized by tokens of type T.
Parameters:
detectors - the detector-to-builder map being tested. May not be null
itr - an iterator over the units the detector will be tested on. May not be null.
answers - an answer key that can be used to find the answer multi-word expressions in a unit. May not be null.
pb - a progress bar to which the harness should report progress. May be null

runDetectors

protected <T extends IToken,S extends IMarkedSentence<T>> void runDetectors(Map<IMWEDetector,IResultBuilder<T,S>> detectors,
                                                                            S sent,
                                                                            List<IMWE<T>> answers)
Runs a set of detectors on the specified sentence, comparing the results to the specified answers.

Type Parameters:
T - the token type
S - the sentence type
Parameters:
detectors - the detector-to-builder map
sent - the sentence on which the detectors should be run
answers - the set of answers for the sentence
Throws:
NullPointerException - if any argument is null
Since:
jMWE 1.0.0

runDetector

protected <T extends IToken,S extends IMarkedSentence<T>> List<IMWE<T>> runDetector(IMWEDetector detector,
                                                                                    IResultBuilder<T,S> builder,
                                                                                    S sent,
                                                                                    List<IMWE<T>> answers)
Runs the detector over a single sentence, storing the result as an ISentenceResult in the given result builder.

Type Parameters:
T - the type of tokens in the sentence
S - the type of sentence
Parameters:
detector - the detector to be tested
builder - the result builder being used to store the results of the test harness
sent - the sentence the detector will be run over
answers - the list of answer MWEs in the sentence
Throws:
NullPointerException - if any argument is null
Since:
jMWE 1.0.0


Copyright © 2011 Massachusetts Institute of Technology. All Rights Reserved.