edu.mit.jmwe.detect
Class ConstrainLength

java.lang.Object
  extended by edu.mit.jmwe.detect.HasMWEDetector
      extended by edu.mit.jmwe.detect.FilterByScore
          extended by edu.mit.jmwe.detect.ConstrainLength
All Implemented Interfaces:
IHasMWEDetector, IMWEDetector, IMWEDetectorFilter

public class ConstrainLength
extends FilterByScore

A detector filter that constrains MWEs by length.

Since:
jMWE 1.0.0
Version:
$Id$
Author:
M.A. Finlayson

Field Summary
protected  boolean isMaxLength
           
protected  int length
           
 
Constructor Summary
ConstrainLength(IMWEDetector detector, int length, boolean isMaxLength)
          Construct a new filter on top of the specified detector
 
Method Summary
protected
<T extends IToken>
IScorer<IMWE<T>>
getScorer(List<T> sentence)
          Returns a scoring function for the specified sentence.
protected  boolean isGoodScore(double score)
          Returns true if the score passes the filter (i.e., the scored MWE should be kept); false otherwise
 
Methods inherited from class edu.mit.jmwe.detect.FilterByScore
detect
 
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
 

Field Detail

length

protected final int length

isMaxLength

protected final boolean isMaxLength
Constructor Detail

ConstrainLength

public ConstrainLength(IMWEDetector detector,
                       int length,
                       boolean isMaxLength)
Construct a new filter on top of the specified detector

Parameters:
detector - the wrapped detector; may not be null
length - the length limit; either max or min depending on the isMaxLength flag
isMaxLength - true if the all MWEs with lengths greater than the specified length are to be discarded; false otherwise
Throws:
NullPointerException - if the detector is null
Since:
jMWE 1.0.0
Method Detail

isGoodScore

protected boolean isGoodScore(double score)
Description copied from class: FilterByScore
Returns true if the score passes the filter (i.e., the scored MWE should be kept); false otherwise

Specified by:
isGoodScore in class FilterByScore
Parameters:
score - the score to be checked
Returns:
true if the score passes the filter (i.e., the scored MWE should be kept); false otherwise

getScorer

protected <T extends IToken> IScorer<IMWE<T>> getScorer(List<T> sentence)
Description copied from class: FilterByScore
Returns a scoring function for the specified sentence.

Specified by:
getScorer in class FilterByScore
Type Parameters:
T - the type of token in the sentence
Parameters:
sentence - the sentence for which the scorer should be constructed
Returns:
a scorer for MWEs in the specified sentence


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