in ConceptMapper/src/main/java/org/apache/uima/conceptMapper/ConceptMapper.java [252:349]
public void initialize(UimaContext uimaContext) throws ResourceInitializationException {
super.initialize(uimaContext);
// Process configration parameters
try {
// logger = new Logger (annotatorContext.getLogger ());
logger = new Logger("ConceptMapper", uimaContext.getLogger());
// tokenDebugFile = new FileWriter("/tmp/cm/tokens."+
// Calendar.getInstance ().getTimeInMillis () + ".txt");
// potentialMatchDebugFile = new FileWriter("/tmp/cm/pm."+
// Calendar.getInstance ().getTimeInMillis () + ".txt");
// findMatchDebugFile = new FileWriter("/tmp/cm/fm."+
// Calendar.getInstance ().getTimeInMillis () + ".txt");
// FileWriter dictDebugFile = new FileWriter("/tmp/cm/dict."+
// Calendar.getInstance ().getTimeInMillis () + ".txt");
tokenAnnotationName = (String) uimaContext
.getConfigParameterValue(PARAM_TOKENANNOTATION);
String tokenizerDescriptor = (String) uimaContext
.getConfigParameterValue(PARAM_TOKENIZERDESCRIPTOR);
tokenClassFeatureName = (String) uimaContext
.getConfigParameterValue(PARAM_TOKENCLASSFEATURENAME);
tokenTypeFeatureName = (String) uimaContext
.getConfigParameterValue(PARAM_TOKENTYPEFEATURENAME);
resultAnnotationName = (String) uimaContext
.getConfigParameterValue(PARAM_ANNOTATION_NAME);
resultEnclosingSpanName = (String) uimaContext
.getConfigParameterValue(PARAM_ENCLOSINGSPAN);
resultMatchedTextFeatureName = (String) uimaContext
.getConfigParameterValue(PARAM_MATCHEDFEATURE);
featureNames = (String[]) uimaContext.getConfigParameterValue(PARAM_FEATURE_LIST);
attributeNames = (String[]) uimaContext.getConfigParameterValue(PARAM_ATTRIBUTE_LIST);
spanFeatureStructureName = (String) uimaContext
.getConfigParameterValue(PARAM_DATA_BLOCK_FS);
tokenTextFeatureName = (String) uimaContext
.getConfigParameterValue(PARAM_TOKENTEXTFEATURENAME);
tokenClassWriteBackFeatureNames = (String[]) uimaContext
.getConfigParameterValue(PARAM_TOKENCLASSWRITEBACKFEATURENAMES);
tokenAnnotationName = (String) uimaContext
.getConfigParameterValue(PARAM_TOKENANNOTATION);
matchedTokensFeatureName = (String) uimaContext
.getConfigParameterValue(PARAM_MATCHEDTOKENSFEATURENAME);
Boolean sortElementsParam = (Boolean) uimaContext
.getConfigParameterValue(PARAM_ORDERINDEPENDENTLOOKUP);
sortElements = (sortElementsParam == null) ? false : sortElementsParam.booleanValue();
searchStrategy = detectSearchStrategy((String) uimaContext
.getConfigParameterValue(PARAM_SEARCHSTRATEGY));
// System.err.println("SEARCH STRATEGY = " + searchStrategy);
Boolean findAllMatchesParam = (Boolean) uimaContext
.getConfigParameterValue(PARAM_FINDALLMATCHES);
findAllMatches = (findAllMatchesParam == null) ? false : findAllMatchesParam.booleanValue();
// always do order-independent lookup if performing "SkipAnyMatch"
// lookups
if (searchStrategy == SkipAnyMatch) {
sortElements = true;
}
if (featureNames.length != attributeNames.length) {
throw new Exception("AttributeList and FeatureList are inconsistent");
}
// for (int i = 0; i < featureNames.length; i++ )
// {
// logger.logInfo ("Attribute \"" + attributeNames [i] + "\" mapped
// to feature \"" + featureNames [i] + "\"");
// }
tokenNormalizer = new TokenNormalizer(uimaContext, logger);
tokenFilter = new TokenFilter(tokenAnnotationName, tokenTypeFeatureName,
tokenClassFeatureName, logger);
tokenFilter.initConfig(uimaContext);
dict = (DictionaryResource) uimaContext.getResourceObject(PARAM_DICT_FILE);
if (!dict.isLoaded()) {
// logger.logInfo("dictionary not yet loaded");
dict.loadDictionaryContents(uimaContext, logger, tokenAnnotationName,
tokenTypeFeatureName, tokenClassFeatureName, tokenizerDescriptor);
// logger.logInfo( "now is loaded: "+dict.toString() );
// System.err.println ("NEW DICTIONARY:\n" + dict.toString());
// debugWrite (dictDebugFile, dict.toString());
}
} catch (Exception e) {
throw new ResourceInitializationException(e);
}
}