edu.mit.jmwe.detect
Class ConstrainLength
java.lang.Object
edu.mit.jmwe.detect.HasMWEDetector
edu.mit.jmwe.detect.FilterByScore
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
Constructor Summary |
ConstrainLength(IMWEDetector detector,
int length,
boolean isMaxLength)
Construct a new filter on top of the specified detector |
Method Summary |
protected
|
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
length
protected final int length
isMaxLength
protected final boolean isMaxLength
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
flagisMaxLength
- 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
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.