edu.mit.jmwe.data
Class MWEComparator<T extends IToken>

java.lang.Object
  extended by edu.mit.jmwe.util.AbstractIndexComparator<T,IMWE<T>>
      extended by edu.mit.jmwe.data.MWEComparator<T>
Type Parameters:
T - the type of token for this comparator
All Implemented Interfaces:
Comparator<IMWE<T>>

public class MWEComparator<T extends IToken>
extends AbstractIndexComparator<T,IMWE<T>>

A comparator that compares IMWEs by checking which MWE starts earlier in the list of tokens used to construct this comparator. If the two MWEs have the same tokens, uses the part of speech to determine the order.

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

Field Summary
 
Fields inherited from class edu.mit.jmwe.util.AbstractIndexComparator
indexMap
 
Constructor Summary
MWEComparator(List<T> list)
          Constructs the comparator from the given list of tokens by mapping each token in the list to its index in the list.
MWEComparator(Map<T,Integer> indexMap)
          Constructs the comparator from the given index map of each token in a list to its index in the list.
 
Method Summary
 int compare(IMWE<T> one, IMWE<T> two)
           
protected  boolean earlier(IMWE<T> one, IMWE<T> two)
          Internal method used to determine if one multi-word expression appears in the sentence before another.
 
Methods inherited from class edu.mit.jmwe.util.AbstractIndexComparator
createIndexMap, getIndexMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

MWEComparator

public MWEComparator(List<T> list)
Constructs the comparator from the given list of tokens by mapping each token in the list to its index in the list.

Parameters:
list - the list of objects used to construct this comparator. May not be null.
Throws:
NullPointerException - if the given list is null.
Since:
jMWE 1.0.0

MWEComparator

public MWEComparator(Map<T,Integer> indexMap)
Constructs the comparator from the given index map of each token in a list to its index in the list.

Parameters:
indexMap - map of each token in a list to its index in the list. May not be null.
Since:
jMWE 1.0.0
Method Detail

compare

public int compare(IMWE<T> one,
                   IMWE<T> two)

earlier

protected boolean earlier(IMWE<T> one,
                          IMWE<T> two)
Internal method used to determine if one multi-word expression appears in the sentence before another.

Parameters:
one - multi-word expression being compared
two - multi-word expression being compared
Returns:
true if one is before two false otherwise.
Since:
jMWE 1.0.0


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