Package org.apache.uima.cas

Examples of org.apache.uima.cas.Type


      IBooleanExpression booleanExpr = (IBooleanExpression) argExpr;
      boolean v = booleanExpr.getBooleanValue(element.getParent(), a, stream);
      a.setBooleanValue(feature, v);
    } else if (argExpr instanceof TypeExpression && !feature.getRange().isPrimitive()) {
      TypeExpression typeExpr = (TypeExpression) argExpr;
      Type t = typeExpr.getType(element.getParent());
      List<AnnotationFS> inWindow = stream.getAnnotationsInWindow(a, t);
      if (feature.getRange().isArray()) {
        a.setFeatureValue(feature, UIMAUtils.toFSArray(stream.getJCas(), inWindow));
      } else {
        AnnotationFS annotation = inWindow.get(0);
View Full Code Here


    String featureString = featureStringExpression.getStringValue(parent, match, element, stream);
    List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotationsOf(element);
    for (AnnotationFS annotationFS : matchedAnnotations) {
      Feature feature = annotationFS.getType().getFeatureByBaseName(featureString);
      if (feature != null) {
        Type range = feature.getRange();
        String rangeName = range.getName();
        stream.getCas().removeFsFromIndexes(annotationFS);
        if (rangeName.equals(UIMAConstants.TYPE_STRING) && expr instanceof IStringExpression) {
          IStringExpression stringExpr = (IStringExpression) expr;
          String string = stringExpr.getStringValue(parent, match, element, stream);
          annotationFS.setStringValue(feature, string);
        } else if (rangeName.equals(UIMAConstants.TYPE_INTEGER)
                && expr instanceof INumberExpression) {
          INumberExpression numberExpr = (INumberExpression) expr;
          int v = numberExpr.getIntegerValue(parent, match, element, stream);
          annotationFS.setIntValue(feature, v);
        } else if (rangeName.equals(UIMAConstants.TYPE_DOUBLE) && expr instanceof INumberExpression) {
          INumberExpression numberExpr = (INumberExpression) expr;
          double v = numberExpr.getDoubleValue(parent, match, element, stream);
          annotationFS.setDoubleValue(feature, v);
        } else if (rangeName.equals(UIMAConstants.TYPE_FLOAT) && expr instanceof INumberExpression) {
          INumberExpression numberExpr = (INumberExpression) expr;
          float v = (float) numberExpr.getFloatValue(parent, match, element, stream);
          annotationFS.setFloatValue(feature, v);
        } else if (rangeName.equals(UIMAConstants.TYPE_BYTE) && expr instanceof INumberExpression) {
          INumberExpression numberExpr = (INumberExpression) expr;
          byte v = (byte) numberExpr.getIntegerValue(parent, match, element, stream);
          annotationFS.setByteValue(feature, v);
        } else if (rangeName.equals(UIMAConstants.TYPE_SHORT) && expr instanceof INumberExpression) {
          INumberExpression numberExpr = (INumberExpression) expr;
          short v = (short) numberExpr.getIntegerValue(parent, match, element, stream);
          annotationFS.setShortValue(feature, v);
        } else if (rangeName.equals(UIMAConstants.TYPE_LONG) && expr instanceof INumberExpression) {
          INumberExpression numberExpr = (INumberExpression) expr;
          long v = numberExpr.getIntegerValue(parent, match, element, stream);
          annotationFS.setLongValue(feature, v);
        } else if (rangeName.equals(UIMAConstants.TYPE_BOOLEAN)
                && expr instanceof IBooleanExpression) {
          IBooleanExpression booleanExpr = (IBooleanExpression) expr;
          boolean v = booleanExpr.getBooleanValue(parent, match, element, stream);
          annotationFS.setBooleanValue(feature, v);
        } else if (expr instanceof TypeExpression) {
          TypeExpression typeExpr = (TypeExpression) expr;
          Type t = typeExpr.getType(parent);
          List<AnnotationFS> inWindow = stream.getAnnotationsInWindow(annotationFS, t);
          if (feature.getRange().isArray()) {
            annotationFS.setFeatureValue(feature, UIMAUtils.toFSArray(stream.getJCas(), inWindow));
          } else {
            AnnotationFS annotation = inWindow.get(0);
View Full Code Here

          eachBasic.setLowMemoryProfile(lowMemoryProfile);
        }
      }
      // TODO: find a better solution for this:
      for (AnnotationFS a : allAnnotations) {
        Type type = a.getType();
        if (!type.equals(basicType)) {
          RutaBasic beginAnchor = getBeginAnchor(a.getBegin());
          RutaBasic endAnchor = getEndAnchor(a.getEnd());
          boolean shouldBeAdded = false;
          if (beginAnchor == null || endAnchor == null) {
            shouldBeAdded = true;
View Full Code Here

    addAnnotation(annotation, false, true, creator);
  }

  public void addAnnotation(AnnotationFS annotation, boolean addToIndex, boolean updateInternal,
          AbstractRuleMatch<? extends AbstractRule> creator) {
    Type type = annotation.getType();
    if (type.equals(basicType)) {
      return;
    }
    boolean modified = checkSpan(annotation);
    if (modified && updateInternal) {
      updateIterators(filter.getWindowAnnotation());
View Full Code Here

  public void removeAnnotation(AnnotationFS annotation, Type type) {
    Collection<RutaBasic> basicAnnotationsInWindow = getAllBasicsInWindow(annotation);
    for (RutaBasic basic : basicAnnotationsInWindow) {
      basic.removePartOf(type);
    }
    Type parent = type;
    RutaBasic beginAnchor = getBeginAnchor(annotation.getBegin());
    RutaBasic endAnchor = getEndAnchor(annotation.getEnd());
    beginAnchor.removeBegin(annotation, parent);
    endAnchor.removeEnd(annotation, parent);
    if (!(annotation instanceof RutaBasic)) {
View Full Code Here

  // note all callers are synchronized
  private void copyDownSuperGenerators(Map<String, LoadedJCasType> jcasTypes, FSGenerator[] fsGenerators) {
    final TypeSystem ts = casImpl.getTypeSystem();
    Iterator<Type> typeIt = ts.getTypeIterator(); // reset iterator to start
    Type topType = ts.getTopType();
    Type superType = null;
    while (typeIt.hasNext()) {
      Type t = (Type) typeIt.next();
      if (builtInsWithNoJCas.contains(t.getName()))
        continue;
      // comment here
      if (CAS.TYPE_NAME_DOCUMENT_ANNOTATION.equals(t.getName())) {
        if (jcasTypes.get("org.apache.uima.jcas.tcas.DocumentAnnotation") != null)
          continue;
      } else if (builtInsWithAltNames.contains(t.getName()))
        continue; // because jcasTypes has no entry for these
      if (null != jcasTypes.get(t.getName()))
        continue;
      // we believe that at this point, t is not "top", because top is
      // always loaded
      // find closest supertype that has a loaded cover class
      superType = t;
View Full Code Here

   * (non-Javadoc)
   *
   * @see org.apache.uima.jcas.JCas#getRequiredType(java.lang.String)
   */
  public Type getRequiredType(String s) throws CASException {
    Type t = getTypeSystem().getType(s);
    if (null == t) {
      CASException casEx = new CASException(CASException.JCAS_TYPENOTFOUND_ERROR,
          new String[] { s });
      throw casEx;
    }
View Full Code Here

   *      java.lang.String, boolean)
   */

  public Feature getRequiredFeatureDE(Type t, String s, String rangeName, boolean featOkTst) {
    Feature f = t.getFeatureByBaseName(s);
    Type rangeType = this.getTypeSystem().getType(rangeName);
    if (null == f && !featOkTst) {
      CASException casEx = new CASException(CASException.JCAS_FEATURENOTFOUND_ERROR, new String[] {
          t.getName(), s });
      sharedView.errorSet.add(casEx);
    }
View Full Code Here

    List<Feature> features2 = fs2.getType().getFeatures();
    for (int i = 0; i < features1.size(); i++) {
      Feature feat1 = features1.get(i);
      Feature feat2 = features2.get(i);
      // System.out.println("Comparing " + feat1.getName());
      Type rangeType1 = feat1.getRange();
      Type rangeType2 = feat2.getRange();
      Assert.assertEquals(rangeType1.getName(), rangeType2.getName());
      // System.out.println("Range type " + rangeType1);
      String rangeTypeName = rangeType1.getName();

      if (fs1.getCAS().getTypeSystem().subsumes(
              fs1.getCAS().getTypeSystem().getType(CAS.TYPE_NAME_STRING), rangeType1)) {
View Full Code Here

      if (selection.getFirstElement() instanceof FeatureValue) {
        FeatureValue featureValue = (FeatureValue) selection.getFirstElement();

        FeatureStructure newValue;

        Type fsSuperType = featureValue.getFeature().getRange();

        if (!fsSuperType.isArray()) {
          List<Type> subTypes =
              document.getCAS().getTypeSystem().getProperlySubsumedTypes(fsSuperType);

          Type typeToCreate;
          int arraySize = -1;

          if (subTypes.size() == 0) {
            typeToCreate = fsSuperType;
          }
          else {
             CreateFeatureStructureDialog createFsDialog =
                 new CreateFeatureStructureDialog(Display.getCurrent()
                         .getActiveShell(), fsSuperType, document.getCAS().getTypeSystem());

             int returnCode = createFsDialog.open();

             if (returnCode == IDialogConstants.OK_ID) {
               typeToCreate = createFsDialog.getType();
               arraySize = createFsDialog.getArraySize();
             }
             else {
               return;
             }
          }

          newValue = createFS(typeToCreate, arraySize);

          document.addFeatureStructure(newValue);
        } else {
          Type arrayType = featureValue.getFeature().getRange();

          CreateFeatureStructureDialog createArrayDialog = new CreateFeatureStructureDialog(Display.getCurrent()
                  .getActiveShell(), arrayType, document.getCAS().getTypeSystem());

          int returnCode = createArrayDialog.open();
View Full Code Here

TOP

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

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.