Package org.apache.uima.cas

Examples of org.apache.uima.cas.Feature


   * @see org.apache.uima.jcas.JCas#getRequiredFeatureDE(org.apache.uima.cas.Type, java.lang.String,
   *      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);
    }
    if (null != f)
      try {
        casImpl.checkTypingConditions(t, rangeType, f);
      } catch (LowLevelException e) {
        CASException casEx = new CASException(CASException.JCAS_FEATURE_WRONG_TYPE, new String[] {
            t.getName(), s, rangeName, f.getRange().toString() });
        sharedView.errorSet.add(casEx);
      }
    return f;
  }
View Full Code Here


  public boolean isValid() {
    if (this.type == null) {
      return false;
    }
    final int max = this.getNumberOfKeys();
    Feature feat;
    for (int i = 0; i < max; i++) {
      if (this.keyTypeVector.get(i) != FEATURE_KEY) {
        continue;
      }
      feat = (Feature) this.keyVector.get(i);
      // if (feat.getTypeSystem() != ts) {
      // return false;
      // }
      if (!this.ts.subsumes(feat.getDomain(), this.type)) {
        return false;
      }
    }
    return true;
  }
View Full Code Here

      this.indexRepository.addFS(fsIndex[i])// add to base index
    }
    int loopStart = loopLen + 2;

    FSIterator iterator = this.svd.baseCAS.getSofaIterator();
    final Feature idFeat = getTypeSystem().getFeatureByFullName(CAS.FEATURE_FULL_NAME_SOFAID);
    // Add FSs to index repository for each View
    while (iterator.isValid()) {
      SofaFS sofa = (SofaFS) iterator.get();
      String id = getLowLevelCAS().ll_getStringValue(((FeatureStructureImpl)sofa).getAddress(),
          ((FeatureImpl) idFeat).getCode());
View Full Code Here

    // get features to copy
    int[] featcodes = getTypeSystem().getLowLevelTypeSystem().ll_getAppropriateFeatures(typeCode);
    for (int i = 0; i < featcodes.length; i++) {

      // get range type of this feature
      Feature feature = getTypeSystem().getLowLevelTypeSystem().ll_getFeatureForCode(featcodes[i]);
      Type rangeType = feature.getRange();
      // get feature code
      int featCode = ((FeatureImpl) feature).getCode();
      // get the value for this feature offset in src fs
      int val = getHeapValue(srcAddr + this.svd.casMetadata.featureOffset[featCode]);
      // if this is a string, create a new reference in the string
View Full Code Here

  public void updateDocumentAnnotation() {
    if (!mySofaIsValid()) {
      return;
    }
    final Type SofaType = this.svd.casMetadata.ts.sofaType;
    final Feature sofaString = SofaType.getFeatureByBaseName(FEATURE_BASE_NAME_SOFASTRING);
    String newDoc = getSofa(this.mySofaRef).getStringValue(sofaString);
    if (null != newDoc) {
      getDocumentAnnotation().setIntValue(getEndFeature(), newDoc.length());
    }
  }
View Full Code Here

        finalizeArray(type, addr);
        return;
      }
      // remap IDs for all nonprimtive, non-multivalued-property features
      int[] feats = casBeingFilled.getTypeSystemImpl().ll_getAppropriateFeatures(type);
      Feature feat;
      for (int i = 0; i < feats.length; i++) {
        feat = ts.ll_getFeatureForCode(feats[i]);
        int typeCode = ts.ll_getRangeType(feats[i]);
        if (casBeingFilled.ll_isRefType(typeCode)
                && (featureType[feats[i]] == LowLevelCAS.TYPE_CLASS_FS || feat
                        .isMultipleReferencesAllowed())) {
          int featVal = casBeingFilled.getFeatureValue(addr, feats[i]);
          if (featVal != CASImpl.NULL) {
            int fsValAddr = CASImpl.NULL;
            try {
              fsValAddr = getFsAddrForXmiId(featVal);
            } catch (NoSuchElementException e) {
              if (!lenient) {
                throw e;
              }
              else {
                // we may not have deserialized the value of this feature because it
                // was of unknown type.  We set it to null, and record in the
                // out-of-typesystem data.
                this.sharedData.addOutOfTypeSystemAttribute(
                        addr, feat.getShortName(), Integer.toString(featVal));
              }
            }
            casBeingFilled.setFeatureValue(addr, feats[i], fsValAddr);
          }
        }
View Full Code Here

        if (keys != null) {
          for (int j = 0; j < keys.length; j++) {
            if (keys[j].isTypePriority()) {
              comparator.addKey(irm.getDefaultTypeOrder(), FSIndexComparator.STANDARD_COMPARE);
            } else {
              Feature feature = type.getFeatureByBaseName(keys[j].getFeatureName());
              if (feature == null) {
                throw new ResourceInitializationException(
                        ResourceInitializationException.INDEX_KEY_FEATURE_NOT_FOUND, new Object[] {
                            keys[j].getFeatureName(), aIndexes[i].getLabel(),
                            aIndexes[i].getSourceUrlString() });
View Full Code Here

  }

  private Number getNumberValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
    Number result = null;
    Type type = fe.getTypeExpr().getType(parent);
    Feature feature = fe.getFeature(parent);
    Type range = feature.getRange();
    List<AnnotationFS> list = getTargetAnnotation(annotation, type, stream);
    Collection<AnnotationFS> featureAnnotations = fe.getFeatureAnnotations(list, stream, parent,
            false);
    if (!featureAnnotations.isEmpty()) {
      AnnotationFS next = featureAnnotations.iterator().next();
View Full Code Here

  }

  @Override
  public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
    Type type = fe.getTypeExpr().getType(parent);
    Feature feature = fe.getFeature(parent);
    List<AnnotationFS> list = getTargetAnnotation(annotation, type, stream);
    Collection<AnnotationFS> featureAnnotations = fe.getFeatureAnnotations(list, stream, parent,
            false);
    if (!featureAnnotations.isEmpty()) {
      AnnotationFS next = featureAnnotations.iterator().next();
View Full Code Here

  public void setOp(String op) {
    this.op = op;
  }

  public boolean checkFeatureValue(AnnotationFS afs, RutaStream stream, RutaBlock parent) {
    Feature feature = getFeature(parent);
    return checkFeatureValue(afs, feature, stream, parent);
  }
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.