|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.washington.cs.knowitall.extractor.Extractor<S,T>
S
- T
- public abstract class Extractor<S,T>
An abstract class that defines the basic behavior of an extractor. An Extractor
object
extracts objects of type T
from a source object of type S
. Candidate extractions
are first obtained by calling the extractCandidates(S source)
method, which returns an
Iterable
object over extractions of type T
. These extractions are passed through
a list of Mapper
objects, each of which can filter or modify the extractions.
Other objects can use an Extractor
object by calling the extract(S source)
object, which returns an Iterable
object of extractions after the Mapper
s have
been applied.
Mapper
objects can be added to the list of Mapper
s by calling the
addMapper(Mapper
method. This will add a Mapper
to the end of the list
(i.e. it is the last one to be applied to the extractions).
Subclasses extending Extractor
must implement the abstract extractCandidates
method.
As an example, this class can be used to implement a class for extracting String
sentences from
a String
block of text. Mapper
objects can be added to filter the sentences by
length, or remove brackets from the sentences.
Constructor Summary | |
---|---|
Extractor()
Constructs a new extractor with no Mapper objects. |
Method Summary | ||
---|---|---|
void |
addMapper(Mapper<T> mapper)
Adds a Mapper object to the end of the list of mappers. |
|
static
|
compose(Extractor<R,S> rsExtractor,
Extractor<S,T> stExtractor)
Composes a R->S extractor with a S->T extractor to create
a R->T extractor. |
|
java.lang.Iterable<T> |
extract(java.lang.Iterable<S> sources)
|
|
java.lang.Iterable<T> |
extract(S source)
|
|
protected abstract java.lang.Iterable<T> |
extractCandidates(S source)
Extracts candidate extractions from the given source object. |
|
MapperList<T> |
getMappers()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Extractor()
Mapper
objects.
Method Detail |
---|
public MapperList<T> getMappers()
MapperList
object containing the mappers assigned to this extractor.public void addMapper(Mapper<T> mapper)
Mapper
object to the end of the list of mappers. It will be the new final
Mapper
object applied to the extractions, after the existing Mapper
s
have been applied.
mapper
- The mapper to add.protected abstract java.lang.Iterable<T> extractCandidates(S source)
extract(S source)
method, the extractCandidate(S source)
method is
used to generate a set of candidate extractions, which are then passed through each Mapper
object assigned to the extractor.
source
- The source to extract from.
Iterable
object over the candidate extractions.public java.lang.Iterable<T> extract(S source)
source
- the source object to extract from.
Iterable
object over extractions from source
.public java.lang.Iterable<T> extract(java.lang.Iterable<S> sources)
sources
- a collection of source objects to extract from.
Iterable
object over extractions from each of the sources.public static <R,S,T> Extractor<R,T> compose(Extractor<R,S> rsExtractor, Extractor<S,T> stExtractor)
R->S
extractor with a S->T
extractor to create
a R->T
extractor.
R
- S
- T
- rsExtractor
- stExtractor
-
R
and returning objects of type T
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |