fix problem from claude

This commit is contained in:
SlimusMinus
2026-10-20 00:37:43 +03:00
parent f01f776d32
commit 28d91ce6d4
31 changed files with 994 additions and 284 deletions

View File

@@ -1,20 +1,23 @@
from pathlib import Path
def normalize_word(word: str) -> str:
return word.strip().lower().replace("", "").replace("ё", "е")
class ProfanityDictionary:
def __init__(
self,
file_path: str
file_path: str | Path
):
self.words = self.load(file_path)
def load(
self,
file_path: str
) -> set[str]:
file_path: str | Path
) -> frozenset[str]:
path = Path(file_path)
@@ -23,22 +26,21 @@ class ProfanityDictionary:
f"Profanity dictionary not found: {file_path}"
)
with open(
path,
"r",
encoding="utf-8"
) as file:
return {
line.strip().lower().replace("\ufeff", "")
return frozenset(
normalize_word(line)
for line in file
if line.strip()
}
if normalize_word(line)
)
def contains(
self,
word: str
) -> bool:
return word in self.words
return word in self.words