/** * Create a TypePriorities given a sequence of ordered type classes * * @param prioritizedTypes * a sequence of ordered type classes * @return type priorities created from the ordered JCas classes */ public static TypePriorities createTypePriorities(Class<?>... prioritizedTypes) { String[] typeNames = new String[prioritizedTypes.length]; for (int i = 0; i < prioritizedTypes.length; i++) { String typeName = prioritizedTypes[i].getName(); if (typeName.startsWith(UIMA_BUILTIN_JCAS_PREFIX)) { typeName = "uima." + typeName.substring(UIMA_BUILTIN_JCAS_PREFIX.length()); } typeNames[i] = typeName; } return createTypePriorities(typeNames); }
for (String location : scanTypePrioritiesDescriptors()) { try { XMLInputSource xmlInput = new XMLInputSource(location);
/** * @param readerClass * The class of the CollectionReader to be created. * @param typeSystem * A description of the types used by the CollectionReader (may be null). * @param prioritizedTypeNames * the type names in order of their priority. * @param configurationData * configuration parameter data as name value pairs. Will override values already set in * the description. * @return the description created from the default parameters specified in the class and the * configuration parameters * @throws ResourceInitializationException * if the descriptor could not be set up */ public static CollectionReaderDescription createReaderDescription( Class<? extends CollectionReader> readerClass, TypeSystemDescription typeSystem, String[] prioritizedTypeNames, Object... configurationData) throws ResourceInitializationException { TypePriorities typePriorities = createTypePriorities(prioritizedTypeNames); return createReaderDescription(readerClass, typeSystem, typePriorities, configurationData); }
private void loadTypePriorities(AnyObject config) { AnyObject tpObject = config.getAnyObject("type-priorities"); if (tpObject == null) { return; } try { String[] typePrioritiesArray = getFromListOrInherit(tpObject, "type-list"); this.typePriorities = TypePrioritiesFactory.createTypePriorities(typePrioritiesArray); } catch (IOException e) { System.err.println("Failed to load type-priorities."); e.printStackTrace(); } }
/** * Get a CollectionReader from a CollectionReader class, a type system, and a set of configuration * parameters. * * @param readerClass * The class of the CollectionReader to be created. * @param typeSystem * A description of the types used by the CollectionReader (may be null). * @param prioritizedTypeNames * the type names in order of their priority. * @param configurationData * Any additional configuration parameters to be set. These should be supplied as (name, * value) pairs, so there should always be an even number of parameters. * @return The CollectionReader created and initialized with the type system and configuration * parameters. * @deprecated use {@link #createReaderDescription(Class, TypeSystemDescription, String[], Object...)} * @throws ResourceInitializationException * if the component could not be initialized */ @Deprecated public static CollectionReader createReader( Class<? extends CollectionReader> readerClass, TypeSystemDescription typeSystem, String[] prioritizedTypeNames, Object... configurationData) throws ResourceInitializationException { TypePriorities typePriorities = createTypePriorities(prioritizedTypeNames); return createReader(readerClass, typeSystem, typePriorities, configurationData); }
/** * Create and configure a primitive {@link AnalysisEngine}. * * @param componentClass * a class that extends {@link AnalysisComponent} e.g. via * {@link org.apache.uima.fit.component.JCasAnnotator_ImplBase} * @param typeSystem * A description of the types (may be null). * @param typePriorities * The type priorities as an array of type names (may be null). * @param configurationData * Any additional configuration parameters to be set. These should be supplied as (name, * value) pairs, so there should always be an even number of parameters. * @return an {@link AnalysisEngine} created from the specified component class and initialized * with the configuration parameters. * @throws ResourceInitializationException * if a failure occurred during production of the resource. * @see <a href="package-summary.html#InstancesVsDescriptors">Why are descriptors better than * component instances?</a> */ public static AnalysisEngine createEngine(Class<? extends AnalysisComponent> componentClass, TypeSystemDescription typeSystem, String[] typePriorities, Object... configurationData) throws ResourceInitializationException { TypePriorities tp = null; if (typePriorities != null) { tp = TypePrioritiesFactory.createTypePriorities(typePriorities); } return createEngine(componentClass, typeSystem, tp, configurationData); }
/** * @return a part of speech tagger using a default model * @throws ResourceInitializationException - */ public static AnalysisEngineDescription createAnnotatorDescription() throws ResourceInitializationException { return AnalysisEngineFactory.createEngineDescription( ThreadSafePosTagger.class, TypeSystemDescriptionFactory.createTypeSystemDescription(), TypePrioritiesFactory.createTypePriorities( Segment.class, Sentence.class, BaseToken.class ) ); }
public static AnalysisEngineDescription createAnnotatorDescription() throws ResourceInitializationException { return AnalysisEngineFactory.createEngineDescription( POSTagger.class, TypeSystemDescriptionFactory .createTypeSystemDescription(), TypePrioritiesFactory .createTypePriorities(Segment.class, Sentence.class, BaseToken.class)); }
public static AnalysisEngineDescription createAnnotatorDescription( String model) throws ResourceInitializationException { return AnalysisEngineFactory.createEngineDescription( POSTagger.class, TypeSystemDescriptionFactory .createTypeSystemDescription(), TypePrioritiesFactory .createTypePriorities(Segment.class, Sentence.class, BaseToken.class), POSTagger.PARAM_POS_MODEL_FILE, model); } }
public static AnalysisEngineDescription createAnnotatorDescription( String model) throws ResourceInitializationException { return AnalysisEngineFactory.createEngineDescription( POSTagger.class, TypeSystemDescriptionFactory .createTypeSystemDescription(), TypePrioritiesFactory .createTypePriorities(Segment.class, Sentence.class, BaseToken.class), POSTagger.PARAM_POS_MODEL_FILE, model); } }
public static AnalysisEngineDescription createAnnotatorDescription() throws ResourceInitializationException { return AnalysisEngineFactory.createEngineDescription( POSTagger.class, TypeSystemDescriptionFactory .createTypeSystemDescription(), TypePrioritiesFactory .createTypePriorities(Segment.class, Sentence.class, BaseToken.class)); }
/** * @param model a part of speech model * @return a part of speech tagger using the given model * @throws ResourceInitializationException - */ public static AnalysisEngineDescription createAnnotatorDescription( final String model ) throws ResourceInitializationException { return AnalysisEngineFactory.createEngineDescription( ThreadSafePosTagger.class, TypeSystemDescriptionFactory.createTypeSystemDescription(), TypePrioritiesFactory.createTypePriorities( Segment.class, Sentence.class, BaseToken.class ), POSTagger.PARAM_POS_MODEL_FILE, model ); }
/** * Create and configure a primitive {@link AnalysisEngine}. The type system is detected * automatically using {@link TypeSystemDescriptionFactory#createTypeSystemDescription()}. Type * priorities are detected automatically using * {@link TypePrioritiesFactory#createTypePriorities()}. Indexes are detected automatically using * {@link FsIndexFactory#createFsIndexCollection()}. * * @param componentClass * a class that extends {@link AnalysisComponent} e.g. via * {@link org.apache.uima.fit.component.JCasAnnotator_ImplBase} * @param configurationData * Any additional configuration parameters to be set. These should be supplied as (name, * value) pairs, so there should always be an even number of parameters. * @return a description for this analysis engine. * @throws ResourceInitializationException * if a failure occurred during production of the resource. */ public static AnalysisEngineDescription createEngineDescription( Class<? extends AnalysisComponent> componentClass, Object... configurationData) throws ResourceInitializationException { TypeSystemDescription typeSystem = createTypeSystemDescription(); TypePriorities typePriorities = createTypePriorities(); FsIndexCollection fsIndexCollection = createFsIndexCollection(); return createEngineDescription(componentClass, typeSystem, typePriorities, fsIndexCollection, (Capability[]) null, configurationData); }
/** * Creates a new {@link JCas}. The type system is detected automatically using * {@link TypeSystemDescriptionFactory#createTypeSystemDescription()}. Type priorities are * detected automatically using {@link TypePrioritiesFactory#createTypePriorities()}. Indexes are * detected automatically using {@link FsIndexFactory#createFsIndexCollection()}. * * @return a new JCas * @throws UIMAException * if the JCas could not be initialized */ public static JCas createJCas() throws UIMAException { TypeSystemDescription tsd = createTypeSystemDescription(); TypePriorities tp = createTypePriorities(); FsIndexCollection indexes = createFsIndexCollection(); ResourceManager resMgr = ResourceManagerFactory.newResourceManager(); return CasCreationUtils.createCas(tsd, tp, indexes.getFsIndexes(), null, resMgr).getJCas(); }