53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import Any, Protocol
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class FieldEvidence:
|
|
field_name: str
|
|
method: str
|
|
confidence: float
|
|
evidence: str = ""
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class ExtractedJob:
|
|
url: str
|
|
title: str
|
|
employer_name: str = ""
|
|
external_id: str = ""
|
|
location_text: str = ""
|
|
region: str = ""
|
|
postal_code: str = ""
|
|
country: str = ""
|
|
description_html: str = ""
|
|
description_text: str = ""
|
|
language: str = ""
|
|
date_posted: str = ""
|
|
valid_through: str = ""
|
|
employment_types: list[str] = field(default_factory=list)
|
|
workplace_type: str = ""
|
|
compensation: dict[str, Any] = field(default_factory=dict)
|
|
skills_required: list[str] = field(default_factory=list)
|
|
skills_preferred: list[str] = field(default_factory=list)
|
|
raw: dict[str, Any] = field(default_factory=dict)
|
|
evidence: list[FieldEvidence] = field(default_factory=list)
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class ExtractionResult:
|
|
jobs: list[ExtractedJob]
|
|
parser_key: str
|
|
parser_version: str
|
|
confidence: float
|
|
warnings: list[str] = field(default_factory=list)
|
|
|
|
|
|
class SourceAdapter(Protocol):
|
|
parser_key: str
|
|
parser_version: str
|
|
|
|
def extract(self, content: str, *, url: str) -> ExtractionResult: ...
|