from paddleocr import PaddleOCR

ocr = PaddleOCR(use_angle_cls=True, lang="en")

def extract_text(image_path: str):
    """Extract tokens + boxes from an image using PaddleOCR"""
    results = ocr.ocr(image_path, cls=True)
    tokens = []
    for res in results[0]:
        (bbox, text, prob) = res
        tokens.append({"bbox": bbox, "text": text[0], "score": prob})
    return tokens
