修复比分识别错误问题

- 修复将日期时间误识别为比分的bug(如"19-00")
- 改进比分识别逻辑:
  - 只在包含"vs"的行中查找比分模式
  - 验证比分在合理范围内(0-5)
  - 排除时间格式的模式
- 更新CHANGELOG记录此修复

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ching L 2025-09-05 17:39:19 +08:00
parent 63a1559e86
commit d3b872cd86
2 changed files with 31 additions and 2 deletions

View File

@ -1,5 +1,12 @@
# Changelog # Changelog
## v3.2.1 - 修复比分识别问题
- **修复错误的比分解析**
- 修复了将日期时间误识别为比分的问题(如 "19-00"
- 改进比分识别逻辑,只在包含 "vs" 的上下文中查找比分
- 添加比分范围验证0-5排除不合理的数值
- 增强时间模式识别,避免将时间戳识别为比分
## v3.2 - TBD 比赛优化 ## v3.2 - TBD 比赛优化
- **智能去重机制** - **智能去重机制**
- 相同时间、相同轮次的多个 TBD 比赛只保留一个代表 - 相同时间、相同轮次的多个 TBD 比赛只保留一个代表

View File

@ -108,8 +108,30 @@ class Dota2CalendarSync:
text = parent.get_text() text = parent.get_text()
# Check if it has a score (completed match) # Check if it has a score (completed match)
score_match = re.search(r'(\d+)[-:](\d+)', text) # Look for score patterns specifically in match result context
has_score = score_match and not ('10:00' in text or '13:00' in text or '16:00' in text) # Scores are typically between team names, not part of timestamps
score_match = None
has_score = False
# First check if this looks like a completed match by looking for score indicators
# Split the text to analyze structure better
lines = text.split('\n')
for line in lines:
# Look for patterns like "Team1 2-1 Team2" or "Team1 2:1 Team2"
# Score should be surrounded by team names or 'vs' context
if 'vs' in line.lower():
# Check for score pattern near 'vs'
score_pattern = re.search(r'(?:^|\s)(\d{1,2})[-:](\d{1,2})(?:\s|$)', line)
if score_pattern:
score1 = int(score_pattern.group(1))
score2 = int(score_pattern.group(2))
# Validate it's a reasonable game score (typically 0-5 for Bo5, 0-3 for Bo3)
if 0 <= score1 <= 5 and 0 <= score2 <= 5 and (score1 + score2) > 0:
# Additional check: not a time pattern
if not re.search(r'\d{1,2}:\d{2}(?:\s*[AP]M)?(?:\s*[A-Z]{3,4})?', line):
score_match = score_pattern
has_score = True
break
# Extract teams and format # Extract teams and format
vs_pattern = r'([A-Za-z0-9\s\.\-_]+?)vs\(?(Bo\d)\)?([A-Za-z0-9\s\.\-_]+?)(?:TI2025|Round|Playoff|Group|\+|$)' vs_pattern = r'([A-Za-z0-9\s\.\-_]+?)vs\(?(Bo\d)\)?([A-Za-z0-9\s\.\-_]+?)(?:TI2025|Round|Playoff|Group|\+|$)'