[['class=[', '][^"\']*word[^"\']*["\'][^>]*data-word=["\']([^"\']+)["\'][^>]*data-gloss=["\']([^"\']+)["\'][^>]*>', 'matches = re.findall(pattern, html, re.IGNORECASE)\n    eng_to_quenya = {}\n    for quenya, gloss in matches:\n        gloss_lower = gloss.lower()\n        # Keep only the first sense; if multiple, they\'re separated by ;\n        gloss_lower = gloss_lower.split(\';\')[0].strip()\n        # Also split by comma if multiple meanings\n        # Use the gloss as key, but may have variations\n        eng_to_quenya[gloss_lower] = quenya\n    print(f"Loaded {len(eng_to_quenya)} Quenya dictionary entries', "return eng_to_quenya\n\ndef translate_phrase(phrase, quenya_dict):\n    words = phrase.split()\n    translated = []\n    for word in words:\n        # Strip punctuation and lower\n        clean = word.strip('.,:;()[]{}!?"], ['clean])\n        else:\n            # Try to find if gloss contains the word as a substring? Not easy.\n            # Keep original (English) as fallback\n            translated.append(word)\n    return \' \'.join(translated)\n\n# Test\nquenya_dict = load_eldamo_dict(\'/tmp/neo-quenya.html\')\n# Example: translate \'provider\'\nprint(\'provider ->\', quenya_dict.get(\'provider\', \'??\'))\nprint(\'search ->\', quenya_dict.get(\'search\', \'??\'))\nprint(\'result ->\', quenya_dict.get(\'result\', \'??\'))\nprint(\'authentication ->\', quenya_dict.get(\'authentication\', \'??\'))\n# Save the dictionary as Python file for later use\nwith open(\'/tmp/quenya_dict.py\', \'w\', encoding=ENCODING) as f:\n    f.write(\'quenya_dict = {\n\')\n    for k in sorted(quenya_dict):\n        f.write(f\'    {json.dumps(k)}: {json.dumps(quenya_dict[k])},\n\')\n    f.write(\'}\n\')\nprint("Saved dictionary']]