public class GeneratorFactory
extends java.lang.Object
<generators> <charngram min = "2" max = "5"/> <definition/> <cache> <window prevLength = "3" nextLength = "3"> <generators> <prevmap/> <sentence/> <tokenclass/> <tokenpattern/> </generators> </window> </cache> </generators>
Each XML element is mapped to aGeneratorFactory.XmlFeatureGeneratorFactory
which
is responsible to process the element and create the specified
AdaptiveFeatureGenerator
. Elements can contain other
elements in this case it is the responsibility of the mapped factory to process
the child elements correctly. In some factories this leads to recursive
calls the
GeneratorFactory.XmlFeatureGeneratorFactory.create(Element, FeatureGeneratorResourceProvider)
method.
In the example above the generators element is mapped to the
GeneratorFactory.AggregatedFeatureGeneratorFactory
which then
creates all the aggregated AdaptiveFeatureGenerator
s to
accomplish this it evaluates the mapping with the same mechanism
and gives the child element to the corresponding factories. All
created generators are added to a new instance of the
AggregatedFeatureGenerator
which is then returned.Constructor and Description |
---|
GeneratorFactory() |
Modifier and Type | Method and Description |
---|---|
static AdaptiveFeatureGenerator |
create(java.io.InputStream xmlDescriptorIn,
FeatureGeneratorResourceProvider resourceManager)
Creates an
AdaptiveFeatureGenerator from an provided XML descriptor. |
static java.util.Map<java.lang.String,ArtifactSerializer<?>> |
extractCustomArtifactSerializerMappings(java.io.InputStream xmlDescriptorIn) |
static java.util.List<org.w3c.dom.Element> |
getDescriptorElements(java.io.InputStream xmlDescriptorIn)
Provides a list with all the elements in the xml feature descriptor.
|
public static AdaptiveFeatureGenerator create(java.io.InputStream xmlDescriptorIn, FeatureGeneratorResourceProvider resourceManager) throws java.io.IOException, InvalidFormatException
AdaptiveFeatureGenerator
from an provided XML descriptor.
Usually this XML descriptor contains a set of nested feature generators
which are then used to generate the features by one of the opennlp
components.xmlDescriptorIn
- the InputStream
from which the descriptor
is read, the stream remains open and must be closed by the caller.resourceManager
- the resource manager which is used to resolve resources
referenced by a key in the descriptorjava.io.IOException
- if an error occurs during reading from the descriptor
InputStream
InvalidFormatException
public static java.util.Map<java.lang.String,ArtifactSerializer<?>> extractCustomArtifactSerializerMappings(java.io.InputStream xmlDescriptorIn) throws java.io.IOException, InvalidFormatException
java.io.IOException
InvalidFormatException
public static java.util.List<org.w3c.dom.Element> getDescriptorElements(java.io.InputStream xmlDescriptorIn) throws java.io.IOException, InvalidFormatException
xmlDescriptorIn
- the xml feature descriptorjava.io.IOException
- if inputstream cannot be openInvalidFormatException
- if xml is not well-formedCopyright © 2010 - 2020 Adobe. All Rights Reserved