org.eclipse.jface.text.IPainter#org.apache.uima.cas.Type源码实例Demo

下面列出了org.eclipse.jface.text.IPainter#org.apache.uima.cas.Type 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: webanno   文件: SuggestionBuilder.java
@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;
}
 
源代码2 项目: webanno   文件: StringFeatureSupportTest.java
@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());
}
 
源代码3 项目: biomedicus   文件: RtfParserFactory.java
/**
 * 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);
}
 
源代码4 项目: webanno   文件: TsvSchema.java
/**
 * @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;
}
 
源代码5 项目: uima-uimaj   文件: RunAE.java
/**
 * 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");
    }
  }
}
 
源代码6 项目: uima-uimafit   文件: CasUtil.java
/**
 * 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);
}
 
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);
}
 
源代码8 项目: uima-uimaj   文件: CasCreationUtilsTest.java
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);
  }
}
 
源代码9 项目: webanno   文件: Tsv3XCasSchemaAnalyzer.java
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;
}
 
源代码10 项目: webanno   文件: RelationOffsetsCheck.java
@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;
}
 
源代码11 项目: uima-uimaj   文件: DocumentUimaImpl.java
/**
 * 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);
}
 
源代码12 项目: webanno   文件: TsvChain.java
public TsvChain(int aId, Type aHeadType, Type aElementType,
        Map<AnnotationFS, TsvChain> aSharedIndex)
{
    id = aId;
    headType = aHeadType;
    elementType = aElementType;
    fs2ChainIndex = aSharedIndex;
}
 
源代码13 项目: uima-uimaj   文件: TypeSystemTest.java
/**
 * 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));
}
 
源代码14 项目: webanno   文件: WebAnnoTsv3WriterTestBase.java
@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"));
}
 
源代码15 项目: webanno   文件: AutomationUtil.java
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;
}
 
源代码16 项目: webanno   文件: RelationDiffAdapter.java
@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);
}
 
源代码17 项目: uima-uimaj   文件: CasCompare.java
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));
  
}
 
源代码18 项目: webanno   文件: WebAnnoTsv3WriterTestBase.java
@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"));
}
 
源代码19 项目: webanno   文件: WebAnnoTsv3WriterTestBase.java
@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"));
}
 
源代码20 项目: uima-uimaj   文件: FeatureStructureImplC.java
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);
    }
  }     
}
 
源代码21 项目: uima-uimafit   文件: FSCollectionFactory.java
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;
}
 
源代码22 项目: uima-uimaj   文件: AnnotationEditor.java
/**
 * 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());
}
 
源代码23 项目: uima-uimafit   文件: FSCollectionFactory.java
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()]));
}
 
源代码24 项目: webanno   文件: WebannoTsv2Reader.java
private int getLayerAndFeature(JCas aJcas, int columns, Map<Type, Set<Feature>> spanLayers,
        Map<Type, Type> relationayers, String line)
    throws IOException
{
    StringTokenizer headerTk = new StringTokenizer(line, "#");
    while (headerTk.hasMoreTokens()) {
        String layerNames = headerTk.nextToken().trim();
        StringTokenizer layerTk = new StringTokenizer(layerNames, "|");

        Set<Feature> features = new LinkedHashSet<>();
        String layerName = layerTk.nextToken().trim();

        Iterator<Type> types = aJcas.getTypeSystem().getTypeIterator();
        boolean layerExists = false;
        while (types.hasNext()) {

            if (types.next().getName().equals(layerName)) {
                layerExists = true;
                break;
            }
        }
        if (!layerExists) {
            throw new IOException(fileName + " This is not a valid TSV File. The layer "
                    + layerName + " is not created in the project.");
        }
        Type layer = CasUtil.getType(aJcas.getCas(), layerName);

        while (layerTk.hasMoreTokens()) {
            String ft = layerTk.nextToken().trim();
            if (ft.startsWith("AttachTo=")) {
                Type attachLayer = CasUtil.getType(aJcas.getCas(), ft.substring(9));
                relationayers.put(layer, attachLayer);
                columns++;
                continue;
            }
            Feature feature = layer.getFeatureByBaseName(ft);
            if (feature == null) {
                throw new IOException(fileName + " This is not a valid TSV File. The feature "
                        + ft + " is not created for the layer " + layerName);
            }
            features.add(feature);
            columns++;
        }
        spanLayers.put(layer, features);
    }
    return columns;
}
 
源代码25 项目: bluima   文件: BioEntityMention_Type.java
/** initialize variables to correspond with Cas Type and Features
* @generated
* @param jcas JCas
* @param casType Type 
*/
public BioEntityMention_Type(JCas jcas, Type casType) {
  super(jcas, casType);
  casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());

}
 
源代码26 项目: uima-uimaj   文件: TypeSystemImpl.java
@Override
public Iterator<Type> iterator() {
  return getTypeIterator();
}
 
源代码27 项目: webanno   文件: TsvSchema.java
public void ignoreType(Type aType)
{
    ignoredTypes.add(aType);
}
 
源代码28 项目: uima-uimaj   文件: CASImpl.java
public final boolean isByteArrayType(Type type) {
  return ((TypeImpl)type).getCode() == byteArrayTypeCode;
}
 
源代码29 项目: bluima   文件: FeatureTokens_Type.java
/** initialize variables to correspond with Cas Type and Features
* @generated
* @param jcas JCas
* @param casType Type 
*/
public FeatureTokens_Type(JCas jcas, Type casType) {
  super(jcas, casType);
  casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());

 
  casFeat_tokens = jcas.getRequiredFeatureDE(casType, "tokens", "uima.cas.StringArray", featOkTst);
  casFeatCode_tokens  = (null == casFeat_tokens) ? JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_tokens).getCode();

 
  casFeat_beginnings = jcas.getRequiredFeatureDE(casType, "beginnings", "uima.cas.IntegerArray", featOkTst);
  casFeatCode_beginnings  = (null == casFeat_beginnings) ? JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_beginnings).getCode();

 
  casFeat_endings = jcas.getRequiredFeatureDE(casType, "endings", "uima.cas.IntegerArray", featOkTst);
  casFeatCode_endings  = (null == casFeat_endings) ? JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_endings).getCode();

}
 
源代码30 项目: ambiverse-nlu   文件: ConceptEntity_Type.java
/** initialize variables to correspond with Cas Type and Features
*
* @param jcas JCas
* @param casType Type 
*/
public ConceptEntity_Type(JCas jcas, Type casType) {
  super(jcas, casType);
  casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());

}