private void initializeTypes(JCas jCas) { if (windowClass != null) { windowType = JCasUtil.getType(jCas, windowClass); } typesInitialized = true; }
private void initializeTypes(JCas jCas) { if (tokenClass != null) { tokenType = JCasUtil.getType(jCas, tokenClass); } typesInitialized = true; }
private void initializeTypes(JCas jCas) throws AnalysisEngineProcessException { try { outputAnnotationType = JCasUtil.getType(jCas, outputAnnotationClass); if (blockAnnotationClass != null) { blockAnnotationType = JCasUtil.getType(jCas, blockAnnotationClass); } } catch (Exception e) { throw new AnalysisEngineProcessException(e); } typesInitialized = true; }
private void initializeTypes(JCas jCas) throws AnalysisEngineProcessException { try { outputAnnotationType = JCasUtil.getType(jCas, outputAnnotationClass); if (blockAnnotationClass != null) { blockAnnotationType = JCasUtil.getType(jCas, blockAnnotationClass); } } catch (Exception e) { throw new AnalysisEngineProcessException(e); } typesInitialized = true; }
/** * Get an iterator over the given feature structure type. * * @param <T> * the JCas type. * @param jCas * a JCas. * @param type * a type. * @return a return value. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static <T extends TOP> Iterator<T> iterator(JCas jCas, Class<T> type) { return (Iterator) FSCollectionFactory.create(jCas.getCas(), getType(jCas, type)).iterator(); }
/** * Get the single instance of the specified type from the JCas. * * @param <T> * JCas wrapper type. * @param jCas * a JCas containing the annotation. * @param type * a UIMA type. * @return the single instance of the given type. throws IllegalArgumentException if not exactly * one instance if the given type is present. */ @SuppressWarnings("unchecked") public static <T extends TOP> T selectSingle(JCas jCas, Class<T> type) { return (T) CasUtil.selectSingle(jCas.getCas(), getType(jCas, type)); }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); token = new TreeSet<>(); outcomes = new TreeSet<>(); vocabularyFile = new File(targetFolder, DeepLearningConstants.FILENAME_VOCABULARY); outcomeFile = new File(targetFolder, DeepLearningConstants.FILENAME_OUTCOMES); try { JCas typeFactory = JCasFactory.createJCas(); Type type = JCasUtil.getType(typeFactory, Class.forName(instanceTypeName)); AnnotationFS createAnnotation = typeFactory.getCas().createAnnotation(type, 0, 0); instanceType = createAnnotation.getType(); } catch (Exception e) { throw new ResourceInitializationException(e); } }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); outputFile = new File(targetFolder, DeepLearningConstants.FILENAME_MAXIMUM_LENGTH); try { JCas typeFactory = JCasFactory.createJCas(); Type type = JCasUtil.getType(typeFactory, Class.forName(instanceTypeName)); AnnotationFS createAnnotation = typeFactory.getCas().createAnnotation(type, 0, 0); instanceType = createAnnotation.getType(); } catch (Exception e) { throw new ResourceInitializationException(e); } }
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); outputFile = new File(targetFolder, DeepLearningConstants.FILENAME_MAXIMUM_LENGTH); try { JCas typeFactory = JCasFactory.createJCas(); Type type = JCasUtil.getType(typeFactory, Class.forName(instanceTypeName)); AnnotationFS createAnnotation = typeFactory.getCas().createAnnotation(type, 0, 0); instanceType = createAnnotation.getType(); } catch (Exception e) { throw new ResourceInitializationException(e); } }
public static <T extends TOP> T createFeatureStructure(JCas jcas, Class<T> cls) { T fs = jcas.getCas().createFS(JCasUtil.getType(jcas, cls)); fs.addToIndexes(); return fs; }
/** * Convenience method to iterator over all features structures of a given type. * * @param <T> * the iteration type. * @param jCas * the JCas containing the type system. * @param type * the type. * @return A collection of the selected type. * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a> */ public static <T extends TOP> Collection<T> select(final JCas jCas, final Class<T> type) { return cast(CasUtil.selectFS(jCas.getCas(), getType(jCas, type))); }
/** * Get all annotations of the given type at the specified offsets. * * @param <T> * the type of annotations to fetch. * @param jCas * the CAS containing the annotations. * @param type * the type of annotations to fetch. * @param aBegin * the begin offset. * @param aEnd * the end offset. * @return the annotations at the specified offsets. */ public static <T extends Annotation> List<T> selectAt(final JCas jCas, final Class<T> type, int aBegin, int aEnd) { return cast(CasUtil.selectAt(jCas.getCas(), getType(jCas, type), aBegin, aEnd)); }
@SuppressWarnings("unchecked") public static <T extends Annotation> FeaturePathIterator<T> create(JCas aJCas, Class<T> aAnchor, String aPath) throws FeaturePathException { Type t = JCasUtil.getType(aJCas, aAnchor); FSIterator<T> iterator = ((AnnotationIndex<T>) aJCas.getAnnotationIndex(t)).iterator(); final FeaturePathInfo fp = new FeaturePathInfo(); fp.initialize(aPath); return new FeaturePathIterator<T>(iterator, fp); }
@SuppressWarnings("unchecked") public static <T extends Annotation> FeaturePathIterator<T> create(JCas aJCas, Class<T> aAnchor, String aPath) throws FeaturePathException { Type t = JCasUtil.getType(aJCas, aAnchor); FSIterator<T> iterator = ((AnnotationIndex<T>) aJCas.getAnnotationIndex(t)).iterator(); final FeaturePathInfo fp = new FeaturePathInfo(); fp.initialize(aPath); return new FeaturePathIterator<T>(iterator, fp); }
protected <T extends TOP> T getFeatureStructure(JCas jcas, XMLElement hAnno, Element elm, Rule<T> mapping) { T annotation = null; if (mapping.isUnique()) { annotation = getOrCreate(jcas, mapping.getTargetClass()); } else { annotation = (T) jcas.getCas().createFS(JCasUtil.getType(jcas, mapping.getTargetClass())); jcas.getCas().addFsToIndexes(annotation); if (Annotation.class.isAssignableFrom(mapping.getTargetClass())) { ((Annotation) annotation).setBegin(hAnno.getBegin()); ((Annotation) annotation).setEnd(hAnno.getEnd()); } if (elm.hasAttr("xml:id") && !exists(elm.attr("xml:id"))) { String id = elm.attr("xml:id"); idRegistry.put(id, new AbstractMap.SimpleEntry<Element, FeatureStructure>(elm, annotation)); } } return annotation; }
protected <T extends TOP> T getFeatureStructure(JCas jcas, XMLElement hAnno, Element elm, Rule<T> mapping) { T annotation = null; if (mapping.isUnique()) { annotation = getOrCreate(jcas, mapping.getTargetClass()); } else { annotation = jcas.getCas().createFS(JCasUtil.getType(jcas, mapping.getTargetClass())); jcas.getCas().addFsToIndexes(annotation); if (Annotation.class.isAssignableFrom(mapping.getTargetClass())) { ((Annotation) annotation).setBegin(hAnno.getBegin()); ((Annotation) annotation).setEnd(hAnno.getEnd()); } if (elm.hasAttr("xml:id") && !exists(elm.attr("xml:id"))) { String id = elm.attr("xml:id"); idRegistry.put(id, new AbstractMap.SimpleEntry<Element, FeatureStructure>(elm, annotation)); } } return annotation; }
public static <T extends TOP> T getOrCreate(JCas jcas, Class<T> targetClass) { if (JCasUtil.exists(jcas, targetClass)) { return JCasUtil.selectSingle(jcas, targetClass); } else { T annotation = jcas.getCas().createFS(JCasUtil.getType(jcas, targetClass)); jcas.getCas().addFsToIndexes(annotation); return annotation; } } }
public static <T extends TOP> T getOrCreate(JCas jcas, Class<T> targetClass) { if (JCasUtil.exists(jcas, targetClass)) { return JCasUtil.selectSingle(jcas, targetClass); } else { T annotation = jcas.getCas().createFS(JCasUtil.getType(jcas, targetClass)); jcas.getCas().addFsToIndexes(annotation); return annotation; } } }
public static <T extends TOP> T getOrCreate(JCas jcas, Class<T> targetClass) { if (JCasUtil.exists(jcas, targetClass)) { return JCasUtil.selectSingle(jcas, targetClass); } else { T annotation = (T) jcas.getCas().createFS(JCasUtil.getType(jcas, targetClass)); jcas.getCas().addFsToIndexes(annotation); return annotation; } } }