Generalize doctor-role correction: trust the keyword parser over the AI default
CI/CD / CI · dotnet build (push) Successful in 53s
CI/CD / Deploy · hamkadr (push) Successful in 2m39s

Replace the per-role (dentist/specialist) patches with one rule: «پزشک عمومی» is the AI fallback,
so whenever the keyword parser already extracted a more specific role from the same text, use that
(dentist, lab, OR tech, mislabeled nurse, …). Falls back to «پزشک متخصص» when the text says
specialist but the parser found nothing more specific. Only ever overrides the weak GP default, so
genuine GP ads are untouched. Applies to new ingests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-21 18:01:58 +03:30
parent d39546389e
commit fbf8deaa8c
@@ -581,16 +581,17 @@ public class IngestionService
}
if (pubRoles.Count == 0) pubRoles.Add(roles.First());
// Doctor-role guard: the AI tends to default an unclear (or even a clearly NON-GP) doctor ad
// to «پزشک عمومی» — a dentist ad («دعوت به همکاری دندانپزشک») published as «استخدام پزشک
// عمومی», an ENT/specialist ad likewise. When the chosen role is a generic doctor but the ad
// text unambiguously names a more specific role the model missed, correct it.
if (pubRoles[0].Name is "پزشک عمومی" or "پزشک متخصص")
// Doctor-role guard. «پزشک عمومی» is the AI's fallback when it's unsure, so it mislabels
// clearly-specific doctor ads — a dentist ad («دعوت به همکاری دندانپزشک») or an ENT/specialist
// one published as «استخدام پزشک عمومی». Rather than patch role-by-role, trust the keyword
// parser: if IT already found a more specific role in the same text, use that; otherwise fall
// back to «پزشک متخصص» when the text says specialist. Only ever overrides the weak GP default.
if (pubRoles[0].Name == "پزشک عمومی")
{
var t = NormalizeFa(raw.RawText);
if (t.Contains("دندانپزشک") || t.Contains("دندان پزشک"))
pubRoles[0] = ResolveOrCreateRole(roles, "دندانپزشک", "دندانپزشک");
else if (pubRoles[0].Name == "پزشک عمومی" && LooksSpecialist(raw.RawText))
var specific = parsed.RoleNames.FirstOrDefault(n => NormalizeFa(n) != NormalizeFa("پزشک عمومی"));
if (specific is not null)
pubRoles[0] = ResolveOrCreateRole(roles, specific, null);
else if (LooksSpecialist(raw.RawText))
pubRoles[0] = ResolveOrCreateRole(roles, "پزشک متخصص", "پزشک");
}