diff --git a/Site/OriginDex.py b/Site/OriginDex.py index 7993719..e5d33af 100644 --- a/Site/OriginDex.py +++ b/Site/OriginDex.py @@ -3,7 +3,38 @@ from flask import Flask, render_template, jsonify from collections import defaultdict import os import json +import re import wordninja +from typing import List, Set + +class CustomWordNinja: + def __init__(self, custom_words: List[str] = None): + self.custom_words = [] + if custom_words: + # Store custom words with original capitalization, sorted by length + self.custom_words = sorted(custom_words, key=len, reverse=True) + + def split(self, text: str) -> str: + working_text = text + + # First handle exact custom words to preserve capitalization + for word in self.custom_words: + pattern = re.compile(word, re.IGNORECASE) + working_text = pattern.sub(f' {word} ', working_text) + + # Clean up spaces + working_text = ' '.join(working_text.split()) + + # For remaining text, use wordninja + parts = [] + for part in working_text.split(): + if part in self.custom_words: + parts.append(part) + else: + split_parts = wordninja.split(part) + parts.extend(split_parts) + + return ' '.join(parts) POKEMON_PROPER_NOUNS = { "Alola", @@ -124,6 +155,8 @@ def load_pokemon_data(): @app.route('/') def index(): pokemon_list = load_pokemon_data() + + splitter = CustomWordNinja(POKEMON_PROPER_NOUNS) try: with open('efficiency_plan.json', 'r', encoding='utf-8') as f: @@ -142,9 +175,8 @@ def index(): direct = cursor.fetchone() if direct: - words = wordninja.split(direct[0]) - cleaned_method = ' '.join(words) - return [cleaned_method] + words = splitter.split(direct[0]) + return [words] # Try to find indirect evolution path cursor.execute(''' @@ -174,9 +206,8 @@ def index(): cleaned_methods = [] for method in methods: # Split and rejoin with spaces - words = wordninja.split(method[0]) - cleaned_method = ' '.join(words) - cleaned_methods.append(cleaned_method) + words = splitter.split(method[0]) + cleaned_methods.append(words) return cleaned_methods return ['Evolution'] @@ -238,12 +269,6 @@ def pokemon_details(pfic): return jsonify(encounters) if __name__ == '__main__': - # Add the custom words to wordninja's word list - #wordninja.DEFAULT_WEIGHT_MULTIPLIER = 2 # Make default words twice as likely - #for word in POKEMON_PROPER_NOUNS: - # wordninja.addWords([word], weight=10) # Higher weight makes these words more likely to be kept together - - extra_files = ['.'] extra_dirs = ['./templates/', './static/'] for extra_dir in extra_dirs: diff --git a/Site/templates/index.html b/Site/templates/index.html index 29d65c6..2c0ba3f 100644 --- a/Site/templates/index.html +++ b/Site/templates/index.html @@ -320,6 +320,24 @@ align-items: center; } + .catch-count-container { + display: flex; + align-items: center; + gap: 5px; + } + + .catch-count-pokeball { + width: 20px; + height: 20px; + object-fit: contain; + } + + .catch-count { + color: #666; + font-size: 1.1em; + font-weight: bold; + } + .pokemon-details { display: none; padding: 15px; @@ -336,11 +354,6 @@ object-fit: contain; } - .catch-count { - color: #666; - font-size: 0.9em; - } - .evolution-list, .breeding-list { margin: 10px 0; padding: 10px; @@ -406,6 +419,38 @@ font-size: 0.8em; color: #4CAF50; } + + .accordion-button-static { + position: relative; + display: flex; + align-items: center; + width: 100%; + padding: var(--bs-accordion-btn-padding-y) var(--bs-accordion-btn-padding-x); + font-size: 1rem; + color: var(--bs-accordion-btn-color); + text-align: left; + background-color: var(--bs-accordion-btn-bg); + border: 0; + border-radius: 0; + overflow-anchor: none; + } + + .accordion-button-static img { + margin-right: 0.5rem; + } + + /* Remove hover effects if desired */ + .accordion-button-static:hover { + z-index: 2; + } + + .pokemon-header-right { + display: flex; + align-items: center; + min-width: 80px; /* Adjust this value to match your needs */ + justify-content: space-between; + gap: 10px; + }
@@ -472,7 +517,7 @@
@@ -480,8 +525,17 @@
+ {{ pokemon.catch_count }}
+