Hi,

has anyone seen the following exception. I have no idea what can cause
this problem. (the typeCode is 0 or something causing the feats int
array to be null). I added the method that causes the problem below. It
just removes some annotations dependent of its type.

I was thinking that the problem is caused by removing annotations that
are indexed and are the value of the feature of another indexed
annotation. However, that works for almost all types. I would assume
that this functionality would not depend on the actual type or the order
in the type system, right?

Any ideas is greatly appreciated.

java.lang.NullPointerException
    at
org.apache.uima.cas.impl.XmiCasSerializer$XmiCasDocSerializer.enqueueFeatures(XmiCasSerializer.java:593)
    at
org.apache.uima.cas.impl.XmiCasSerializer$XmiCasDocSerializer.enqueueFeaturesOfIndexed(XmiCasSerializer.java:521)
    at
org.apache.uima.cas.impl.XmiCasSerializer$XmiCasDocSerializer.serialize(XmiCasSerializer.java:241)
    at
org.apache.uima.cas.impl.XmiCasSerializer$XmiCasDocSerializer.access$700(XmiCasSerializer.java:108)
    at
org.apache.uima.cas.impl.XmiCasSerializer.serialize(XmiCasSerializer.java:1551)
    at
org.apache.uima.cas.impl.XmiCasSerializer.serialize(XmiCasSerializer.java:1616)
    at
org.apache.uima.cas.impl.XmiCasSerializer.serialize(XmiCasSerializer.java:1567)
    at
org.apache.uima.ruta.testing.ui.handlers.RerunActionHandler.writeXmi(RerunActionHandler.java:652)
    at
org.apache.uima.ruta.testing.ui.handlers.RerunActionHandler.access$0(RerunActionHandler.java:647)
    at
org.apache.uima.ruta.testing.ui.handlers.RerunActionHandler$RerunHandlerJob.writeCleanInputFiles(RerunActionHandler.java:378)
    at
org.apache.uima.ruta.testing.ui.handlers.RerunActionHandler$RerunHandlerJob.evalRutaWithClassPathScript(RerunActionHandler.java:196)
    at
org.apache.uima.ruta.testing.ui.handlers.RerunActionHandler$RerunHandlerJob.run(RerunActionHandler.java:182)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)


    private void prepareCas(CAS cas) {
      if (!includedTypes.isEmpty()) {
        // exclude all other types if there are some included types
        excludedTypes = new ArrayList<String>();
        List<Type> types =
cas.getTypeSystem().getProperlySubsumedTypes(cas.getAnnotationType());
        for (Type type : types) {
          if (!includedTypes.contains(type.getName())) {
            excludedTypes.add(type.getName());
          }
        }
      }
      if (includedTypes.isEmpty() && excludedTypes.isEmpty()) {
        // remove all annotation in default settings
        String documentText = cas.getDocumentText();
        cas.reset();
        cas.setDocumentText(documentText);
      } else {
        List<AnnotationFS> toRemove = new LinkedList<AnnotationFS>();
        AnnotationIndex<AnnotationFS> annotationIndex =
cas.getAnnotationIndex();
        for (AnnotationFS annotationFS : annotationIndex) {
          Type type = annotationFS.getType();
          String typeName = type.getName();
          if (includedTypes.contains(typeName) ||
!excludedTypes.contains(typeName)) {
            toRemove.add(annotationFS);
          }
        }
        for (AnnotationFS each : toRemove) {
          if (!cas.getDocumentAnnotation().equals(each)) {
            cas.removeFsFromIndexes(each);
          }
        }
      }
    }


Reply via email to