0

I have the following output from a function and I need to read shape, labels, and domain from this stream.

[Annotation(shape=Rectangle(x=0.0, y=0.0, width=1.0, height=1.0), labels=[ScoredLabel(62282a1dc79ed6743e731b36, name=GOOD, probability=0.5143796801567078, domain=CLASSIFICATION, color=Color(red=233, green=97, blue=21, alpha=255), hotkey=ctrl+3)], id=622cc4d962f051a8f41ddf35)]

I need them as follows

shp = Annotation.shape
lbl = Annotation.labels
dmn = domain

It seems simple but I could not figure it out yet.

5
  • Is that "output" a string of text that you want to parse? Commented Mar 12, 2022 at 16:18
  • Where does domain come from? Commented Mar 12, 2022 at 16:19
  • You could think its as a string. But I don't want to use split or regex here. Commented Mar 12, 2022 at 16:20
  • domain is there too."domain=CLASSIFICATION" Commented Mar 12, 2022 at 16:21
  • "You could think its as a string" -- but would you be correct if you thought that? Commented Mar 12, 2022 at 16:31

1 Answer 1

1

Given output as a list of Annotation objects:

output = [Annotation(...)]

you ought to be able to simply do:

shp = output[0].shape
lbl = output[0].labels
dmn = labels[0].domain
Sign up to request clarification or add additional context in comments.

1 Comment

Wow, this is exactly what I was looking for. onot believe that I did not add the []....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.