|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.cmu.minorthird.text.learn.SpanFE
public abstract class SpanFE
A Feature Extractor which converts a Span to an Instance.
Typical use of this would be something like the following:
Generally, to use this class, one subclasses it and implements the
extractFeatures method, using a chain of feature-extracting actions which
starts with 'from' and ends with 'emit'.
SpanFE fe=new SpanFE(labels){
public void extractFeatures(Span span){
from(span).tokens().emit();
from(span).left().subSpan(-2,2).emit();
from(span).right().subSpan(0,2).emit();
from(span).right().contains("obj").emit();
}
};
Instance inst=fe.extractInstance(span);
The methods tokens(), subSpan(), and so on are defined in subclasses of SpanFE.Result, and are summarized here.
Nested Class Summary | |
---|---|
static class |
SpanFE.Filter
An abstract class that can be used to filter SpanSetResults. |
static class |
SpanFE.Function
An abstract class that can be used to change SpanSets |
static class |
SpanFE.Result
Encodes an intermediate result of the SpanFE process. |
static class |
SpanFE.SetResult<T>
An intermediate result of a SpanFE process where the object being operated on is a Set of something. |
static class |
SpanFE.SpanResult
An intermediate result of an SpanFE process where a span is being processed. |
static class |
SpanFE.SpanSetResult
An intermediate result of a SpanFE process where the object being operated on is a set of spans. |
static class |
SpanFE.StringBagResult
An intermediate result of a SpanFE process where the object being operated on is a set of strings. |
static class |
SpanFE.TokenSetResult
An intermediate result of a SpanFE process where the object being operated on is a set of tokens. |
Field Summary | |
---|---|
protected AnnotatorLoader |
annotatorLoader
|
protected MutableInstance |
instance
|
protected java.lang.String |
requiredAnnotation
|
protected java.lang.String |
requiredAnnotationFileToLoad
|
static int |
STORE_AS_BINARY
Store features as binary, whenever possible, even if occurence counts are ignored. |
static int |
STORE_AS_COUNTS
Store features as numeric counts, whenever possible |
static int |
STORE_COMPACTLY
Store features as binary or counts, trying to reduce storage while maintaining information. |
Constructor Summary | |
---|---|
SpanFE()
Create a feature extractor |
Method Summary | |
---|---|
void |
emit(SpanFE.SpanResult result)
Called by some SpanFE.Result subclass when a 'pipeline' of extraction steps is ended with a SpanResult. |
void |
emit(SpanFE.SpanSetResult result)
Called by some SpanFE.Result subclass when a 'pipeline' of extraction steps is ended with a SpanSetResult. |
void |
emit(SpanFE.StringBagResult result)
Called by some SpanFE.Result subclasses when a 'pipeline' of extraction steps is ended with a StringBagResult. |
void |
emit(SpanFE.TokenSetResult result)
Called by some SpanFE.Result subclass when a 'pipeline' of extraction steps is ended with a TokenSetResult. |
void |
extractFeatures(Span span)
Implement this with a specific set of SpanFE 'pipelines'. |
abstract void |
extractFeatures(TextLabels labels,
Span span)
Implement this with a specific set of SpanFE 'pipelines'. |
Instance |
extractInstance(Span span)
Deprecated. Use extractInstance(TextLabels labels,Span s) |
Instance |
extractInstance(TextLabels labels,
Span span)
Extract an Instance from a span |
SpanFE.SpanResult |
from(Span s)
Starts a 'pipeline' of extraction steps, and adds the resulting features to the instance being built. |
static SpanFE.SpanResult |
from(Span s,
FeatureBuffer buffer)
Starts a 'pipeline' of extraction steps, and adds the resulting features to the instance being built. |
java.lang.String |
getAnnotationProvider()
|
java.lang.String |
getRequiredAnnotation()
Retrieve the annotation required by this SpanFeatureExtractor. |
void |
requireMyAnnotation(TextLabels labels)
Make sure the required annotation is present. |
void |
setAnnotationProvider(java.lang.String classNameOrMixupFileName)
Specify a mixup file or java class to use to provide the annotation. |
void |
setAnnotatorLoader(AnnotatorLoader newLoader)
Attach an annotatorLoader to the SpanFeatureExtractor, which is used to find the required Annotation (and any other Annotations that that it might recursively require.) |
void |
setFeatureStoragePolicy(int p)
Set the policy for creating features. |
void |
setRequiredAnnotation(java.lang.String requiredAnnotation)
Specify an annotator to run before feature generation. |
void |
setRequiredAnnotation(java.lang.String requiredAnnotation,
java.lang.String annotationProvider)
Simultaneously specify an annotator to run before feature generation and a mixup file or class that generates it. |
void |
trace(SpanFE.Result result)
Subclass this to change the tracing behavior. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int STORE_AS_BINARY
public static final int STORE_AS_COUNTS
public static final int STORE_COMPACTLY
protected transient MutableInstance instance
protected java.lang.String requiredAnnotation
protected java.lang.String requiredAnnotationFileToLoad
protected AnnotatorLoader annotatorLoader
Constructor Detail |
---|
public SpanFE()
Method Detail |
---|
public void setFeatureStoragePolicy(int p)
p
- should be one of SpanFE.STORE_AS_BINARY, SpanFE.STORE_AS_COUNTS,
SpanFE.STORE_COMPACTLYpublic void setRequiredAnnotation(java.lang.String requiredAnnotation, java.lang.String annotationProvider)
public void setRequiredAnnotation(java.lang.String requiredAnnotation)
setRequiredAnnotation
in interface MixupCompatible
public java.lang.String getRequiredAnnotation()
MixupCompatible
getRequiredAnnotation
in interface MixupCompatible
public void setAnnotationProvider(java.lang.String classNameOrMixupFileName)
public java.lang.String getAnnotationProvider()
public void setAnnotatorLoader(AnnotatorLoader newLoader)
MixupCompatible
setAnnotatorLoader
in interface MixupCompatible
public void requireMyAnnotation(TextLabels labels)
public final Instance extractInstance(Span span)
public final Instance extractInstance(TextLabels labels, Span span)
extractInstance
in interface SpanFeatureExtractor
public final SpanFE.SpanResult from(Span s)
As an example: fe.from(s).tokens(s).eq().emit()
adds
bag-of-words type features.
public static final SpanFE.SpanResult from(Span s, FeatureBuffer buffer)
This is intended to be used as an alternative to using the SpanFE class to build an Span2Instance converter, eg
fe=new Span2Instance(){
public extractInstance(Span s){
FeatureBuffer buf=new FeatureBuffer(s);
SpanFE.from(s,buf).tokens().emit();
SpanFE.from(s,buf).left().subspan(-2,2).emit();
SpanFE.from(s,buf).right().subspan(0,2).emit();
buf.getInstance();
}
}
public void emit(SpanFE.StringBagResult result)
public void emit(SpanFE.TokenSetResult result)
public void emit(SpanFE.SpanSetResult result)
public void emit(SpanFE.SpanResult result)
public void extractFeatures(Span span)
public abstract void extractFeatures(TextLabels labels, Span span)
public void trace(SpanFE.Result result)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |