Package org.apache.uima.cas

Examples of org.apache.uima.cas.Feature


    cas.addFsToIndexes(orgAnnot2);
    AnnotationFS testAnnot = cas.createAnnotation(testAnnotType, 0, 20);
    cas.addFsToIndexes(testAnnot);
    Type nonEmptyFsListType = cas.getTypeSystem().getType(CAS.TYPE_NAME_NON_EMPTY_FS_LIST);
    Type emptyFsListType = cas.getTypeSystem().getType(CAS.TYPE_NAME_EMPTY_FS_LIST);
    Feature headFeat = nonEmptyFsListType.getFeatureByBaseName("head");
    Feature tailFeat = nonEmptyFsListType.getFeatureByBaseName("tail");
    FeatureStructure emptyNode = cas.createFS(emptyFsListType);
    FeatureStructure secondNode = cas.createFS(nonEmptyFsListType);
    secondNode.setFeatureValue(headFeat, orgAnnot2);
    secondNode.setFeatureValue(tailFeat, emptyNode);
    FeatureStructure firstNode = cas.createFS(nonEmptyFsListType);
    firstNode.setFeatureValue(headFeat, orgAnnot1);
    firstNode.setFeatureValue(tailFeat, secondNode);
   
    Feature listFeat = testAnnotType.getFeatureByBaseName("listFeat");
    testAnnot.setFeatureValue(listFeat, firstNode);
   
    //serialize to XMI
    String xmiStr = serialize(cas, null);
//    System.out.println(xmiStr);
   
    //deserialize into a CAS that's missing the Organization type
    File partialTypeSystemFile = JUnitExtension.getFile("ExampleCas/partialTestTypeSystem.xml");
    TypeSystemDescription partialTypeSystem = UIMAFramework.getXMLParser().parseTypeSystemDescription(
            new XMLInputSource(partialTypeSystemFile));
    testAnnotTypeDesc = partialTypeSystem.addType("org.apache.uima.testTypeSystem.TestAnnotation", "", "uima.tcas.Annotation");
    testAnnotTypeDesc.addFeature("listFeat", "", "uima.cas.FSList");
    CAS partialTsCas = CasCreationUtils.createCas(partialTypeSystem, null, null);
    XmiSerializationSharedData sharedData = new XmiSerializationSharedData();
    deserialize(xmiStr, partialTsCas, sharedData, true, -1);
   
    //check out of type system data
    Type testAnnotType2 = partialTsCas.getTypeSystem().getType("org.apache.uima.testTypeSystem.TestAnnotation");
    FeatureStructure testAnnot2 = partialTsCas.getAnnotationIndex(testAnnotType2).iterator().get();
    Feature listFeat2 = testAnnotType2.getFeatureByBaseName("listFeat");
    FeatureStructure listFs = testAnnot2.getFeatureValue(listFeat2);
    List ootsElems = sharedData.getOutOfTypeSystemElements();
    assertEquals(2, ootsElems.size());
    OotsElementData oed = sharedData.getOutOfTypeSystemFeatures(listFs.hashCode());
    XmlAttribute attr = (XmlAttribute)oed.attributes.get(0);
View Full Code Here


  }

  public static void lowerRightAnnotationSide(ICasDocument document, AnnotationFS annotation) {
   
    Type annotationType = annotation.getType();
    Feature endFeature = annotationType.getFeatureByBaseName("end");
   
    if (annotation.getBegin() < annotation.getEnd()) {
      annotation.setIntValue(endFeature, annotation.getEnd() - 1);
    }
   
View Full Code Here

    return annotation.size() == 1;
  }

  public static void wideRightAnnotationSide(ICasDocument document, AnnotationFS annotation) {
    Type annotationType = annotation.getType();
    Feature endFeature = annotationType.getFeatureByBaseName("end");
   
    if (annotation.getEnd() < document.getCAS().getDocumentText().length()) {
      annotation.setIntValue(endFeature, annotation.getEnd() + 1);
    }
   
View Full Code Here

      makeFeaturesForAkof(cas, m, Akof2);
    }
  }
 
  private void maybeSetBoolean(FeatureStructure fs, TTypeSystem m, boolean value) {
    Feature f = m.getFeature(fs, "Boolean");
    if (f != null) {
      fs.setBooleanValue(f, value);
    }
  }
View Full Code Here

      fs.setBooleanValue(f, value);
    }
  }
 
  private void maybeSetByte(FeatureStructure fs, TTypeSystem m, byte value) {
    Feature f = m.getFeature(fs, "Byte");
    if (f != null) {
      fs.setByteValue(f, value);
    }
  }
View Full Code Here

      fs.setByteValue(f, value);
    }
  }

  private void maybeSetShort(FeatureStructure fs, TTypeSystem m, short value) {
    Feature f = m.getFeature(fs, "Short");
    if (f != null) {
      fs.setShortValue(f, value);
    }
  }
View Full Code Here

      fs.setShortValue(f, value);
    }
  }

  private void maybeSetInt(FeatureStructure fs, TTypeSystem m, int value) {
    Feature f = m.getFeature(fs, "Int");
    if (f != null) {
      fs.setIntValue(f, value);
    }
  }
View Full Code Here

      fs.setIntValue(f, value);
    }
  }

  private void maybeSetFloat(FeatureStructure fs, TTypeSystem m, float value) {
    Feature f = m.getFeature(fs, "Float");
    if (f != null) {
      fs.setFloatValue(f, value);
    }
  }
View Full Code Here

      fs.setFloatValue(f, value);
    }
  }

  private void maybeSetLong(FeatureStructure fs, TTypeSystem m, long value) {
    Feature f = m.getFeature(fs, "Long");
    if (f != null) {
      fs.setLongValue(f, value);
    }
  }
View Full Code Here

      fs.setLongValue(f, value);
    }
  }

  private void maybeSetDouble(FeatureStructure fs, TTypeSystem m, double value) {
    Feature f = m.getFeature(fs, "Double");
    if (f != null) {
      fs.setDoubleValue(f, value);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.cas.Feature

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.