(image, items, prompt_item, image_h, image_w, prompt_chars=None, engine=None)
| 617 | candidates.extend(split_ocr_item(image, item, prompt_chars=prompt_chars, engine=engine)) |
| 618 | candidates = [ |
| 619 | cand |
| 620 | for cand in candidates |
| 621 | if len(cand.get('char') or '') == 1 or (prompt_chars and not cand.get('char')) |
| 622 | ] |
| 623 | candidates = sorted(candidates, key=lambda cand: (cand['bbox'][1], cand['bbox'][0])) |
| 624 | candidates = repair_candidates_by_prompt(candidates, prompt_chars or []) |
| 625 | return candidates |
| 626 | |
| 627 | |
| 628 | def match_prompt_to_candidates(prompt_chars, candidate_chars): |
| 629 | buckets = {} |
| 630 | for candidate in candidate_chars: |
| 631 | buckets.setdefault(candidate['char'], []).append(candidate) |
| 632 | |
| 633 | for char in buckets: |
| 634 | buckets[char].sort(key=lambda cand: (-cand['score'], -cand['area'])) |
| 635 |
no test coverage detected