-
Notifications
You must be signed in to change notification settings - Fork 34
fix(ui): normalize ship selection matching and level filtering (copilot addressed v4) #441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f263b44
fix(ui): normalize ship selection and level filtering
yltx 3ea125e
chore(release): bump version to 2.1.9.post6
yltx 06eb36b
fix(ui): address Copilot review for level OCR parsing
yltx 4315744
fix(ui): address Copilot review for level parsing and probing
yltx 9a501e8
fix(ui): address Copilot review for level binding and OCR noise
yltx 8418eae
fix(ui): address Copilot review for OCR noise i and docs
yltx d6277f9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| """AutoWSGR - 战舰少女R 自动化框架(v2)""" | ||
|
|
||
| __version__ = '2.1.9.post5' | ||
| __version__ = '2.1.9.post6' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,7 +31,9 @@ | |||||||
| #: Legacy 选船列表左侧裁剪宽度 (px@1280) | ||||||||
| LEGACY_LIST_WIDTH: int = 1048 | ||||||||
|
|
||||||||
| _LEVEL_PATTERN = re.compile(r'[Ll][Vv]\.?\s*(\d+)') | ||||||||
| _LEVEL_PATTERN = re.compile(r'[Ll][Vv]\.?\s*([0-9ILilOo]{1,6})') | ||||||||
| _LEVEL_NOISY_PATTERN = re.compile(r'(?:[LlIi1O0][VvYy])[\.:]?\s*([0-9ILilOo]{1,6})') | ||||||||
| _MAX_LEVEL_VALUE = 200 | ||||||||
|
|
||||||||
|
|
||||||||
| def to_legacy_format(screen: np.ndarray) -> tuple[np.ndarray, float, float]: | ||||||||
|
|
@@ -169,15 +171,124 @@ def recognize_ships_in_list( | |||||||
|
|
||||||||
| def _parse_level(text: str) -> int | None: | ||||||||
| """从 OCR 文本中提取 ``Lv.XX`` 格式等级数字。""" | ||||||||
| m = _LEVEL_PATTERN.search(text) | ||||||||
| compact = text.strip().replace(' ', '') | ||||||||
|
|
||||||||
| m = _LEVEL_PATTERN.search(compact) | ||||||||
| if m: | ||||||||
| try: | ||||||||
| return int(m.group(1)) | ||||||||
| except ValueError: | ||||||||
| return None | ||||||||
| level = _coerce_level_digits(m.group(1)) | ||||||||
| if level is not None: | ||||||||
| return level | ||||||||
|
|
||||||||
| m2 = _LEVEL_NOISY_PATTERN.search(compact) | ||||||||
| if m2: | ||||||||
| level = _coerce_level_digits(m2.group(1)) | ||||||||
| if level is not None: | ||||||||
| return level | ||||||||
|
|
||||||||
| return None | ||||||||
|
|
||||||||
|
|
||||||||
| def _coerce_level_digits(raw_digits: str) -> int | None: | ||||||||
| """将 OCR 提取出的数字串映射为合法等级值。""" | ||||||||
| trans = str.maketrans( | ||||||||
| { | ||||||||
| 'I': '1', | ||||||||
| 'i': '1', | ||||||||
| 'l': '1', | ||||||||
|
||||||||
| 'l': '1', | |
| 'l': '1', | |
| 'L': '1', |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新增的等级解析/噪声矫正逻辑(
_parse_level()+_coerce_level_digits(),包括i -> 1、前 3 位截断、_LEVEL_NOISY_PATTERN等)目前没有对应的单元测试覆盖;仓库里已有testing/vision/test_ocr.py这类 OCR 相关单测框架。建议补充一些纯字符串输入的单测用例,覆盖典型 OCR 噪声(如Lv.i5、Iv:O3、Lv.051、Lv.110544)以及超界值被拒绝的情况,避免后续调整 regex/映射时回归。