amazon-textract-response-parser icon indicating copy to clipboard operation
amazon-textract-response-parser copied to clipboard

No confindence levels in query output (with solution)

Open noxqs opened this issue 2 years ago • 0 comments

I would like to know the confidence level of query results, however this is not made available. I suggest to make a small change to get_query_answers in trp2.py:

  def get_query_answers(self, page: TBlock) -> List[List[str]]:
        result_list: List[List[str]] = list()
        for query in self.queries(page=page):
            answers = [x for x in self.get_answers_for_query(block=query)]
            if answers:
                for answer in answers:
                    result_list.append([query.query.text, query.query.alias, answer.text, answer.confidence])
            else:
                result_list.append([query.query.text, query.query.alias, "", 0])

This will make confidence available as fourth item in the return list and maintains compatibility with previous output.

noxqs avatar Jul 01 '22 08:07 noxqs