fix: tighten cv prose-tail rejection

Reject experience-like lines when the company side continues with prose, including in-Paris and before-moving patterns, while preserving valid single-word titles and lowercase company names.
This commit is contained in:
Antoine 2026-05-28 16:31:36 +02:00
parent c57d9b0275
commit fe201831ba
2 changed files with 32 additions and 1 deletions

View File

@ -32,6 +32,7 @@ EXPERIENCE_PROSE_MARKERS = {
"joining",
"left",
"leaving",
"in",
"moved",
"moving",
"relocated",
@ -123,6 +124,8 @@ def _looks_like_experience_line(line: str) -> bool:
def _looks_like_prose_company(company: str) -> bool:
company_words = [word.strip(".,;:!?()[]{}") for word in company.split()]
return any(
word and word.islower() and word in EXPERIENCE_PROSE_MARKERS
word
and word.lower() in EXPERIENCE_PROSE_MARKERS
and not (word.isupper() and len(word) <= 3)
for word in company_words
)

View File

@ -73,6 +73,34 @@ def test_extract_cv_signals_ignores_prose_after_company_name() -> None:
assert extracted["experience_entries"] == []
def test_extract_cv_signals_ignores_in_paris_prose_tail() -> None:
text = dedent(
"""
Tonio
Location: France
Data Engineer at Microsoft in Paris
"""
).strip()
extracted = extract_cv_signals(text)
assert extracted["experience_entries"] == []
def test_extract_cv_signals_ignores_before_moving_prose_tail() -> None:
text = dedent(
"""
Tonio
Location: France
Senior Engineer at Microsoft Before moving to Paris.
"""
).strip()
extracted = extract_cv_signals(text)
assert extracted["experience_entries"] == []
def test_extract_pdf_text_skips_blank_pages(monkeypatch) -> None:
class FakePage:
def __init__(self, text: str | None) -> None: