46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import re
|
|
|
|
from .normalization import normalize_token
|
|
|
|
SUPPORT_TERMS = [
|
|
"first line",
|
|
"1st line",
|
|
"helpdesk",
|
|
"service desk",
|
|
"telefonische support",
|
|
"support utilisateurs",
|
|
]
|
|
CONSULTANCY_TERMS = [
|
|
"consultancy",
|
|
"consultant",
|
|
"bij klanten",
|
|
"chez nos clients",
|
|
"customer sites",
|
|
]
|
|
TRAVEL_TERMS = ["verplaatsingen", "travel required", "déplacements", "rijbewijs b"]
|
|
PUBLIC_SECTOR_TERMS = ["overheid", "gemeente", "provincie", "publieke sector", "service public"]
|
|
|
|
|
|
def term_ratio(text: str, terms: list[str]) -> float:
|
|
normalized = normalize_token(text)
|
|
hits = sum(1 for term in terms if normalize_token(term) in normalized)
|
|
return min(1.0, hits / max(1, len(terms) / 2))
|
|
|
|
|
|
def extract_deterministic_features(title: str, description: str) -> dict[str, object]:
|
|
text = f"{title}\n{description}"
|
|
normalized = normalize_token(text)
|
|
experience_years = [
|
|
int(v) for v in re.findall(r"\b(\d{1,2})\s*(?:jaar|years?|ans)\b", normalized)
|
|
]
|
|
return {
|
|
"support_ratio": term_ratio(text, SUPPORT_TERMS),
|
|
"consultancy_ratio": term_ratio(text, CONSULTANCY_TERMS),
|
|
"travel_ratio": term_ratio(text, TRAVEL_TERMS),
|
|
"public_sector_signal": term_ratio(text, PUBLIC_SECTOR_TERMS),
|
|
"experience_years_max": max(experience_years) if experience_years else None,
|
|
"word_count": len(normalized.split()),
|
|
}
|