feat: add KeywordDigitCounter class for filtering digit counters in OCR results

This commit is contained in:
2026-07-05 17:55:16 +08:00
parent 84ac3dc9b8
commit fc5847d6d8
3 changed files with 18 additions and 5 deletions
+15
View File
@@ -201,3 +201,18 @@ class Keyword:
# Not found
raise ScriptError(f'Cannot find a {cls.__name__} instance that matches "{name}"')
class KeywordDigitCounter(Keyword):
"""
A fake Keyword class to filter digit counters in ocr results
OcrResultButton.match_keyword will be a str
"""
@classmethod
def find(cls, name, lang: str = None, ignore_punctuation=True):
from module.ocr.ocr import DigitCounter
if DigitCounter.is_format_matched(name):
return name
else:
raise ScriptError