Closed DavidHuebner closed 2 years ago
How about using type.name
?
This works in principle, but we should guarantee that the Type object has a proper string representation when called. Especially since calling str(annotation)
(or print(annotation)
) will always call str(annotation.type)
and lead to this kind of messy output.
So maybe adding something like the following representation to the Type
class will already do the job.
def __str__(self):
return f"Type(name={self.name})"
We added your suggested change and it will be in the next release.
Describe the bug The attribute
.type
of an annotation seems to be calling an infinite recursion loop instead of printing the simple type name. This is quite a severe bug as this prevents us not only from accessingannotation.type
, but also from just printing an annotation.To Reproduce Steps to reproduce the behavior:
with open('typesystem.xml', 'rb') as f: typesystem = load_typesystem(f)
with open('test.xmi', 'rb') as f: cas = load_cas_from_xmi(f, typesystem=typesystem)
doc = cas.select("uima.tcas.DocumentAnnotation")[0] print(len(str(doc.type))) # 26350638 --> OUCH
print(doc) --> might crash your application