diff --git a/src/JobsMedical.Web/Services/Scraping/IngestionService.cs b/src/JobsMedical.Web/Services/Scraping/IngestionService.cs index 9188f3b..c0c5eee 100644 --- a/src/JobsMedical.Web/Services/Scraping/IngestionService.cs +++ b/src/JobsMedical.Web/Services/Scraping/IngestionService.cs @@ -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, "پزشک متخصص", "پزشک"); }