Key Information Extractor
Key Information Extraction (KIE) heuristics for the vision module of Otary.
HeuristicKeyInformationExtractor
Key Information Extraction (KIE) heuristic class
Source code in otary/vision/kie/heuristic.py
extract(ocr_outputs, key, closest_word_dist_thresh, levenshtein_threshold=0.9, exact_key_match=False)
staticmethod
Extracts key-value pairs from OCR outputs by matching keys heuristically using Levenshtein distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ocr_outputs
|
List[OCRSingleOutput]
|
OCR results, each containing a value and access to closest_word(to="left"). |
required |
key
|
str
|
expected keys to match. |
required |
closest_word_dist_thresh
|
float
|
Maximum distance between the OCR key bounding box and the closest word bounding box for the value. |
required |
levenshtein_threshold
|
float
|
Minimum normalized distance for a valid match |
0.9
|
exact_key_match
|
bool
|
Whether to match keys exactly |
False
|
Returns:
| Type | Description |
|---|---|
list[OcrSingleOutput]
|
Dict[str, str]: Dictionary mapping expected keys to matched values. |