feat: add deterministic Apec query derivation
This commit is contained in:
parent
4d57af0b86
commit
ac78bee74b
3
src/job_research/apec/__init__.py
Normal file
3
src/job_research/apec/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from job_research.apec.query_derivation import derive_apec_queries
|
||||||
|
|
||||||
|
__all__ = ["derive_apec_queries"]
|
||||||
19
src/job_research/apec/query_derivation.py
Normal file
19
src/job_research/apec/query_derivation.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
from job_research.models import CandidateProfileOutput
|
||||||
|
|
||||||
|
|
||||||
|
def derive_apec_queries(profile: CandidateProfileOutput) -> list[str]:
|
||||||
|
queries: list[str] = []
|
||||||
|
seen: set[str] = set()
|
||||||
|
|
||||||
|
for target_role in profile.target_roles:
|
||||||
|
query = target_role.strip()
|
||||||
|
if not query or query in seen:
|
||||||
|
continue
|
||||||
|
|
||||||
|
seen.add(query)
|
||||||
|
queries.append(query)
|
||||||
|
|
||||||
|
if len(queries) == 5:
|
||||||
|
break
|
||||||
|
|
||||||
|
return queries
|
||||||
26
tests/apec/test_query_derivation.py
Normal file
26
tests/apec/test_query_derivation.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
from job_research.apec.query_derivation import derive_apec_queries
|
||||||
|
from job_research.models import CandidateProfileOutput
|
||||||
|
|
||||||
|
|
||||||
|
def test_derive_apec_queries_preserves_order_dedupes_and_caps_at_five() -> None:
|
||||||
|
profile = CandidateProfileOutput(
|
||||||
|
target_roles=[
|
||||||
|
"Data Engineer",
|
||||||
|
"Analytics Engineer",
|
||||||
|
"Data Engineer",
|
||||||
|
"BI Engineer",
|
||||||
|
"Junior Data Platform Engineer",
|
||||||
|
"ML Engineer",
|
||||||
|
"Backend Engineer",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
queries = derive_apec_queries(profile)
|
||||||
|
|
||||||
|
assert queries == [
|
||||||
|
"Data Engineer",
|
||||||
|
"Analytics Engineer",
|
||||||
|
"BI Engineer",
|
||||||
|
"Junior Data Platform Engineer",
|
||||||
|
"ML Engineer",
|
||||||
|
]
|
||||||
Loading…
x
Reference in New Issue
Block a user