Uploaded image for project: 'UIMA'
  1. UIMA
  2. UIMA-5793

FSUtil.getFeature fails when called with Object.class on multi-valued features

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 3.0.0uimaFIT, 2.5.0uimaFIT
    • uimaFIT
    • None

    Description

      When FSUtil.getFeature(fs, feature, type) is called on a feature that is multi-valued and type is Object, then the method fails with a message like

      Unable to coerce value of feature [de.tudarmstadt.ukp.inception.api.kb.type.Fact:object] with type [de.tudarmstadt.ukp.inception.api.kb.type.FactObjectLink[]] into [java.lang.Object]
      

      This is because Object is no an array or collection type. However, FSUtil.getFeatures should handle this as a special case. When the Object is used, basically any return value is acceptable. FSUtil should have defined behavior here, e.g. returning either an array or a list representation of the multi-value.

      This is what current work-around code looks like:

          private Object getValue(FeatureStructure fs, AnnotationFeature aFeature)
          {
              Object value;
              
              Feature f = fs.getType().getFeatureByBaseName(aFeature.getName());
              if (f.getRange().isPrimitive()) {
                  value = FSUtil.getFeature(fs, aFeature.getName(), Object.class);
              }
              else if (FSUtil.isMultiValuedFeature(fs, f)) {
                  value = FSUtil.getFeature(fs, aFeature.getName(), List.class);
              }
              else {
                  value = FSUtil.getFeature(fs, aFeature.getName(), FeatureStructure.class);
              }
              
              return value;
          }
      

      Attachments

        Activity

          People

            rec Richard Eckart de Castilho
            rec Richard Eckart de Castilho
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: