Spaces:
Running
Running
Upload ai/decks/verify_decks.py with huggingface_hub
Browse files- ai/decks/verify_decks.py +45 -0
ai/decks/verify_decks.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
|
| 3 |
+
with open(
|
| 4 |
+
r"c:\Users\trios\.gemini\antigravity\vscode\loveca-copy\ai\decks\groupwinnersraw.txt", "r", encoding="utf-8"
|
| 5 |
+
) as f:
|
| 6 |
+
content = f.read()
|
| 7 |
+
|
| 8 |
+
# Split by deck headers
|
| 9 |
+
sections = re.split(r'<h1 class="parts-h1-2">', content)
|
| 10 |
+
deck_sections = sections[1:]
|
| 11 |
+
|
| 12 |
+
names = ["Aqours", "Nijigaku", "Liella", "Muse", "Hasunosora"]
|
| 13 |
+
|
| 14 |
+
for i, section in enumerate(deck_sections):
|
| 15 |
+
if i >= len(names):
|
| 16 |
+
break
|
| 17 |
+
|
| 18 |
+
print(f"--- {names[i]} Cup ---")
|
| 19 |
+
|
| 20 |
+
# Split section by category headers
|
| 21 |
+
categories = re.split(r'<h2 class="parts-h2-3">', section)
|
| 22 |
+
# categories[0] is intro
|
| 23 |
+
# Then usually Live, Member, Energy
|
| 24 |
+
|
| 25 |
+
cat_counts = {}
|
| 26 |
+
|
| 27 |
+
for cat_chunk in categories[1:]:
|
| 28 |
+
# Get category name from the beginning of chunk
|
| 29 |
+
cat_match = re.match(r"([^<]+)</h2>", cat_chunk)
|
| 30 |
+
if not cat_match:
|
| 31 |
+
continue
|
| 32 |
+
cat_name = cat_match.group(1).strip()
|
| 33 |
+
|
| 34 |
+
# Find all cards in this category
|
| 35 |
+
matches = re.findall(r'<span class="sheet"><span>×</span><span>(\d+)</span></span>', cat_chunk)
|
| 36 |
+
total_count = sum(int(c) for c in matches)
|
| 37 |
+
unique_types = len(matches)
|
| 38 |
+
|
| 39 |
+
cat_counts[cat_name] = (total_count, unique_types)
|
| 40 |
+
print(f" {cat_name}: {total_count} cards ({unique_types} unique types)")
|
| 41 |
+
|
| 42 |
+
# Totals
|
| 43 |
+
total_cards = sum(count for count, _ in cat_counts.values())
|
| 44 |
+
print(f" Total: {total_cards} cards")
|
| 45 |
+
print()
|