dkpro / dkpro-cassis

UIMA CAS processing library written in Python
https://pypi.org/project/dkpro-cassis/
Apache License 2.0
84 stars 22 forks source link

Error if there is no sofa #218

Open reckart opened 2 years ago

reckart commented 2 years ago

Describe the bug It is possible to create CAS objects in the UIMA Java SDK that do contain feature structures but not any sofa. XMI representing such CAS objects cannot be loaded in cassis.

To Reproduce

  public static CAS casWithFloatingPointSpecialValues() throws Exception {
    CAS cas = createCas();

    DoubleArrayFS doubleArrayFs = cas.createDoubleArrayFS(5);
    doubleArrayFs.set(0, 0.0);
    doubleArrayFs.set(1, 1.0);
    doubleArrayFs.set(2, Double.NEGATIVE_INFINITY);
    doubleArrayFs.set(3, Double.POSITIVE_INFINITY);
    doubleArrayFs.set(4, Double.NaN);
    cas.addFsToIndexes(doubleArrayFs);

    return cas;
  }
<?xml version="1.0" encoding="UTF-8"?><xmi:XMI xmlns:noNamespace="http:///uima/noNamespace.ecore" xmlns:tcas="http:///uima/tcas.ecore" xmlns:xmi="http://www.omg.org/XMI" xmlns:cas="http:///uima/cas.ecore" xmi:version="2.0">
    <cas:NULL xmi:id="0"/>
    <cas:DoubleArray xmi:id="1" elements="0.0 1.0 -Infinity Infinity NaN"/>
    <cas:View members="1"/>
</xmi:XMI>

Expected behavior Good question. I'd say the CAS should load and probably add the feature structures to the default view but without initializing the sofa of the view.

Error message

../cassis/xmi.py:73: in load_cas_from_xmi
    return deserializer.deserialize(
../cassis/xmi.py:123: in deserialize
    proto_view = self._parse_view(elem)
../cassis/xmi.py:295: in _parse_view
    sofa = int(attributes["sofa"])

Please complete the following information: