fix: normalize inspection resource names
This commit is contained in:
1 parent
6b9c6c2f84
commit
2752673682
3 files changed
+24
-5
No files matched your search
+15
-4
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from difflib import SequenceMatcher
|
||||
import re
|
||||
from typing import Literal
|
||||
|
||||
@@ -155,13 +156,23 @@ class InspectionResult:
|
||||
|
||||
def _inspection_resource_value(name: str) -> int:
|
||||
normalized = " ".join(name.casefold().replace("ё", "е").split())
|
||||
if "надпис" in normalized or "ядовит" in normalized:
|
||||
letters = re.sub(r"[^а-я]", "", normalized)
|
||||
if "надпис" in letters or "ядовит" in letters:
|
||||
return 0
|
||||
if normalized in ("паутина", "паук"):
|
||||
if "лугов" in normalized and "зме" in normalized:
|
||||
return 1
|
||||
if (
|
||||
"щитоморд" in letters
|
||||
or "аспид" in letters
|
||||
or letters in ("змея", "змеи")
|
||||
or SequenceMatcher(None, letters, "змея").ratio() >= 0.8
|
||||
):
|
||||
return 0
|
||||
if "паутин" in letters or "паутн" in letters or normalized == "паук":
|
||||
return 7
|
||||
if normalized == "обычный мох":
|
||||
if "обычн" in normalized and "мох" in normalized:
|
||||
return 3
|
||||
if normalized == "водяной мох":
|
||||
if "водян" in normalized and "мох" in normalized:
|
||||
return 2
|
||||
return 1
|
||||
|
||||
|
||||
Reference in new issue
Block a user