edu.mit.jmwe.detect
Class LMLR

java.lang.Object
  extended by edu.mit.jmwe.detect.HasMWEDetector
      extended by edu.mit.jmwe.detect.LMLR
All Implemented Interfaces:
IHasMWEDetector, IMWEDetector, IMWEDetectorResolver

public class LMLR
extends HasMWEDetector
implements IMWEDetectorResolver

Stands for "Longest Match, Left to Right". A detector that resolves conflicts in the results of its backing detector by returning the MWE that started the earliest in the sentence. If the conflicting MWEs started at the same position, returns the longer of them.

Since:
jMWE 1.0.0
Version:
$Id: LMLR.java 616 2011-05-07 01:00:47Z markaf $
Author:
M.A. Finlayson

Constructor Summary
LMLR(IMWEDetector detector)
          Constructs the detector from the backing detector.
 
Method Summary
<T extends IToken>
List<IMWE<T>>
detect(List<T> s)
          Given a list of tokens, the detector searches for the MWEs in the list.
static
<T extends IToken>
T
getFirstToken(Iterable<? extends T> tokens, Comparator<T> c)
          Returns the token that is the first in a given iterable collection of tokens.
static
<T extends IToken>
IMWE<T>
longest(IMWE<T> one, IMWE<T> two, Comparator<T> c)
          Compares two MWEs and returns the longest MWE.
 
Methods inherited from class edu.mit.jmwe.detect.HasMWEDetector
getWrappedDetector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.mit.jmwe.detect.IHasMWEDetector
getWrappedDetector
 

Constructor Detail

LMLR

public LMLR(IMWEDetector detector)
Constructs the detector from the backing detector. May not be null.

Parameters:
detector - the detector used to back this detector.
Since:
jMWE 1.0.0
Method Detail

detect

public <T extends IToken> List<IMWE<T>> detect(List<T> s)
Description copied from interface: IMWEDetector
Given a list of tokens, the detector searches for the MWEs in the list. It returns a set of IMWE objects representing these multi-word expressions. The method returns an empty list if no MWEs are found; the method should never return null.

Specified by:
detect in interface IMWEDetector
Overrides:
detect in class HasMWEDetector
Type Parameters:
T - the type of the tokens in the sentence
Parameters:
s - a sentence which the detector should search for multi-word expressions.
Returns:
a list of IMWE objects representing the multi-word expressions found in the sentence. Returns an empty list if no multi-word expressions are found; never returns null

getFirstToken

public static <T extends IToken> T getFirstToken(Iterable<? extends T> tokens,
                                                 Comparator<T> c)
Returns the token that is the first in a given iterable collection of tokens. Uses the given comparator to compare two tokens.

Type Parameters:
T - the type of tokens being compared
Parameters:
tokens - the tokens being compared
c - the comparator used to determine if one token comes before another
Returns:
the first token of the given tokens.
Since:
jMWE 1.0.0

longest

public static <T extends IToken> IMWE<T> longest(IMWE<T> one,
                                                 IMWE<T> two,
                                                 Comparator<T> c)
Compares two MWEs and returns the longest MWE. If they are the same size, returns the MWE that has more tokens to the left.

Type Parameters:
T - the type of tokens in the MWE
Parameters:
one - the first MWE
two - the second MWE
Returns:
the longest MWE. If they are the same size, returns the MWE that has more tokens to the left.
Since:
jMWE 1.0.0


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