MCPcopy
hub / github.com/IPADS-SAI/MobiAgent / OCRResult

Class OCRResult

utils/ocr_engine.py:79–105  ·  view source on GitHub ↗

OCR识别的完整结果

Source from the content-addressed store, hash-verified

77
78@dataclass
79class OCRResult:
80 """OCR识别的完整结果"""
81 words: List[OCRWord]
82
83 def get_text(self) -> str:
84 """获取所有文字内容的拼接字符串"""
85 return " ".join([w.text for w in self.words])
86
87 def find(self, keyword: str, fuzzy: bool = True) -> bool:
88 """
89 在OCR结果中查找关键词
90
91 Args:
92 keyword: 要查找的关键词
93 fuzzy: 是否使用模糊匹配
94
95 Returns:
96 是否找到关键词
97 """
98 text = self.get_text()
99 if not fuzzy:
100 return keyword in text
101 try:
102 from rapidfuzz import fuzz
103 return fuzz.partial_ratio(keyword, text) >= 80
104 except ImportError:
105 return keyword in text
106
107
108class OCREngine:

Callers 1

runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected