MCPcopy Create free account
hub / github.com/VitoHowe/glm-coding / build_candidate_chars

Function build_candidate_chars

app/services/tenvision_adapter.py:619–632  ·  view source on GitHub ↗
(image, items, prompt_item, image_h, image_w, prompt_chars=None, engine=None)

Source from the content-addressed store, hash-verified

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
628def 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

Callers 1

run_pipeline_bytesFunction · 0.85

Calls 3

is_ignored_itemFunction · 0.85
split_ocr_itemFunction · 0.85

Tested by

no test coverage detected