public final class DictionaryDescriptorParser
extends java.lang.Object
externalResource
for DictionaryDescriptorFile
in the XML descriptor for the Rare Word Term Lookup Annotator
DefaultJCasTermAnnotator
If there is a problem with the descriptor then the whole pipeline goes down, so care must be taken by the User
and any messages (logged or otherwise) produced by this class should be as specific as possible. Devs take notice.
Author: SPF
Affiliation: CHIP-NLP
Date: 11/20/13Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
CONCEPT_FACTORIES_KEY |
private static java.lang.String |
CONSUMER_KEY
XML key specifying the section that defines the single
TermConsumer that should be used to consume discovered terms. |
private static java.lang.String |
DICTIONARIES_KEY
XML keys specifying the main sections that define dictionaries, concept factories, and the pairing of the two
|
private static java.lang.Object[] |
EMPTY_OBJECT_ARRAY |
private static java.lang.String |
IMPLEMENTATION_KEY
|
private static Logger |
LOGGER |
private static int |
MAX_LIST_SIZE |
private static java.lang.String |
NAME_KEY
Each dictionary, concept factory, pairing and term consumer should have a unique name
|
private static java.lang.String |
PAIR_CONCEPT_FACTORY_NAME |
private static java.lang.String |
PAIR_DICTIONARY_NAME
pairings must have specified dictionaries and concept factories
|
private static java.lang.String |
PAIRS_KEY |
private static java.lang.String |
PROPERTIES_KEY
everything else is implementation-specific and therefore optional and therefore set as a property
|
Modifier | Constructor and Description |
---|---|
private |
DictionaryDescriptorParser()
A Utility Class cannot be instantiated
|
Modifier and Type | Method and Description |
---|---|
private static java.lang.String |
getName(java.lang.String elementName,
Element element) |
private static java.util.Map<java.lang.String,ConceptFactory> |
parseConceptFactories(UimaContext uimaContext,
Element conceptFactoriesElement)
Creates concept factories by parsing the section defined by {@link this.CONCEPT_FACTORY_KEY
|
private static ConceptFactory |
parseConceptFactory(UimaContext uimaContext,
Element conceptFactoryElement)
Creates a dictionary by parsing each child element of
this.DICTIONARIES_KEY |
private static TermConsumer |
parseConsumerXml(UimaContext uimaContext,
Element lookupConsumerElement)
Creates a term consumer by parsing section defined by
this.CONSUMER_KEY |
static DictionarySpec |
parseDescriptor(java.io.File descriptorFile,
UimaContext uimaContext)
Initiates the parsing of the XML descriptor file containing definition of dictionaries and a consumer for the
Rare Word Term dictionary paradigm
|
private static java.util.Map<java.lang.String,RareWordDictionary> |
parseDictionaries(UimaContext uimaContext,
Element dictionariesElement)
Creates dictionary engines by parsing the section defined by
this.DICTIONARIES_KEY |
private static RareWordDictionary |
parseDictionary(UimaContext uimaContext,
Element dictionaryElement)
Creates a dictionary by parsing each child element of
this.DICTIONARIES_KEY |
private static java.util.Map<java.lang.String,java.lang.String> |
parsePairingNames(Element pairingsElement,
java.lang.String pairingName) |
private static java.util.Properties |
parsePropertiesXml(Element propertiesElement)
Builds a collection of key, value properties
|
private static final Logger LOGGER
private static final java.lang.Object[] EMPTY_OBJECT_ARRAY
private static final java.lang.String DICTIONARIES_KEY
private static final java.lang.String CONCEPT_FACTORIES_KEY
private static final java.lang.String PAIRS_KEY
private static final java.lang.String CONSUMER_KEY
TermConsumer
that should be used to consume discovered terms.private static final java.lang.String NAME_KEY
private static final java.lang.String IMPLEMENTATION_KEY
private static final java.lang.String PAIR_DICTIONARY_NAME
private static final java.lang.String PAIR_CONCEPT_FACTORY_NAME
private static final java.lang.String PROPERTIES_KEY
private static final int MAX_LIST_SIZE
private DictionaryDescriptorParser()
public static DictionarySpec parseDescriptor(java.io.File descriptorFile, UimaContext uimaContext) throws AnnotatorContextException
descriptorFile
- XML-formatted file, see the dictionary-lookup resources file RareWordTermsUMLS.xml
for an exampleuimaContext
- -DefaultDictionarySpec
with specification of dictionaries and a consumer as read from the
descriptorFile
AnnotatorContextException
- if the File could not be found/read or the xml could not be parsedprivate static java.util.Map<java.lang.String,RareWordDictionary> parseDictionaries(UimaContext uimaContext, Element dictionariesElement) throws AnnotatorContextException
this.DICTIONARIES_KEY
uimaContext
- -dictionariesElement
- contains definition of all dictionariesRareWordDictionary
instancesAnnotatorContextException
- if the resource specified by this.EXTERNAL_RESOURCE
does not match
the type specified by this.IMPLEMENTATION
or for some reason could not be usedprivate static RareWordDictionary parseDictionary(UimaContext uimaContext, Element dictionaryElement) throws AnnotatorContextException
this.DICTIONARIES_KEY
uimaContext
- -dictionaryElement
- contains the definition of a single dictionaryAnnotatorContextException
- if any of a dozen things goes wrongprivate static java.util.Map<java.lang.String,ConceptFactory> parseConceptFactories(UimaContext uimaContext, Element conceptFactoriesElement) throws AnnotatorContextException
uimaContext
- -conceptFactoriesElement
- contains definition of all concept factoriesConceptFactory
instancesAnnotatorContextException
- if the resource specified by this.EXTERNAL_RESOURCE
does not match
the type specified by this.IMPLEMENTATION
or for some reason could not be usedprivate static ConceptFactory parseConceptFactory(UimaContext uimaContext, Element conceptFactoryElement) throws AnnotatorContextException
this.DICTIONARIES_KEY
uimaContext
- -conceptFactoryElement
- contains the definition of a single dictionaryAnnotatorContextException
- if any of a dozen things goes wrongprivate static java.util.Map<java.lang.String,java.lang.String> parsePairingNames(Element pairingsElement, java.lang.String pairingName) throws AnnotatorContextException
pairingsElement
- -pairingName
- one of "dictionaryName" or "conceptFactoryName"AnnotatorContextException
- -private static java.lang.String getName(java.lang.String elementName, Element element) throws AnnotatorContextException
AnnotatorContextException
private static TermConsumer parseConsumerXml(UimaContext uimaContext, Element lookupConsumerElement) throws AnnotatorContextException
this.CONSUMER_KEY
uimaContext
- -lookupConsumerElement
- contains the definition of the term consumerAnnotatorContextException
- if any of a dozen things goes wrongprivate static java.util.Properties parsePropertiesXml(Element propertiesElement)
propertiesElement
- element with key, value pairs