fix(ai): ignore generic phrases and stopwords in voice name extraction
This commit is contained in:
@@ -375,8 +375,17 @@ def _extract_name_candidate(text: str | None, language: str) -> tuple[str | None
|
||||
|
||||
candidate = _normalize_name_candidate(raw)
|
||||
if candidate:
|
||||
lower_cand = candidate.lower()
|
||||
stopwords = {
|
||||
"здравствуйте", "привет", "алло", "да", "нет", "добрый", "день",
|
||||
"саламатсыз", "сәлеметсіз", "ба", "бе", "ау", "слышно", "интернет", "не", "работает", "вопрос", "у", "меня"
|
||||
}
|
||||
cand_words = set(lower_cand.split())
|
||||
if cand_words.issubset(stopwords) or len(lower_cand) < 2:
|
||||
return None, False
|
||||
|
||||
word_count = len(re.findall(r"[^\W\d_]+(?:[-'][^\W\d_]+)*", raw, flags=re.UNICODE))
|
||||
if word_count <= 3 and not _name_followup_needed(raw):
|
||||
if word_count <= 2 and not _name_followup_needed(raw):
|
||||
return candidate, False
|
||||
return candidate, True
|
||||
return None, False
|
||||
|
||||
Reference in New Issue
Block a user