Extracting from <class 'haystack.schema.Answer'>

30 Views Asked by At

I have an answer from the Haystack framework, which is: <Answer: answer='major mild ncd', score=0.09601292014122009, context='d neurocognitive disorder due hiv infection functi...'> The type of it is <class 'haystack.schema.Answer'>. How to extract the context and the score from it?

I cannot access the elements as for lists or dictionaries

1

There are 1 best solutions below

0
Karan Shishoo On

As per Haystack docs (just search for haystack.schema.Answer to see the example code), you can directly access the values by using -

score = answer.score
context = answer.context

where answer is your haystack.schema.Answer object