edu.mit.jmwe.harness.result
Class MWEResultBuilder<T extends IToken,S extends IMarkedSentence<T>>

java.lang.Object
  extended by edu.mit.jmwe.harness.result.MWEResultBuilder<T,S>
Type Parameters:
T - the type of tokens contained in the unit and its associated multi-word expressions.
S - the type of unit whose results are stored. Is parameterized by tokens of type T.
All Implemented Interfaces:
IResultBuilder<T,S>
Direct Known Subclasses:
TokenResultBuilder

public class MWEResultBuilder<T extends IToken,S extends IMarkedSentence<T>>
extends Object
implements IResultBuilder<T,S>

Builds an MWEResult by processing the data in ISentenceResult objects. Calculates the overall precision and recall scores with and without partial credit. All of the data stored in this builder is organized by part of speech. Partial credit is given when the detector correctly identifies some but not all of the tokens in an expression or if it includes some extra incorrect tokens in the expression. The partial credit is the alignment score between a partially correct MWE and an answer MWE. This alignment score is the ratio of the number of tokens shared between the two MWEs and the total number of unique tokens in both MWEs. It will be somewhere in between 0 (not overlapping at all) and 1 (overlapping perfectly). For example, in

 Senator Ben Cardin of Maryland voted for the health insurance bill.
 
If the detector correctly identifies health insurance but identifies Senator Ben Cardin of Maryland instead of Senator Ben Cardin, the scores would be
 Found   Actual  Correct   pc    Pr    Re    Pr/pc    Re/pc
 ----------------------------------------------------------
 2       2       1         0.6   0.5   0.5   0.8      0.8
 

Since:
jMWE 1.0.0
Version:
$Id: MWEResultBuilder.java 620 2011-05-08 21:13:58Z markaf $
Author:
N. Kulkarni, M.A. Finlayson

Field Summary
 Map<MWEPOS,AtomicInteger> answerData
           
 Map<MWEPOS,AtomicInteger> correctData
           
 Map<String,ISentenceResult<T,S>> details
           
 Map<MWEPOS,AtomicInteger> foundData
           
 Map<MWEPOS,AtomicDouble<T,S>> partialScores
           
 
Constructor Summary
MWEResultBuilder()
          Constructs a new builder that stores the detailed results obtained from individual sentences.
MWEResultBuilder(boolean captureDetails)
          Constructs a new builder that, if the captureDetials flag is true, will stores the detailed results obtained from individual sentences.
 
Method Summary
 void addDetail(String ID, ISentenceResult<T,S> detail)
          Stores the results for a unit under its ID.
 MWEResult<T,S> createResult()
          Creates a result from the data stored in this builder.
protected  Map<MWEPOS,AtomicDouble<T,S>> initDoubleMap()
          Provides a new, empty map for double values.
protected  Map<MWEPOS,AtomicInteger> initIntegerMap()
          Provides a new map for integer values.
 void process(List<IMWE<T>> found, List<IMWE<T>> answers)
          Updates the internal data stored in this builder by comparing the multi-word expressions found by an MWE detector to the answer multi-word expressions.
protected  Map<MWEPOS,Double> toDblMap(Map<MWEPOS,AtomicDouble<T,S>> map)
          Converts a map of AtomicDoubles to a map of Doubles.
protected  Map<MWEPOS,Integer> toIntMap(Map<MWEPOS,AtomicInteger> map)
          Converts a map of AtomicIntegers to a map of Integers.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

answerData

public final Map<MWEPOS,AtomicInteger> answerData

foundData

public final Map<MWEPOS,AtomicInteger> foundData

correctData

public final Map<MWEPOS,AtomicInteger> correctData

partialScores

public final Map<MWEPOS,AtomicDouble<T extends IToken,S extends IMarkedSentence<T>>> partialScores

details

public final Map<String,ISentenceResult<T extends IToken,S extends IMarkedSentence<T>>> details
Constructor Detail

MWEResultBuilder

public MWEResultBuilder()
Constructs a new builder that stores the detailed results obtained from individual sentences.

Since:
jMWE 1.0.0

MWEResultBuilder

public MWEResultBuilder(boolean captureDetails)
Constructs a new builder that, if the captureDetials flag is true, will stores the detailed results obtained from individual sentences.

Parameters:
captureDetails - the flag that if true, means that this builder will store results from each sentence.
Since:
jMWE 1.0.0
Method Detail

process

public void process(List<IMWE<T>> found,
                    List<IMWE<T>> answers)
Description copied from interface: IResultBuilder
Updates the internal data stored in this builder by comparing the multi-word expressions found by an MWE detector to the answer multi-word expressions.

Specified by:
process in interface IResultBuilder<T extends IToken,S extends IMarkedSentence<T>>
Parameters:
found - A non-null list of multi-word expressions found by an IMWEDetector.
answers - A non-null list of answer multi-word expressions

addDetail

public void addDetail(String ID,
                      ISentenceResult<T,S> detail)
Description copied from interface: IResultBuilder
Stores the results for a unit under its ID.

Specified by:
addDetail in interface IResultBuilder<T extends IToken,S extends IMarkedSentence<T>>
Parameters:
ID - the non-null identification String for the unit
detail - the unit result. May not be null.

createResult

public MWEResult<T,S> createResult()
Description copied from interface: IResultBuilder
Creates a result from the data stored in this builder. Should not return null.

Specified by:
createResult in interface IResultBuilder<T extends IToken,S extends IMarkedSentence<T>>
Returns:
a non-null result that contains the data stored in this builder.

toIntMap

protected Map<MWEPOS,Integer> toIntMap(Map<MWEPOS,AtomicInteger> map)
Converts a map of AtomicIntegers to a map of Integers.

Parameters:
map - the map to be converted
Returns:
the converted map
Since:
jMWE 1.0.0

toDblMap

protected Map<MWEPOS,Double> toDblMap(Map<MWEPOS,AtomicDouble<T,S>> map)
Converts a map of AtomicDoubles to a map of Doubles.

Parameters:
map - the map to be converted
Returns:
the converted map
Since:
jMWE 1.0.0

toString

public String toString()
Overrides:
toString in class Object

initIntegerMap

protected Map<MWEPOS,AtomicInteger> initIntegerMap()
Provides a new map for integer values.

Since:
jMWE 1.0.0

initDoubleMap

protected Map<MWEPOS,AtomicDouble<T,S>> initDoubleMap()
Provides a new, empty map for double values.

Since:
jMWE 1.0.0


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