/** * Creates a {@link FsIndexCollection} from all index descriptions that can be found via the * pattern specified in the system property {@code org.apache.uima.fit.fsindex.import_pattern} or * via the {@code META-INF/org.apache.uima.fit/fsindexes.txt} files in the classpath. * * @return the auto-scanned indexes. * @throws ResourceInitializationException * if the index collection could not be assembled */ public static FsIndexCollection createFsIndexCollection() throws ResourceInitializationException { List<FsIndexDescription> fsIndexList = new ArrayList<FsIndexDescription>(); for (String location : scanIndexDescriptors()) { try { XMLInputSource xmlInput = new XMLInputSource(location); FsIndexCollection fsIdxCol = getXMLParser().parseFsIndexCollection(xmlInput); fsIdxCol.resolveImports(); fsIndexList.addAll(asList(fsIdxCol.getFsIndexes())); LogFactory.getLog(FsIndexFactory.class).debug("Detected index at [" + location + "]"); } catch (IOException e) { throw new ResourceInitializationException(e); } catch (InvalidXMLException e) { LogFactory.getLog(FsIndexFactory.class).warn( "[" + location + "] is not a index descriptor file. Ignoring.", e); } } return createFsIndexCollection(fsIndexList.toArray(new FsIndexDescription[fsIndexList.size()])); }
/** * @param featureName * the feature to index * @return the index key description */ public static FsIndexKeyDescription createFsIndexKeyDescription(String featureName) { return createFsIndexKeyDescription(featureName, STANDARD_COMPARE); }
keys.add(createFsIndexKeyDescription(anIndexKey.featureName(), anIndexKey.comparator())); fsIndexCollection.addFsIndex(createFsIndexDescription(anIdx.label(), anIdx.kind(), typeName, anIdx.typePriorities(), keys.toArray(new FsIndexKeyDescription[keys.size()])));
/** * 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(); }
desc.getCollectionReaderMetaData().setFsIndexCollection(indexes); } else { desc.getCollectionReaderMetaData().setFsIndexCollection(createFsIndexCollection(readerClass));
fsIndexes.add(indexes); fsIndexes.add(FsIndexFactory.createFsIndexCollection(componentClass)); FsIndexCollection aggIndexColl = CasCreationUtils.mergeFsIndexes(fsIndexes, ResourceManagerFactory.newResourceManager());