org.apache.uima.cas.Type Java Examples

The following examples show how to use org.apache.uima.cas.Type. 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: Tsv3XCasSchemaAnalyzer.java    From webanno with Apache License 2.0 6 votes vote down vote up
public static boolean isRelationLayer(Type aType)
{
    Feature relSourceFeat = aType.getFeatureByBaseName(FEAT_REL_SOURCE);
    boolean hasSourceFeature = relSourceFeat != null && !isPrimitiveFeature(relSourceFeat);
    Feature relTargetFeat = aType.getFeatureByBaseName(FEAT_REL_TARGET);
    boolean hasTargetFeature = relTargetFeat != null && !isPrimitiveFeature(relTargetFeat);
    
    boolean compatible = true;
    for (Feature feat : aType.getFeatures()) {
        if (
                CAS.FEATURE_BASE_NAME_SOFA.equals(feat.getShortName()) ||
                FEAT_REL_SOURCE.equals(feat.getShortName()) || 
                FEAT_REL_TARGET.equals(feat.getShortName())
        ) {
            continue;
        }
        
        if (!isPrimitiveFeature(feat)) {
            compatible = false;
            //LOG.debug("Incompatible feature in type [" + aType + "]: " + feat);
            break;
        }
    }
    
    return hasSourceFeature && hasTargetFeature && compatible;
}
 
Example #2
Source File: CasCreationUtilsTest.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
public void testCreateCasTypeSystemDescription() throws Exception {
  try {
    //parse type system description
    TypeSystemDescription tsDesc = UIMAFramework.getXMLParser().parseTypeSystemDescription(
            new XMLInputSource(JUnitExtension.getFile("CasCreationUtilsTest/SupertypeMergeTestMaster.xml")));

    // call method
    CAS cas = CasCreationUtils.createCas(tsDesc, null, null);
    
    //check that imports were resolved and supertype merged properly
    Type subType = cas.getTypeSystem().getType("uima.test.Sub");
    assertNotNull(subType);
    Type superType = cas.getTypeSystem().getType("uima.test.Super");
    assertNotNull(superType);
    assertTrue(cas.getTypeSystem().subsumes(superType,subType));      
  } catch (Exception e) {
    JUnitExtension.handleException(e);
  }
}
 
Example #3
Source File: RemoteStringMatchingNerRecommender.java    From inception with Apache License 2.0 6 votes vote down vote up
public String predict(String aPredictionRequestJson) throws IOException, UIMAException,
    SAXException, RecommendationException
{
    PredictionRequest request = deserializePredictionRequest(aPredictionRequestJson);
    CAS cas = deserializeCas(request.getDocument().getXmi(), request.getTypeSystem());

    // Only work on real annotations, not on predictions
    Type predictedType = CasUtil.getType(cas, recommender.getLayer().getName());
    Feature feature = predictedType.getFeatureByBaseName(FEATURE_NAME_IS_PREDICTION);

    for (AnnotationFS fs : CasUtil.select(cas, predictedType)) {
        if (fs.getBooleanValue(feature)) {
            cas.removeFsFromIndexes(fs);
        }
    }

    recommendationEngine.predict(context, cas);

    return buildPredictionResponse(cas);
}
 
Example #4
Source File: StringFeatureSupportTest.java    From webanno with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception
{
    initMocks(this);
    
    sut = new StringFeatureSupport(new PrimitiveUimaFeatureSupportProperties(),
            schemaService);
    
    valueFeature = new AnnotationFeature("value", CAS.TYPE_NAME_STRING);
    
    valueTagset = new TagSet();
    
    jcas = createJCasFromPath("src/test/resources/desc/type/webannoTestTypes.xml");
    jcas.setDocumentText("label");
    
    Type spanType = jcas.getCas().getTypeSystem().getType("webanno.custom.Span");
    spanFS = jcas.getCas().createAnnotation(spanType, 0, jcas.getDocumentText().length());
}
 
Example #5
Source File: SuggestionBuilder.java    From webanno with Apache License 2.0 6 votes vote down vote up
@Deprecated
public static List<Type> getEntryTypes(CAS aMergeCas, List<AnnotationLayer> aLayers,
        AnnotationSchemaService aAnnotationService)
{
    List<Type> entryTypes = new LinkedList<>();

    for (AnnotationLayer layer : aLayers) {
        if (layer.getName().equals(Token.class.getName())) {
            continue;
        }
        if (layer.getType().equals(WebAnnoConst.CHAIN_TYPE)) {
            continue;
        }
        entryTypes.add(aAnnotationService.getAdapter(layer).getAnnotationType(aMergeCas));
    }
    return entryTypes;
}
 
Example #6
Source File: CasUtil.java    From uima-uimafit with Apache License 2.0 6 votes vote down vote up
/**
 * Get the single instance of the specified type from the CAS at the given offsets.
 * 
 * @param aCas
 *          the CAS containing the annotations.
 * @param aType
 *          the type of annotations to fetch.
 * @param aBegin
 *          the begin offset.
 * @param aEnd
 *          the end offset.
 * @return the single annotation at the specified offsets.
 */
public static AnnotationFS selectSingleAt(final CAS aCas, final Type aType, int aBegin, int aEnd) {
  List<AnnotationFS> list = selectAt(aCas, aType, aBegin, aEnd);

  if (list.isEmpty()) {
    throw new IllegalArgumentException("CAS does not contain any [" + aType.getName() + "] at ["
            + aBegin + "," + aEnd + "]");
  }
  
  if (list.size() > 1) {
    throw new IllegalArgumentException("CAS contains more than one [" + aType.getName()
            + "] at [" + aBegin + "," + aEnd + "]");
  }

  return list.get(0);
}
 
Example #7
Source File: RunAE.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Entity process complete.
 *
 * @param aCas the a cas
 * @param aStatus the a status
 * @see org.apache.uima.collection.StatusCallbackListener#entityProcessComplete(org.apache.uima.cas.CAS,
 *      org.apache.uima.collection.EntityProcessStatus)
 */
public void entityProcessComplete(CAS aCas, EntityProcessStatus aStatus) {
  if (aStatus.isException()) {
    Iterator iter = aStatus.getExceptions().iterator();
    while (iter.hasNext()) {
      ((Throwable) iter.next()).printStackTrace();
    }
  } else if (genProgressMessages) {
    // retrieve the filename of the input file from the CAS
    // (it was put there by the FileSystemCollectionReader)
    if (!(xcasInput || xmiInput)) {
      Type fileLocType = aCas.getTypeSystem().getType(
              "org.apache.uima.examples.SourceDocumentInformation");
      Feature fileNameFeat = fileLocType.getFeatureByBaseName("uri");
      FSIterator it = aCas.getAnnotationIndex(fileLocType).iterator();
      FeatureStructure fileLoc = it.get();
      File inFile = new File(fileLoc.getStringValue(fileNameFeat));
      System.out.println("Processed Document " + inFile.getName());
    } else {
      System.out.println("doc" + docsProcessed++ + " processed successfully");
    }
  }
}
 
Example #8
Source File: TsvSchema.java    From webanno with Apache License 2.0 6 votes vote down vote up
/**
 * @param aSlotFeatures
 *            if {@code true}, returns only types <b>with slot features</b>, otherwise returns
 *            only types <b>without slot features</b>.
 */
private Set<Type> getUimaTypes(LayerType aLayerType, boolean aSlotFeatures)
{
    Set<Type> types = new LinkedHashSet<>();
    for (TsvColumn col : columns) {
        if (aLayerType.equals(col.layerType)) {
            boolean hasSlotFeatures = columns.stream().anyMatch(c -> 
                    c.uimaType.equals(col.uimaType) &&
                    (SLOT_ROLE.equals(c.featureType) || SLOT_TARGET.equals(c.featureType)));

            if (hasSlotFeatures == aSlotFeatures) {
                types.add(col.uimaType);
            }
        }
    }
    return types;
}
 
Example #9
Source File: RtfParserFactory.java    From biomedicus with Apache License 2.0 6 votes vote down vote up
/**
 * Parses the rtf source into a set of UIMA CAS views.
 *
 * @param cas parent jCas view to create destination views in.
 * @param rtfSource the source rtf document.
 * @throws IOException if there is a problem reading.
 * @throws RtfReaderException if there is a problem parsing.
 */
RtfParser createParser(CAS cas, RtfSource rtfSource) throws RtfReaderException {
  List<DestinationCasMapping> destinationCasMappings = casMappings.getDestinationCasMappings();

  Map<String, Type> annotationTypeForSymbolName = casMappings
      .getControlWordCasMappings()
      .stream()
      .collect(Collectors.toMap(ControlWordCasMapping::getControlWord,
          p -> cas.getTypeSystem()
              .getType(p.getAnnotationName())));

  OutputDestinationFactory outputDestinationFactory = new CasOutputDestinationFactory(
      destinationCasMappings,
      annotationTypeForSymbolName,
      casMappings.getPropertyCasMappings(),
      cas,
      writeTables
  );

  CAS originalDocumentView = cas.getView(DocumentIdentifiers.ORIGINAL_DOCUMENT);
  IndexListener indexListener = new CasIndexListener(originalDocumentView);

  State initialState = State.createState(outputDestinationFactory, initialProperties,
      indexListener);
  return new RtfParser(rtfKeywordParser, rtfSource, initialState);
}
 
Example #10
Source File: AutomationUtil.java    From webanno with Apache License 2.0 5 votes vote down vote up
private static boolean isSamAnno(Type aType, AnnotationFS aMFs, AnnotationFS aFs)
{
    for (Feature f : aType.getFeatures()) {
        // anywhere is ok
        if (f.getName().equals(CAS.FEATURE_FULL_NAME_BEGIN)) {
            continue;
        }
        // anywhere is ok
        if (f.getName().equals(CAS.FEATURE_FULL_NAME_END)) {
            continue;
        }
        if (!f.getRange().isPrimitive() && aMFs.getFeatureValue(f) instanceof SofaFS) {
            continue;
        }
        // do not attach relation on empty span annotations
        if (aMFs.getFeatureValueAsString(f) == null) {
            continue;
        }
        if (aFs.getFeatureValueAsString(f) == null) {
            continue;
        }
        if (!aMFs.getFeatureValueAsString(f).equals(aFs.getFeatureValueAsString(f))) {
            return false;
        }
    }
    return true;
}
 
Example #11
Source File: RelationOffsetsCheck.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Override
public boolean check(Project aProject, CAS aCas, List<LogMessage> aMessages)
{
    boolean ok = true;
    
    for (AnnotationLayer layer : annotationService.listAnnotationLayer(aProject)) {
        if (!WebAnnoConst.RELATION_TYPE.equals(layer.getType())) {
            continue;
        }

        Type type;
        try {
            type = getType(aCas, layer.getName());
        }
        catch (IllegalArgumentException e) {
            // If the type does not exist, the CAS has not been upgraded. In this case, we
            // can skip checking the layer because there will be no annotations anyway.
            continue;
        }
        
        for (AnnotationFS rel : select(aCas, type)) {
            AnnotationFS target = getFeature(rel, WebAnnoConst.FEAT_REL_TARGET,
                    AnnotationFS.class);
            if ((rel.getBegin() != target.getBegin()) || (rel.getEnd() != target.getEnd())) {
                aMessages.add(new LogMessage(this, LogLevel.ERROR,
                        "Relation offsets [%d,%d] to not match target offsets [%d,%d]",
                        rel.getBegin(), rel.getEnd(), target.getBegin(), target.getEnd()));
                ok = false;
            }
        }
    }

    return ok;
}
 
Example #12
Source File: DocumentUimaImpl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves annotations of the given type from the {@link CAS}.
 *
 * @param type the type
 * @return the annotations
 */
@Override
public Collection<AnnotationFS> getAnnotations(Type type) {
  FSIndex<AnnotationFS> annotationIndex = mCAS.getAnnotationIndex(type);

  StrictTypeConstraint typeConstrain = new StrictTypeConstraint(type);

  FSIterator<AnnotationFS> strictTypeIterator = mCAS
          .createFilteredIterator(annotationIndex.iterator(), typeConstrain);

  return fsIteratorToCollection(strictTypeIterator);
}
 
Example #13
Source File: TsvChain.java    From webanno with Apache License 2.0 5 votes vote down vote up
public TsvChain(int aId, Type aHeadType, Type aElementType,
        Map<AnnotationFS, TsvChain> aSharedIndex)
{
    id = aId;
    headType = aHeadType;
    elementType = aElementType;
    fs2ChainIndex = aSharedIndex;
}
 
Example #14
Source File: TypeSystemTest.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Test array types.
 * 
 */
public void testArrayTypes() {
  // Our version of object arrays. Type is built-in and has special name,
  // for backwards compatibility.
  Type fsArrayType = this.ts.getType(CAS.TYPE_NAME_FS_ARRAY);
  assertNotNull(fsArrayType);
  assertTrue(fsArrayType.isArray());
  assertNotNull(fsArrayType.getComponentType());
  assertTrue(fsArrayType.getComponentType().equals(this.ts.getTopType()));
  assertTrue(fsArrayType.equals(this.ts.getArrayType(this.ts.getTopType())));
  // Int arrays are also built-in, but are primitive-valued.
  Type intArrayType = this.ts.getType(CAS.TYPE_NAME_INTEGER_ARRAY);
  assertNotNull(intArrayType);
  assertTrue(intArrayType.isArray());
  assertNotNull(intArrayType.getComponentType());
  assertTrue(intArrayType.getComponentType().equals(this.ts.getType(CAS.TYPE_NAME_INTEGER)));
  assertTrue(intArrayType.equals(this.ts.getArrayType(this.ts.getType(CAS.TYPE_NAME_INTEGER))));
  // Negative tests: make sure regular types are not classified as arrays.
  Type stringType = this.ts.getType(CAS.TYPE_NAME_STRING);
  assertFalse(stringType.isArray());
  assertNull(stringType.getComponentType());
  Type topType = this.ts.getTopType();
  assertFalse(topType.isArray());
  assertNull(topType.getComponentType());
  // Create an array of arrays.
  Type intMatrix = this.ts.getArrayType(intArrayType);
  assertNotNull(intMatrix);
  assertTrue(intMatrix.isArray());
  assertTrue(intMatrix.getComponentType().equals(intArrayType));
  // Check array inheritance.
  Type annotationArray = this.ts.getArrayType(this.ts.getType(CAS.TYPE_NAME_ANNOTATION));
  assertTrue(this.ts.subsumes(fsArrayType, annotationArray));
  // assertFalse(this.ts.subsumes(annotationArray, fsArrayType));
}
 
Example #15
Source File: WebAnnoTsv3WriterTestBase.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Test
public void testSingleTokenRelationWithMultipleFeatureValues() throws Exception
{
    JCas jcas = makeJCasOneSentence();
    CAS cas = jcas.getCas();
    
    List<Token> tokens = new ArrayList<>(select(jcas, Token.class));
    
    Token gov = tokens.get(0);
    Token dep = tokens.get(tokens.size() - 1);

    Type relationType = cas.getTypeSystem().getType("webanno.custom.ComplexRelation");
    
    // One at the beginning
    // WebAnno legacy conventions
    // AnnotationFS fs1 = cas.createAnnotation(relationType, 
    //      min(dep.getBegin(), gov.getBegin()),
    //      max(dep.getEnd(), gov.getEnd()));
    // DKPro Core conventions
    AnnotationFS fs1 = cas.createAnnotation(relationType, dep.getBegin(), dep.getEnd());
    FSUtil.setFeature(fs1, "Governor", gov);
    FSUtil.setFeature(fs1, "Dependent", dep);
    FSUtil.setFeature(fs1, "value", "nsubj");
    FSUtil.setFeature(fs1, "boolValue", true);
    FSUtil.setFeature(fs1, "integerValue", 42);
    cas.addFsToIndexes(fs1);
    
    writeAndAssertEquals(jcas, 
            WebannoTsv3Writer.PARAM_RELATION_LAYERS, asList("webanno.custom.ComplexRelation"));
}
 
Example #16
Source File: RelationDiffAdapter.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Override
public Position getPosition(int aCasId, FeatureStructure aFS, String aFeature, String aRole,
        int aLinkTargetBegin, int aLinkTargetEnd, LinkCompareBehavior aLinkCompareBehavior)
{
    Type type = aFS.getType();
    AnnotationFS sourceFS = (AnnotationFS) aFS.getFeatureValue(type
            .getFeatureByBaseName(sourceFeature));
    AnnotationFS targetFS = (AnnotationFS) aFS.getFeatureValue(type
            .getFeatureByBaseName(targetFeature));
    
    String collectionId = null;
    String documentId = null;
    try {
        FeatureStructure dmd = WebAnnoCasUtil.getDocumentMetadata(aFS.getCAS());
        collectionId = FSUtil.getFeature(dmd, "collectionId", String.class);
        documentId = FSUtil.getFeature(dmd, "documentId", String.class);
    }
    catch (IllegalArgumentException e) {
        // We use this information only for debugging - so we can ignore if the information
        // is missing.
    }
    
    String linkTargetText = null;
    if (aLinkTargetBegin != -1 && aFS.getCAS().getDocumentText() != null) {
        linkTargetText = aFS.getCAS().getDocumentText()
                .substring(aLinkTargetBegin, aLinkTargetEnd);
    }
    
    return new RelationPosition(collectionId, documentId, aCasId, getType(), 
            sourceFS != null ? sourceFS.getBegin() : -1,
            sourceFS != null ? sourceFS.getEnd() : -1,
            sourceFS != null ? sourceFS.getCoveredText() : null,
            targetFS != null ? targetFS.getBegin() : -1,
            targetFS != null ? targetFS.getEnd() : -1,
            targetFS != null ? targetFS.getCoveredText() : null,
            aFeature, aRole, aLinkTargetBegin, aLinkTargetEnd, linkTargetText,
            aLinkCompareBehavior);
}
 
Example #17
Source File: CasCompare.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
private void applyToTypeFeature_inner(CASImpl cas, String typeName, String featureBaseName, Consumer2<TOP, Feature> c) {
  TypeSystem ts = cas.getTypeSystem();
  Type type = ts.getType(typeName);
  Feature feat = type.getFeatureByBaseName(featureBaseName);
  
  cas.select(type).allViews().forEach(fs -> c.accept2(fs, feat));
  
}
 
Example #18
Source File: WebAnnoTsv3WriterTestBase.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Test
public void testSingleStackedNonTokenRelationWithoutFeatureValue2() throws Exception
{
    JCas jcas = makeJCasOneSentence();
    CAS cas = jcas.getCas();
    
    List<Token> tokens = new ArrayList<>(select(jcas, Token.class));
    
    Token t1 = tokens.get(0);
    Token t2 = tokens.get(tokens.size() - 1);
    
    Span gov = new Span(jcas, t1.getBegin(), t1.getEnd());
    gov.addToIndexes();

    Span dep =  new Span(jcas, t2.getBegin(), t2.getEnd());
    dep.addToIndexes();
    new Span(jcas, t2.getBegin(), t2.getEnd()).addToIndexes();

    Type relationType = cas.getTypeSystem().getType("webanno.custom.Relation");
    
    // One at the beginning
    // WebAnno legacy conventions
    // AnnotationFS fs1 = cas.createAnnotation(relationType, 
    //         min(dep.getBegin(), gov.getBegin()),
    //         max(dep.getEnd(), gov.getEnd()));
    // DKPro Core conventions
    AnnotationFS fs1 = cas.createAnnotation(relationType, dep.getBegin(), dep.getEnd());
    FSUtil.setFeature(fs1, "Governor", gov);
    FSUtil.setFeature(fs1, "Dependent", dep);
    cas.addFsToIndexes(fs1);
    
    writeAndAssertEquals(jcas, 
            WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(Span.class),
            WebannoTsv3Writer.PARAM_RELATION_LAYERS, asList("webanno.custom.Relation"));
}
 
Example #19
Source File: WebAnnoTsv3WriterTestBase.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiTokenSlotFeature() throws Exception
{
    JCas jcas = makeJCasOneSentence();
    CAS cas = jcas.getCas();
    
    List<Token> tokens = new ArrayList<>(select(jcas, Token.class));
    
    Token t1 = tokens.get(0);
    Token t2 = tokens.get(1);
    Token t3 = tokens.get(2);
    Token t4 = tokens.get(3);
    Token t5 = tokens.get(4);
    
    Type type = cas.getTypeSystem().getType("webanno.custom.SimpleSpan");
    AnnotationFS s2 = cas.createAnnotation(type, t2.getBegin(), t3.getEnd());
    cas.addFsToIndexes(s2);
    AnnotationFS s3 = cas.createAnnotation(type, t4.getBegin(), t5.getEnd());
    cas.addFsToIndexes(s3);

    FeatureStructure link1 = makeLinkFS(jcas, "p1", s2);
    FeatureStructure link2 = makeLinkFS(jcas, "p2", s3);
    
    makeLinkHostFS(jcas, t1.getBegin(), t1.getEnd(), link1, link2);
    
    writeAndAssertEquals(jcas, 
            WebannoTsv3Writer.PARAM_SLOT_FEATS, asList("webanno.custom.SimpleLinkHost:links"),
            WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList("webanno.custom.SimpleSpan", 
                    "webanno.custom.SimpleLinkHost"),
            WebannoTsv3Writer.PARAM_LINK_TYPES, asList("webanno.custom.LinkType"),
            WebannoTsv3Writer.PARAM_SLOT_TARGETS, asList("webanno.custom.SimpleSpan"));
}
 
Example #20
Source File: FeatureStructureImplC.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
private void subStringRangeCheck(Feature feat, String v) {
  Type range = feat.getRange();
  if (range instanceof TypeImpl_stringSubtype) {
    if (v != null) { // null values always OK
      ((TypeImpl_stringSubtype)range).validateIsInAllowedValues(v);
    }
  }     
}
 
Example #21
Source File: FSCollectionFactory.java    From uima-uimafit with Apache License 2.0 5 votes vote down vote up
public static <T extends TOP> FSList<T> createFSList(CAS aCas, Collection<T> aValues) {
  if (aValues == null) {
    return null;
  }
  
  TypeSystem ts = aCas.getTypeSystem();

  if (aValues.size() == 0) {
    return aCas.emptyFSList();
  }
  
  Type nonEmptyType = ts.getType(CAS.TYPE_NAME_NON_EMPTY_FS_LIST);
  Feature headFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD);
  Feature tailFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL);

  FeatureStructure head = aCas.createFS(nonEmptyType);
  FeatureStructure list = head;
  Iterator<? extends FeatureStructure> i = aValues.iterator();
  while (i.hasNext()) {
    head.setFeatureValue(headFeature, i.next());
    if (i.hasNext()) {
      FeatureStructure tail = aCas.createFS(nonEmptyType);
      head.setFeatureValue(tailFeature, tail);
      head = tail;
    } else {
      head.setFeatureValue(tailFeature, aCas.emptyFSList());
    }
  }

  return (FSList<T>) list;
}
 
Example #22
Source File: AnnotationEditor.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves an <code>AnnotationStyle</code> from the underlying storage.
 *
 * @param type the type
 * @return the annotation style
 */
public AnnotationStyle getAnnotationStyle(Type type) {
  if (type == null)
    throw new IllegalArgumentException("type parameter must not be null!");
  
  IPreferenceStore prefStore = getCasDocumentProvider().
          getTypeSystemPreferenceStore(getEditorInput());
  
  return AnnotationStyle.getAnnotationStyleFromStore(prefStore, type.getName());
}
 
Example #23
Source File: FSCollectionFactory.java    From uima-uimafit with Apache License 2.0 5 votes vote down vote up
public static <T extends TOP> List<T> create(FSList<T> aList, Type type) {
  TypeSystem ts = aList.getCAS().getTypeSystem();
  List<FeatureStructure> data = new ArrayList<FeatureStructure>();
  FSList<T> i = aList;
  while (i instanceof NonEmptyFSList) {
    NonEmptyFSList<T> l = (NonEmptyFSList<T>) i;
    TOP value = l.getHead();
    if (value != null && (type == null || ts.subsumes(type, value.getType()))) {
      data.add(l.getHead());
    }
    i = l.getTail();
  }

  return (List<T>) asList(data.toArray(new TOP[data.size()]));
}
 
Example #24
Source File: Protein_Type.java    From bluima with Apache License 2.0 4 votes vote down vote up
/** initialize variables to correspond with Cas Type and Features
* @generated
* @param jcas JCas
* @param casType Type 
*/
public Protein_Type(JCas jcas, Type casType) {
  super(jcas, casType);
  casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());

}
 
Example #25
Source File: TypeSystemImpl.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
public TypeImpl refreshType(Type t) {
  return getType(t.getName());
}
 
Example #26
Source File: UiucWikiPeople_Type.java    From ambiverse-nlu with Apache License 2.0 4 votes vote down vote up
/** initialize variables to correspond with Cas Type and Features
*
* @param jcas JCas
* @param casType Type 
*/
public UiucWikiPeople_Type(JCas jcas, Type casType) {
  super(jcas, casType);
  casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());

}
 
Example #27
Source File: PART_WHOLE_Inverse_Type.java    From bluima with Apache License 2.0 4 votes vote down vote up
/** initialize variables to correspond with Cas Type and Features
* @generated
* @param jcas JCas
* @param casType Type 
*/
public PART_WHOLE_Inverse_Type(JCas jcas, Type casType) {
  super(jcas, casType);
  casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());

}
 
Example #28
Source File: UiucKnownName_Type.java    From ambiverse-nlu with Apache License 2.0 4 votes vote down vote up
/** initialize variables to correspond with Cas Type and Features
*
* @param jcas JCas
* @param casType Type 
*/
public UiucKnownName_Type(JCas jcas, Type casType) {
  super(jcas, casType);
  casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());

}
 
Example #29
Source File: UiucMeasurements_Type.java    From ambiverse-nlu with Apache License 2.0 4 votes vote down vote up
/** initialize variables to correspond with Cas Type and Features
*
* @param jcas JCas
* @param casType Type 
*/
public UiucMeasurements_Type(JCas jcas, Type casType) {
  super(jcas, casType);
  casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());

}
 
Example #30
Source File: Relation_Type.java    From bluima with Apache License 2.0 4 votes vote down vote up
/** initialize variables to correspond with Cas Type and Features
* @generated
* @param jcas JCas
* @param casType Type 
*/
public Relation_Type(JCas jcas, Type casType) {
  super(jcas, casType);
  casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());

}