Java Code Examples for org.apache.uima.fit.factory.ExternalResourceFactory#bindResource()
The following examples show how to use
org.apache.uima.fit.factory.ExternalResourceFactory#bindResource() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomResourceTermSuiteAEFactory.java From termsuite-core with Apache License 2.0 | 6 votes |
public static AnalysisEngineDescription createNormalizerAEDesc(ResourceConfig resourceConfig, Lang lang, Tagger tagger) { AnalysisEngineDescription ae; try { ae = AnalysisEngineFactory.createEngineDescription( Lexer.class, Lexer.PARAM_TYPE, "fr.univnantes.termsuite.types.WordAnnotation" ); ExternalResourceDescription segmentBank = ExternalResourceFactory.createExternalResourceDescription( SegmentBankResource.class, getResourceURL(resourceConfig, ResourceType.SEGMENT_BANK, lang) ); ExternalResourceFactory.bindResource( ae, SegmentBank.KEY_SEGMENT_BANK, segmentBank); return ae; } catch (Exception e) { throw new TermSuiteException(e); } }
Example 2
Source File: CustomResourceTermSuiteAEFactory.java From termsuite-core with Apache License 2.0 | 6 votes |
public static AnalysisEngineDescription createWordTokenizerAEDesc(ResourceConfig resourceConfig, Lang lang) { AnalysisEngineDescription ae; try { ae = AnalysisEngineFactory.createEngineDescription( Lexer.class, Lexer.PARAM_TYPE, "fr.univnantes.termsuite.types.WordAnnotation" ); ExternalResourceDescription segmentBank = ExternalResourceFactory.createExternalResourceDescription( SegmentBankResource.class, getResourceURL(resourceConfig, ResourceType.SEGMENT_BANK, lang) ); ExternalResourceFactory.bindResource( ae, SegmentBank.KEY_SEGMENT_BANK, segmentBank); return ae; } catch (Exception e) { throw new TermSuiteException(e); } }
Example 3
Source File: CustomResourceTermSuiteAEFactory.java From termsuite-core with Apache License 2.0 | 6 votes |
/** * Spots fixed expressions in the CAS an creates {@link FixedExpression} * annotation whenever one is found. * * @return */ public static AnalysisEngineDescription createFixedExpressionSpotterAEDesc(ResourceConfig resourceConfig, Lang lang) { try { AnalysisEngineDescription ae = AnalysisEngineFactory.createEngineDescription( FixedExpressionSpotter.class, FixedExpressionSpotter.FIXED_EXPRESSION_MAX_SIZE, 5, FixedExpressionSpotter.REMOVE_WORD_ANNOTATIONS_FROM_CAS, false, FixedExpressionSpotter.REMOVE_TERM_OCC_ANNOTATIONS_FROM_CAS, true ); ExternalResourceDescription fixedExprRes = ExternalResourceFactory.createExternalResourceDescription( FixedExpressionResource.class, getResourceURL(resourceConfig, ResourceType.FIXED_EXPRESSIONS, lang)); ExternalResourceFactory.bindResource( ae, FixedExpressionResource.FIXED_EXPRESSION_RESOURCE, fixedExprRes ); return ae; } catch (Exception e) { throw new PreparationPipelineException(e); } }
Example 4
Source File: CustomResourceTermSuiteAEFactory.java From termsuite-core with Apache License 2.0 | 6 votes |
private static AnalysisEngineDescription createSubNormalizerAEDesc(String target, URL mappingFile) { try { AnalysisEngineDescription ae = AnalysisEngineFactory.createEngineDescription( Mapper.class, Mapper.PARAM_SOURCE, "fr.univnantes.termsuite.types.WordAnnotation:tag", Mapper.PARAM_TARGET, target, Mapper.PARAM_UPDATE, true ); ExternalResourceDescription mappingRes = ExternalResourceFactory.createExternalResourceDescription( MappingResource.class, mappingFile ); ExternalResourceFactory.bindResource( ae, Mapping.KEY_MAPPING, mappingRes ); return ae; } catch (Exception e) { throw new PreparationPipelineException(e); } }
Example 5
Source File: FixedExpressionSpotterSpec.java From termsuite-core with Apache License 2.0 | 6 votes |
private AnalysisEngine makeAE(boolean removeWordAnnotationFromCas, boolean removeTermOccAnnotationFromCas) throws Exception { AnalysisEngineDescription aeDesc = AnalysisEngineFactory.createEngineDescription( FixedExpressionSpotter.class, FixedExpressionSpotter.FIXED_EXPRESSION_MAX_SIZE, 5, FixedExpressionSpotter.REMOVE_WORD_ANNOTATIONS_FROM_CAS, removeWordAnnotationFromCas, FixedExpressionSpotter.REMOVE_TERM_OCC_ANNOTATIONS_FROM_CAS, removeTermOccAnnotationFromCas ); /* * The term index resource */ ExternalResourceDescription fixedExpressionDesc = ExternalResourceFactory.createExternalResourceDescription( FixedExpressionResource.FIXED_EXPRESSION_RESOURCE, FixedExpressionResource.class, "file:fr/univnantes/termsuite/test/resources/french-fixed-expressions.txt" ); ExternalResourceFactory.bindResource(aeDesc, fixedExpressionDesc); AnalysisEngine ae = AnalysisEngineFactory.createEngine(aeDesc); return ae; }
Example 6
Source File: CustomResourceTermSuiteAEFactory.java From termsuite-core with Apache License 2.0 | 5 votes |
public static AnalysisEngineDescription createTreeTaggerAEDesc(ResourceConfig resourceConfig, Lang lang, Path treeTaggerPath) { try { AnalysisEngineDescription treeTaggerAE = AnalysisEngineFactory.createEngineDescription( TreeTaggerWrapper.class, TreeTaggerWrapper.PARAM_ANNOTATION_TYPE, "fr.univnantes.termsuite.types.WordAnnotation", TreeTaggerWrapper.PARAM_TAG_FEATURE, "tag", TreeTaggerWrapper.PARAM_LEMMA_FEATURE, "lemma", TreeTaggerWrapper.PARAM_UPDATE_ANNOTATION_FEATURES, true, TreeTaggerWrapper.PARAM_TT_HOME_DIRECTORY, treeTaggerPath.toString() ); ExternalResourceDescription ttParam = ExternalResourceFactory.createExternalResourceDescription( TreeTaggerParameter.class, getResourceURL(resourceConfig, ResourceType.TREETAGGER_CONFIG, lang, Tagger.TREE_TAGGER) ); ExternalResourceFactory.bindResource( treeTaggerAE, TreeTaggerParameter.KEY_TT_PARAMETER, ttParam ); AnalysisEngineDescription lemmaFixerAE = AnalysisEngineFactory.createEngineDescription( TreeTaggerLemmaFixer.class, TreeTaggerLemmaFixer.LANGUAGE, lang.getCode() ); AnalysisEngineDescription normalizerAE = createNormalizerAE(resourceConfig, lang, Tagger.TREE_TAGGER); return AnalysisEngineFactory.createEngineDescription( treeTaggerAE, lemmaFixerAE, normalizerAE); } catch (Exception e) { throw new TermSuiteException(e); } }
Example 7
Source File: CustomResourceTermSuiteAEFactory.java From termsuite-core with Apache License 2.0 | 4 votes |
public static AnalysisEngineDescription createRegexSpotterAEDesc(ResourceConfig resourceConfig, Lang lang) { try { AnalysisEngineDescription ae = AnalysisEngineFactory.createEngineDescription( RegexSpotter.class, TokenRegexAE.PARAM_ALLOW_OVERLAPPING_OCCURRENCES, true ); addParameters( ae, RegexSpotter.LOG_OVERLAPPING_RULES, false); ExternalResourceDescription mwtRules = ExternalResourceFactory.createExternalResourceDescription( RegexListResource.class, getResourceURL(resourceConfig, ResourceType.MWT_RULES, lang)); ExternalResourceFactory.bindResource( ae, RegexListResource.KEY_TOKEN_REGEX_RULES, mwtRules ); if(lang != Lang.ZH) { ExternalResourceDescription allowedCharsRes = ExternalResourceFactory.createExternalResourceDescription( CharacterFootprintTermFilter.class, getResourceURL(resourceConfig, ResourceType.ALLOWED_CHARS, lang)); ExternalResourceFactory.bindResource( ae, RegexSpotter.CHARACTER_FOOTPRINT_TERM_FILTER, allowedCharsRes ); } ExternalResourceDescription stopWordsRes = ExternalResourceFactory.createExternalResourceDescription( DefaultFilterResource.class, getResourceURL(resourceConfig, ResourceType.STOP_WORDS_FILTER, lang)); ExternalResourceFactory.bindResource( ae, RegexSpotter.STOP_WORD_FILTER, stopWordsRes ); return ae; } catch(Exception e) { throw new TermSuiteException(e); } }