edu.mit.jmwe.detect
Class MWEBuilder<T extends IToken>

java.lang.Object
  extended by edu.mit.jmwe.detect.MWEBuilder<T>

public class MWEBuilder<T extends IToken>
extends Object

A record that is used to hold tokens as the detector passes over a sentence. Contains empty slots for each part of a multi-word expression. Each slot can be filled by a token that matches the part.

Since:
jMWE 1.0.0
Version:
1.620, 08 May 2011
Author:
M.A. Finlayson

Constructor Summary
MWEBuilder(IMWEDesc entry, Comparator<T> comparator)
          Constructs an empty record from an IRootMWEDesc object.
MWEBuilder(IMWEDesc entry, List<T> sentence)
          Constructs an empty record from the given MWE description and sentence.
 
Method Summary
 MWEBuilder<T> clone()
           
 boolean equals(Object obj)
           
static
<T extends IToken>
boolean
fillNextSlot(MWEBuilder<T> builder, T t)
          Fills the first non-null (empty) slot in the given builder.
static
<T extends IToken>
void
fillSlots(Set<MWEBuilder<T>> records, T token)
          Given a set of MWE builders, fills all the slots in the records that can be filled by the given token.
 IMWEDesc getEntry()
          Returns the multi-word expression description object corresponding to the record.
 SortedMap<IMWEDesc.IPart,T> getSlots()
          Returns the slots of this record.
 boolean hasEmptyMatchingSlots(Map.Entry<IMWEDesc.IPart,T> slot)
          Returns true if the matching slots after the given slot in this record are empty.
 int hashCode()
           
 boolean hasMultiple()
          Returns true if the record contains two or more slots whose index parts have the same part lemma.
 boolean isContentFull()
          Returns true if the all of the content words in this record are full.
 boolean isFull()
          Returns true if all the slots in this record contain a token.
 boolean isPartOfSpeechSatisfied()
          Returns true if at least one token in one slot matches the part of speech of the MWE description; false otherwise.
 IMWE<T> toMWE()
          Converts the tokens in a full record into an IMWE object.
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MWEBuilder

public MWEBuilder(IMWEDesc entry,
                  List<T> sentence)
Constructs an empty record from the given MWE description and sentence.

Parameters:
entry - the description of the MWE associated with this record
sentence - the sentence from which the tokens used to fill this record will be drawn
Since:
jMWE 1.0.0

MWEBuilder

public MWEBuilder(IMWEDesc entry,
                  Comparator<T> comparator)
Constructs an empty record from an IRootMWEDesc object.

Parameters:
entry - a multi-word expression description. May not be null.
Throws:
NullPointerException - if the description is null.
Since:
jMWE 1.0.0
Method Detail

getEntry

public IMWEDesc getEntry()
Returns the multi-word expression description object corresponding to the record.

Returns:
the IMWEDesc corresponding to the record.
Since:
jMWE 1.0.0

getSlots

public SortedMap<IMWEDesc.IPart,T> getSlots()
Returns the slots of this record. These slots map each index part of the multi-word expression to a token or to null if the slot has not yet been filled.

Returns:
a SortedMap that maps each index part of the multi-word expression to a token or to null if the slot has not yet been filled.
Since:
jMWE 1.0.0

isFull

public boolean isFull()
Returns true if all the slots in this record contain a token.

Returns:
true if all the slots in this record are full.
Since:
jMWE 1.0.0

isContentFull

public boolean isContentFull()
Returns true if the all of the content words in this record are full.

Returns:
true if the all of the content words in this record are full.
Since:
jMWE 1.0.0

isPartOfSpeechSatisfied

public boolean isPartOfSpeechSatisfied()
Returns true if at least one token in one slot matches the part of speech of the MWE description; false otherwise.

Returns:
true if at least one token in one slot matches the part of speech of the MWE description; false otherwise.
Since:
jMWE 1.0.0

hasEmptyMatchingSlots

public boolean hasEmptyMatchingSlots(Map.Entry<IMWEDesc.IPart,T> slot)
Returns true if the matching slots after the given slot in this record are empty. Matching slots have index parts with the same part lemma.

Parameters:
slot - the slot in consideration. May not be null.
Returns:
true if the matching slots after the given slot in this record are empty.
Since:
jMWE 1.0.0

hasMultiple

public boolean hasMultiple()
Returns true if the record contains two or more slots whose index parts have the same part lemma.

Returns:
true if the record contains any matching slots
Since:
jMWE 1.0.0

clone

public MWEBuilder<T> clone()
Overrides:
clone in class Object

toMWE

public IMWE<T> toMWE()
Converts the tokens in a full record into an IMWE object. If this record is not full, returns null.

Returns:
a IMWE object if the record is full, null otherwise.
Since:
jMWE 1.0.0

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

fillSlots

public static <T extends IToken> void fillSlots(Set<MWEBuilder<T>> records,
                                                T token)
Given a set of MWE builders, fills all the slots in the records that can be filled by the given token. If necessary, adds new records to the set.

Type Parameters:
T - type of tokens the records hold
Parameters:
records - a set of records whose slots may be filled. May not be null.
token - the token that will be used to fill the appropriate slots in the records. May not be null.
Throws:
NullPointerException - if either parameter is null.
Since:
jMWE 1.0.0

fillNextSlot

public static <T extends IToken> boolean fillNextSlot(MWEBuilder<T> builder,
                                                      T t)
Fills the first non-null (empty) slot in the given builder. Each slot can be filled by a token that matches the part. Returns true if the slot can be filled, false otherwise.

Parameters:
builder - the builder to be filled
t - the token to fill the builder's next open slot with
Returns:
true if the next open slot can be filled, false otherwise.
Since:
jMWE 1.0.0


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