dnd-name-generator/language/languages/dwarvish/rules.py

25 lines
576 B
Python
Raw Normal View History

2023-11-24 05:48:03 -08:00
import logging
import re
from language.rules import default_rules
from language.types import Language
logger = logging.getLogger("dwarvish-rules")
def cannot_start_with_repeated_consonants(language: Language, word: str) -> bool:
found = re.compile(r"(^[bcdfghklmnpqrstvwxz]{2})").search(word)
if not found:
return True
first, second = found.group(1)
if first == second:
logger.debug(f"{word} starts with a repeated consonant.")
return False
return True
rules = default_rules
rules.add(cannot_start_with_repeated_consonants)