### Install Dependencies Source: https://github.com/donaldpminer/edhrec/blob/master/README.md Install the required PRAW and Redis Python modules. ```bash pip install praw ``` ```bash pip install redis ``` -------------------------------- ### Get Deck Recommendations via API Source: https://context7.com/donaldpminer/edhrec/llms.txt Retrieves card recommendations for a specific deck URL. ```bash curl "http://edhrec.com/rec?to=http://tappedout.net/mtg-decks/my-omnath-deck/" ``` -------------------------------- ### GET /recent Source: https://context7.com/donaldpminer/edhrec/llms.txt Returns the most recently analyzed decks. ```APIDOC ## GET /recent ### Description Returns the most recently analyzed decks. ### Method GET ### Endpoint /recent ### Response #### Success Response (200) - **Array** (JSON) - A list of strings, where each string is a JSON object containing deck details like URL, commander, and reddit link. #### Response Example [ "{\"url\": \"http://tappedout.net/mtg-decks/deck1\", \"commander\": \"Omnath\", \"reddit\": \"http://reddit.com/abc123\"}", "{\"url\": \"http://tappedout.net/mtg-decks/deck2\", \"commander\": \"Prossh\"}" ] ``` -------------------------------- ### GET /rec Source: https://context7.com/donaldpminer/edhrec/llms.txt Returns card recommendations and deck statistics for a specific deck URL from supported platforms. ```APIDOC ## GET /rec ### Description Returns card recommendations for a specific deck URL from TappedOut, MTGSalvation, DeckStats, or GracefulStats. ### Method GET ### Endpoint /rec ### Parameters #### Query Parameters - **to** (string) - Required - The URL of the deck to analyze. ### Response #### Success Response (200) - **url** (string) - The original deck URL. - **recs** (array) - List of recommended cards with scores. - **cuts** (array) - List of unique cards in the deck with scores. - **stats** (object) - Statistics for the provided deck. - **kstats** (object) - Statistics for similar decks. - **cstats** (object) - Commander and land/nonland counts. #### Response Example { "url": "http://tappedout.net/mtg-decks/my-omnath-deck/", "recs": [ {"score": 0.85, "card_info": {"name": "Cultivate", "types": ["Sorcery"]}} ], "cuts": [ {"score": 0.65, "card_info": {"name": "Some Unique Card", "types": ["Creature"]}} ], "stats": {"types": {"Creature": 28, "Sorcery": 12}, "curve": [["0", 2], ["1", 8]]}, "kstats": {"types": {"Creature": 30, "Sorcery": 10}}, "cstats": {"commander": "Omnath, Locus of Mana", "lands": 38, "nonlands": 61} } ``` -------------------------------- ### GET /stats Source: https://context7.com/donaldpminer/edhrec/llms.txt Returns trending commanders and overall database statistics. ```APIDOC ## GET /stats ### Description Returns trending commanders and overall database statistics. ### Method GET ### Endpoint /stats ``` -------------------------------- ### GET /cmdrdeck Source: https://context7.com/donaldpminer/edhrec/llms.txt Generates a complete 99-card deck based on popular cards for a given commander. ```APIDOC ## GET /cmdrdeck ### Description Generates a complete 99-card deck based on popular cards for a given commander. ### Method GET ### Endpoint /cmdrdeck ### Parameters #### Query Parameters - **commander** (string) - Required - The name of the commander. ### Response #### Success Response (200) - **commander** (string) - Name of the commander. - **cards** (array) - List of cards in the generated deck. - **basics** (array) - List of basic lands. - **stats** (object) - Deck statistics. #### Response Example { "commander": "Omnath, Locus of Mana", "cards": [ {"count": 142, "card_info": {"name": "Sol Ring", "types": ["Artifact"]}} ], "basics": [["Forest", 32]], "stats": {"types": {"Creature": 28}, "colors": {"Green": 95}} } ``` -------------------------------- ### Get Global Statistics via API Source: https://context7.com/donaldpminer/edhrec/llms.txt Retrieves trending commanders and overall database statistics. ```bash curl "http://edhrec.com/stats" ``` -------------------------------- ### Get Commander Statistics via API Source: https://context7.com/donaldpminer/edhrec/llms.txt Retrieves aggregated statistics and popular cards for a specific commander. ```bash curl "http://edhrec.com/cmdr?commander=omnath%20locus%20of%20mana" ``` -------------------------------- ### GET /randomcmdr Source: https://context7.com/donaldpminer/edhrec/llms.txt Returns statistics for a random commander that has enough decks in the database. ```APIDOC ## GET /randomcmdr ### Description Returns statistics for a random commander that has enough decks in the database. ### Method GET ### Endpoint /randomcmdr ``` -------------------------------- ### GET /cmdr Source: https://context7.com/donaldpminer/edhrec/llms.txt Returns aggregated statistics and popular cards for a specific commander across all decks in the database. ```APIDOC ## GET /cmdr ### Description Returns aggregated statistics and popular cards for a specific commander across all decks in the database. ### Method GET ### Endpoint /cmdr ### Parameters #### Query Parameters - **commander** (string) - Required - The name of the commander. ### Response #### Success Response (200) - **commander** (string) - Name of the commander. - **numdecks** (integer) - Total number of decks analyzed. - **recs** (array) - Popular cards for this commander. - **stats** (object) - Aggregated deck statistics. - **archetypes** (array) - Identified deck archetypes. #### Response Example { "commander": "Omnath, Locus of Mana", "numdecks": 145, "recs": [ {"count": 142, "card_info": {"name": "Sol Ring", "types": ["Artifact"], "cmc": 1}} ], "stats": { "types": {"Creature": 25, "Sorcery": 12}, "curve": [["0", 2], ["1", 8]], "colors": {"Green": 95} }, "archetypes": [] } ``` -------------------------------- ### Get Decks Source: https://context7.com/donaldpminer/edhrec/llms.txt Retrieves decks from Redis filtered by color identity. Supports optional deduplication of near-identical decks. ```python import core # Get all mono-green decks green_decks = core.get_decks(['GREEN']) print(f"Found {len(green_decks)} mono-green decks") # Get all 5-color decks with deduplication five_color_decks = core.get_decks(['BLACK', 'BLUE', 'GREEN', 'RED', 'WHITE'], dedup=True) # Get all decks across all colors all_decks = core.get_all_decks(dedup=True) print(f"Total unique decks in corpus: {len(all_decks)}") ``` -------------------------------- ### Scrape TappedOut Deck (Python) Source: https://context7.com/donaldpminer/edhrec/llms.txt Extracts deck data from a TappedOut URL by parsing its text export format. Requires the 'tappedout' library. You can get the full deck details or just commander, colors, and date. ```python import tappedout # Scrape a deck from TappedOut url = "http://tappedout.net/mtg-decks/my-commander-deck/" deck = tappedout.get_deck(url) print(deck) # Output: # { # 'commander': 'omnath, locus of mana', # 'cards': ['card1', 'card2', 'card3', ...], # 'date': 735439 # Ordinal date # } # Get deck metadata (commander, colors, date) separately cmdr, colors, date = tappedout.get_tappedout_info(url) print(f"Commander: {cmdr}") print(f"Colors: {colors}") # ['GREEN'] print(f"Date: {date}") # Ordinal date integer ``` -------------------------------- ### Get Redis Connection Source: https://context7.com/donaldpminer/edhrec/llms.txt Retrieves a pooled Redis connection instance for data operations. Use this to access the BANNED set or query deck keys. ```python import core # Get a Redis connection r = core.get_redis() # Check if a card is on the ban list is_banned = r.sismember('BANNED', 'sol ring') # Get all deck keys deck_keys = r.keys('DECKS_*') # Returns keys like 'DECKS_BLACK_BLUE_GREEN' ``` -------------------------------- ### Initialize the Bot Source: https://github.com/donaldpminer/edhrec/blob/master/README.md Run the initialization script to prepare the environment. ```bash python initialize.py ``` -------------------------------- ### Configure Login Credentials Source: https://github.com/donaldpminer/edhrec/blob/master/README.md Format the login.txt file with username and password separated by a space. ```text BotAccount524 hunter2 ``` -------------------------------- ### Run the Bot Source: https://github.com/donaldpminer/edhrec/blob/master/README.md Execute the main bot script. ```bash python reddit.py ``` -------------------------------- ### Display Deck Recommendations Source: https://context7.com/donaldpminer/edhrec/llms.txt Prints recommended cards and unique cards for a given deck using the core library. ```python # new_recs: cards similar decks use that you don't have print("Cards to consider adding:") for card_name, score in new_recs[:10]: print(f" {core.cap_cardname(card_name)}: {score:.2f}") # unique_cards: cards you have that similar decks don't use print("\nUnique cards in your deck:") for card_name, score in unique_cards[:5]: print(f" {core.cap_cardname(card_name)}: {score:.2f}") # With returnk=True, also get the similar decks found new_recs, unique_cards, similar_decks = core.recommend(my_deck, k=15, returnk=True) print(f"\nFound {len(similar_decks)} similar decks for comparison") ``` -------------------------------- ### Generate Full Decklist via API Source: https://context7.com/donaldpminer/edhrec/llms.txt Generates a complete 99-card deck based on popular cards for a given commander. ```bash curl "http://edhrec.com/cmdrdeck?commander=omnath%20locus%20of%20mana" ``` -------------------------------- ### Initialize EDHREC Database with Card Data Source: https://context7.com/donaldpminer/edhrec/llms.txt Loads card data from a JSON file into Redis. This must be run before first use. Optionally loads sample decks and the ban list. ```python import initialize # Load cards from MTG JSON file initialize.load_cards_from_json('AllCards.json') # Optionally load sample decks import json import core for deck_json in open('decks_sample.json').readlines(): deck = json.loads(deck_json) core.add_deck(deck) # Load ban list for card in open('banlist.txt').read().strip().split('\n'): core.get_redis().sadd('BANNED', core.sanitize_cardname(card)) ``` -------------------------------- ### Find Commander Archetypes with k-means Clustering Source: https://context7.com/donaldpminer/edhrec/llms.txt Use k-means clustering to find archetypes for a given commander. Requires sufficient deck data in the database. Displays archetype percentage, number of decks, defining cards, and top recommendations. ```python archetypes = kmeans.kmeans('prossh, skyraider of kher', k=4) for i, archetype in enumerate(archetypes): print(f"\nArchetype {i + 1} ({archetype['percentdecks']}% of decks):") print(f" Number of decks: {archetype['numdecks']}") print(f" Defining cards:") for card in archetype['defining'][:5]: print(f" - {card['card_info']['name']}") print(f" Top recommendations:") for card in archetype['recs'][:5]: print(f" - {card['card_info']['name']} (score: {card['score']:.2f})") ``` -------------------------------- ### Download AllCards Data Source: https://github.com/donaldpminer/edhrec/blob/master/README.md Download the required AllCards.json file from MTGJSON. ```bash curl http://mtgjson.com/json/AllCards.json > AllCards.json ``` -------------------------------- ### Cluster Commander Archetypes (Python) Source: https://context7.com/donaldpminer/edhrec/llms.txt Uses k-means clustering to identify distinct deck archetypes for a given commander based on card choices. Requires the 'kmeans' library. ```python import kmeans ``` -------------------------------- ### Recommend Cards Source: https://context7.com/donaldpminer/edhrec/llms.txt Executes the collaborative filtering engine to suggest cards based on deck similarity. Returns recommended additions and unique cards found in the input deck. ```python import core # Input deck to get recommendations for my_deck = { 'commander': 'riku of two reflections', 'cards': [ 'riku of two reflections', 'sol ring', 'cultivate', 'mulldrifter', 'eternal witness', 'forest', 'island', 'mountain' ] } # Get recommendations (returns cards to add and cards that are unique to your deck) new_recs, unique_cards = core.recommend(my_deck, k=15) ``` -------------------------------- ### Configure Subreddit Scanning Source: https://github.com/donaldpminer/edhrec/blob/master/README.md Modify the subreddit selection logic in the bot configuration. ```python subreddit = PRAW.get_subreddit('edhrec+edh').get_new(limit=sublimit) ``` -------------------------------- ### Fetch Recent Decks (Bash) Source: https://context7.com/donaldpminer/edhrec/llms.txt Use this endpoint to retrieve a list of the most recently analyzed decks. The response is a JSON array of strings, where each string is a JSON object containing deck metadata. ```bash curl "http://edhrec.com/recent" ``` -------------------------------- ### Run the EDHREC Reddit Bot Source: https://context7.com/donaldpminer/edhrec/llms.txt The Reddit bot monitors subreddits for deck posts, scrapes decks, generates recommendations, and posts them as comments. Configure testing mode to prevent actual Reddit posts. Can run a single scan or continuously. ```python import reddit import core # Configure testing mode (prevents actual Reddit posts) reddit.TESTING = True # Run a single scan of submissions reddit.seek_submissions(sublimit=250) # Run continuously (production mode) if __name__ == '__main__': while True: try: reddit.seek_submissions() except Exception as e: print(f"Error: {e}") core.flush_cache() reddit.sleep(t=30.0) # Wait 30 seconds between scans ``` -------------------------------- ### Fetch Random Commander Stats (Bash) Source: https://context7.com/donaldpminer/edhrec/llms.txt This endpoint returns statistics for a randomly selected commander that meets the database criteria. The response format is identical to the /cmdr endpoint. ```bash curl "http://edhrec.com/randomcmdr" ``` -------------------------------- ### Commander-Specific Statistics (Python) Source: https://context7.com/donaldpminer/edhrec/llms.txt Retrieves aggregated statistics for all decks associated with a specific commander. Requires the 'deckstats' library. The output includes commander name, card types, mana curve, and color distribution. ```python import deckstats # Get stats for a specific commander stats = deckstats.get_commander_stats('omnath, locus of mana') print(stats) # Output: # { # 'commander': 'Omnath, Locus of Mana', # 'types': {'Creature': 26, 'Enchantment': 7, ...}, # 'curve': [('0', 2), ('1', 10), ...], # 'colors': {'Green': 48}, # 'nonlands': 61, # 'lands': 38 # } ``` -------------------------------- ### Scrape MTGSalvation Deck (Python) Source: https://context7.com/donaldpminer/edhrec/llms.txt Extracts deck data from MTGSalvation forum posts containing deck tables. Requires the 'mtgsalvation' library. This function can also scrape multiple pages of deck listings. ```python import mtgsalvation # Scrape a deck from MTGSalvation url = "http://www.mtgsalvation.com/forums/the-game/commander-edh/multiplayer-commander-decklists/123456" deck = mtgsalvation.scrape_deck(url) print(deck) # Output: # { # 'url': 'http://www.mtgsalvation.com/...', # 'mtgsalvation': 'http://www.mtgsalvation.com/...', # 'date': 735439, # 'scrapedate': '2014-11-08 01:56:25.872182', # 'commander': 'kaalia of the vast', # 'cards': ['kaalia of the vast', 'sol ring', ...], # 'ref': 'mtgsalvation' # } # Scrape multiple pages of deck forum listings for deck_link in mtgsalvation.frontpages(startpage=1, endpage=10): full_url = 'http://www.mtgsalvation.com' + deck_link try: deck = mtgsalvation.scrape_deck(full_url) print(f"Found deck: {deck['commander']}") except ValueError as e: print(f"Skipping invalid deck: {e}") ``` -------------------------------- ### Scrape GracefulStats Deck (Python) Source: https://context7.com/donaldpminer/edhrec/llms.txt Extracts deck data from GracefulStats using their JSON API. Requires the 'gracefulstats' library. The output includes commander, cards, date, and reference. ```python import gracefulstats # Scrape a deck from GracefulStats url = "http://www.gracefulstats.com/deck/view/9349" deck = gracefulstats.scrapedeck(url) print(deck) # Output: # { # 'commander': 'omnath, locus of mana', # 'cards': ['card1', 'card2', ...], # 'date': '2014-11-08', # 'ref': 'gracefulstats' # } ``` -------------------------------- ### Add Deck Source: https://context7.com/donaldpminer/edhrec/llms.txt Persists a deck dictionary to Redis. The function returns False if the deck is identified as a duplicate. ```python import core # Create a deck dictionary deck = { 'commander': 'omnath, locus of mana', 'cards': [ 'omnath, locus of mana', 'sol ring', 'lightning greaves', 'forest', 'forest', 'cultivate', 'kodama\'s reach' ], 'date': 735439, # Ordinal date 'url': 'http://tappedout.net/mtg-decks/my-omnath-deck/', 'scrapedate': '2014-11-08 01:56:25.872182', 'ref': 'tappedout' } # Add deck to corpus (returns False if duplicate) success = core.add_deck(deck) if success: print("Deck added successfully") else: print("Deck was a duplicate, not added") ``` -------------------------------- ### Tally Deck Statistics (Python) Source: https://context7.com/donaldpminer/edhrec/llms.txt Calculates aggregate statistics for a collection of decks, including card type distribution, mana curve, and color distribution. Requires 'deckstats' and 'core' libraries. You can filter decks by color. ```python import deckstats import core # Get statistics for a list of decks decks = core.get_decks(['GREEN'])[:10] # First 10 mono-green decks stats = deckstats.tally(decks) print(stats) # Output: # { # 'types': {'Creature': 28.5, 'Enchantment': 8.2, 'Sorcery': 10.1, ...}, # 'curve': [('0', 2.1), ('1', 8.3), ('2', 14.2), ('3', 12.5), ...], # 'colors': {'Green': 45.2, 'Red': 0, 'Blue': 0, 'White': 0, 'Black': 0}, # 'nonlands': 62, # 'lands': 37 # } ``` -------------------------------- ### Lookup Card Source: https://context7.com/donaldpminer/edhrec/llms.txt Retrieves detailed card metadata from the database. Returns a dictionary containing properties like types, mana cost, and text. ```python import core # Look up card information card = core.lookup_card("lightning greaves") print(card) # Output: # { # 'name': 'Lightning Greaves', # 'types': ['Artifact', 'Equipment'], # 'cmc': 2, # 'manaCost': '{2}', # 'text': 'Equipped creature has haste and shroud...' # } # Check card types if 'Creature' in card['types']: print("This is a creature") ``` -------------------------------- ### Core Functions Source: https://context7.com/donaldpminer/edhrec/llms.txt This section details the core Python functions available in the EDHREC library for interacting with the API and data. ```APIDOC ## Core Functions ### Get Redis Connection Returns a pooled Redis connection instance, automatically reconnecting if the connection is lost. All deck data, card information, and caching is stored in Redis. ```python import core # Get a Redis connection r = core.get_redis() # Check if a card is on the ban list is_banned = r.sismember('BANNED', 'sol ring') # Get all deck keys deck_keys = r.keys('DECKS_*') # Returns keys like 'DECKS_BLACK_BLUE_GREEN' ``` ### Sanitize Card Name Normalizes card names by removing accents, converting to lowercase, and handling special characters. All card names must be sanitized before storage or lookup. ```python import core # Sanitize various card name formats card1 = core.sanitize_cardname("Æther Vial") # Returns: "aether vial" card2 = core.sanitize_cardname("Jötun Grunt") # Returns: "jotun grunt" card3 = core.sanitize_cardname(" Sol Ring ") # Returns: "sol ring" # Reverse for display - capitalize properly display_name = core.cap_cardname("sol ring") # Returns: "Sol Ring" display_name2 = core.cap_cardname("sorin's thirst") # Returns: "Sorin's Thirst" ``` ### Lookup Card Retrieves card data from the pre-loaded card database. Returns a dictionary with card properties including name, types, mana cost, and text. ```python import core # Look up card information card = core.lookup_card("lightning greaves") print(card) # Output: # { # 'name': 'Lightning Greaves', # 'types': ['Artifact', 'Equipment'], # 'cmc': 2, # 'manaCost': '{2}', # 'text': 'Equipped creature has haste and shroud...' # } # Check card types if 'Creature' in card['types']: print("This is a creature") ``` ### Color Identity Determines the color identity of a card by analyzing its mana cost and text for colored mana symbols. Returns a sorted list of color names. ```python import core # Get color identity for commanders colors = core.color_identity("sliver overlord") print(colors) # Output: ['BLACK', 'BLUE', 'GREEN', 'RED', 'WHITE'] colors = core.color_identity("omnath, locus of mana") print(colors) # Output: ['GREEN'] colors = core.color_identity("sol ring") print(colors) # Output: [] ``` ### Add Deck Stores a deck in Redis, organized by the commander's color identity. Automatically detects and rejects duplicate decks. ```python import core # Create a deck dictionary deck = { 'commander': 'omnath, locus of mana', 'cards': [ 'omnath, locus of mana', 'sol ring', 'lightning greaves', 'forest', 'forest', 'cultivate', 'kodama\'s reach' ], 'date': 735439, # Ordinal date 'url': 'http://tappedout.net/mtg-decks/my-omnath-deck/', 'scrapedate': '2014-11-08 01:56:25.872182', 'ref': 'tappedout' } # Add deck to corpus (returns False if duplicate) success = core.add_deck(deck) if success: print("Deck added successfully") else: print("Deck was a duplicate, not added") ``` ### Get Decks Retrieves all decks for a given color identity from Redis. Optionally deduplicates near-duplicate decks. ```python import core # Get all mono-green decks green_decks = core.get_decks(['GREEN']) print(f"Found {len(green_decks)} mono-green decks") # Get all 5-color decks with deduplication five_color_decks = core.get_decks(['BLACK', 'BLUE', 'GREEN', 'RED', 'WHITE'], dedup=True) # Get all decks across all colors all_decks = core.get_all_decks(dedup=True) print(f"Total unique decks in corpus: {len(all_decks)}") ``` ### Recommend Cards The main recommendation engine using collaborative filtering. Finds the k most similar decks and tallies cards that appear in those decks but not in the input deck. ```python import core # Input deck to get recommendations for my_deck = { 'commander': 'riku of two reflections', 'cards': [ 'riku of two reflections', 'sol ring', 'cultivate', 'mulldrifter', 'eternal witness', 'forest', 'island', 'mountain' ] } # Get recommendations (returns cards to add and cards that are unique to your deck) new_recs, unique_cards = core.recommend(my_deck, k=15) ``` ``` -------------------------------- ### Scrape DeckStats Deck (Python) Source: https://context7.com/donaldpminer/edhrec/llms.txt Extracts deck data from a DeckStats.net URL. Requires the 'deckstatscom' library. The scraped data includes URL, scrape date, commander, cards, and reference. ```python import deckstatscom # Scrape a deck from DeckStats url = "http://deckstats.net/decks/11763/98275-athreos-god-of-passage/en" deck = deckstatscom.scrapedeck(url) print(deck) # Output: # { # 'url': 'http://deckstats.net/decks/11763/98275-athreos-god-of-passage/en', # 'scrapedate': '2014-11-08 01:56:25.872182', # 'commander': 'athreos, god of passage', # 'cards': ['card1', 'card2', ...], # 'ref': 'deckstats' # } ``` -------------------------------- ### Color Identity Source: https://context7.com/donaldpminer/edhrec/llms.txt Analyzes a card's mana cost and text to determine its color identity. Returns a list of color names. ```python import core # Get color identity for commanders colors = core.color_identity("sliver overlord") print(colors) # Output: ['BLACK', 'BLUE', 'GREEN', 'RED', 'WHITE'] colors = core.color_identity("omnath, locus of mana") print(colors) # Output: ['GREEN'] colors = core.color_identity("sol ring") print(colors) # Output: [] ``` -------------------------------- ### Check Duplicate Decks Source: https://context7.com/donaldpminer/edhrec/llms.txt Determines if two decks are near-duplicates based on a configurable card overlap threshold. ```python import core deck1 = {'commander': 'omnath, locus of mana', 'cards': ['card1', 'card2', 'card3']} deck2 = {'commander': 'omnath, locus of mana', 'cards': ['card1', 'card2', 'card4']} deck3 = {'commander': 'azusa, lost but seeking', 'cards': ['card1', 'card2', 'card3']} # Check if decks are duplicates (default threshold: 70% overlap) print(core.decks_are_dups(deck1, deck2)) # True if >70% overlap print(core.decks_are_dups(deck1, deck3)) # False (different commander) print(core.decks_are_dups(deck1, deck2, threshold=0.9)) # More strict threshold ``` -------------------------------- ### Calculate Deck Closeness Score Source: https://context7.com/donaldpminer/edhrec/llms.txt Computes a similarity score between two deck dictionaries based on card overlap and other metadata. ```python import core deck1 = { 'commander': 'omnath, locus of mana', 'cards': ['omnath, locus of mana', 'sol ring', 'cultivate', 'forest'], 'scrapedate': '2014-11-08 01:56:25.872182' } deck2 = { 'commander': 'omnath, locus of mana', 'cards': ['omnath, locus of mana', 'sol ring', 'kodama\'s reach', 'forest'], 'scrapedate': '2014-11-10 01:56:25.872182' } # Calculate closeness (higher = more similar) score = core.rec_deck_closeness(deck1, deck2) print(f"Deck similarity score: {score:.4f}") # Typically 0.0 to 1.0+ ``` -------------------------------- ### Sanitize Card Name Source: https://context7.com/donaldpminer/edhrec/llms.txt Normalizes card names for storage and lookup by removing accents and casing. Use cap_cardname to reverse the process for display purposes. ```python import core # Sanitize various card name formats card1 = core.sanitize_cardname("Æther Vial") # Returns: "aether vial" card2 = core.sanitize_cardname("Jötun Grunt") # Returns: "jotun grunt" card3 = core.sanitize_cardname(" Sol Ring ") # Returns: "sol ring" # Reverse for display - capitalize properly display_name = core.cap_cardname("sol ring") # Returns: "Sol Ring" display_name2 = core.cap_cardname("sorin's thirst") # Returns: "Sorin's Thirst" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.