# Job Resolvers

> **Relevant source files**
> * [ArWikiCats/jsons/jobs/activists_keys.json](../ArWikiCats/jsons/jobs/activists_keys.json)
> * [ArWikiCats/new/handle_suffixes.py](../ArWikiCats/new/handle_suffixes.py)
> * [ArWikiCats/new_resolvers/jobs_resolvers/mens.py](../ArWikiCats/new_resolvers/jobs_resolvers/mens.py)
> * [ArWikiCats/new_resolvers/jobs_resolvers/utils.py](../ArWikiCats/new_resolvers/jobs_resolvers/utils.py)
> * [ArWikiCats/new_resolvers/jobs_resolvers/womens.py](../ArWikiCats/new_resolvers/jobs_resolvers/womens.py)
> * [ArWikiCats/new_resolvers/nationalities_resolvers/ministers_resolver.py](../ArWikiCats/new_resolvers/nationalities_resolvers/ministers_resolver.py)
> * [ArWikiCats/translations/__init__.py](../ArWikiCats/translations/__init__.py)
> * [ArWikiCats/translations/build_data/__init__.py](../ArWikiCats/translations/build_data/__init__.py)
> * [ArWikiCats/translations/funcs.py](../ArWikiCats/translations/funcs.py)
> * [ArWikiCats/translations/geo/__init__.py](../ArWikiCats/translations/geo/__init__.py)
> * [ArWikiCats/translations/geo/labels_country.py](../ArWikiCats/translations/geo/labels_country.py)
> * [ArWikiCats/translations/jobs/Jobs.py](../ArWikiCats/translations/jobs/Jobs.py)
> * [ArWikiCats/translations/jobs/Jobs2.py](../ArWikiCats/translations/jobs/Jobs2.py)
> * [ArWikiCats/translations/jobs/jobs_data_basic.py](../ArWikiCats/translations/jobs/jobs_data_basic.py)
> * [ArWikiCats/translations/jobs/jobs_players_list.py](../ArWikiCats/translations/jobs/jobs_players_list.py)
> * [ArWikiCats/translations/jobs/jobs_singers.py](../ArWikiCats/translations/jobs/jobs_singers.py)
> * [ArWikiCats/translations/jobs/jobs_womens.py](../ArWikiCats/translations/jobs/jobs_womens.py)
> * [ArWikiCats/translations/mixed/all_keys2.py](../ArWikiCats/translations/mixed/all_keys2.py)
> * [ArWikiCats/translations/mixed/female_keys.py](../ArWikiCats/translations/mixed/female_keys.py)
> * [ArWikiCats/translations/mixed/keys2.py](../ArWikiCats/translations/mixed/keys2.py)
> * [ArWikiCats/translations/others/__init__.py](../ArWikiCats/translations/others/__init__.py)
> * [ArWikiCats/translations/others/tax_table.py](../ArWikiCats/translations/others/tax_table.py)
> * [ArWikiCats/translations/sports/Sport_key.py](../ArWikiCats/translations/sports/Sport_key.py)
> * [ArWikiCats/translations/tv/films_mslslat.py](../ArWikiCats/translations/tv/films_mslslat.py)
> * [_work_files/data_len.json](../_work_files/data_len.json)

## Purpose and Scope

This page documents the job resolution subsystem within the ArWikiCats resolver chain. Job resolvers translate English Wikipedia categories containing occupation names into grammatically correct Arabic equivalents, handling gender agreement, nationality-occupation ordering, and specialized domains like sports jobs, religious occupations, and professional roles.

For nationality-based category resolution without job components, see [Nationality Resolvers](16.Nationality-Resolvers.md). For sports-specific categories that don't involve occupations, see [Sports Resolvers](19.Sports-Resolvers.md). For the overall resolver chain orchestration, see [Resolver Chain](14.Resolver-System.md)

---

## Job Resolution Architecture

The job resolution system operates as the fourth priority resolver in the main resolution chain (R4 in the overall architecture). It attempts to match categories after year patterns, nationalities, and country names have been tried.

### Job Resolver Execution Flow

```mermaid
flowchart TD

INPUT["Category String<br/>(e.g. 'American footballers')"]
ENTRY["resolve_jobs_main()"]
CHECK1["Gender-specific<br/>pattern?"]
MENS["Mens Job Resolver<br/>mens_jobs_data: 4,015"]
WOMENS["Womens Job Resolver<br/>jobs_womens_data: 2,954"]
NEUTRAL["Jobs_new: 1,285"]
NAT_CHECK["NAT_BEFORE_OCC<br/>pattern?"]
NAT_FIRST["Nationality-First Formatting<br/>(e.g. 'American footballers'<br/>→ 'لاعبو كرة قدم أمريكيون')"]
STANDARD["Standard Formatting<br/>(e.g. 'British actors'<br/>→ 'ممثلون بريطانيون')"]
FORMATTER["MultiDataFormatterBaseV2<br/>Pattern Substitution"]
GENDER_AGREE["Gender Agreement<br/>Apply male/female forms"]
OUTPUT["Arabic Label<br/>(e.g. 'لاعبو كرة قدم أمريكيون')"]

INPUT --> ENTRY
ENTRY --> CHECK1
CHECK1 --> MENS
CHECK1 --> WOMENS
CHECK1 --> NEUTRAL
MENS --> NAT_CHECK
WOMENS --> NAT_CHECK
NEUTRAL --> NAT_CHECK
NAT_CHECK --> NAT_FIRST
NAT_CHECK --> STANDARD
NAT_FIRST --> FORMATTER
STANDARD --> FORMATTER
FORMATTER --> GENDER_AGREE
GENDER_AGREE --> OUTPUT
```

**Sources:** ArWikiCats/new_resolvers/jobs_resolvers/**init**.py, ArWikiCats/translations/jobs/Jobs.py, ArWikiCats/translations/jobs/jobs_data_basic.py

---

## Job Data Organization

Job translation data is organized into multiple dictionaries based on gender specificity and domain specialization. The system maintains separate datasets for men's and women's occupations to ensure proper Arabic gender agreement.

### Primary Job Dictionaries

| Dictionary Name | Size | Purpose | File Location |
| --- | --- | --- | --- |
| `jobs_mens_data` | 4,015 | Men's occupations with masculine Arabic forms | ArWikiCats/jsons/jobs/ |
| `jobs_womens_data` | 2,954 | Women's occupations with feminine Arabic forms | ArWikiCats/jsons/jobs/ |
| `Jobs_new` | 1,285 | Gender-neutral occupations | ArWikiCats/jsons/jobs/ |
| `NAT_BEFORE_OCC` | 54 | Jobs requiring nationality-first ordering | ArWikiCats/jsons/jobs/ |
| `NAT_BEFORE_OCC_JOBS` | 96 | Extended nationality-first patterns | ArWikiCats/jsons/jobs/jobs_data_basic.py |
| `RELIGIOUS_KEYS_PP` | 33 | Religious occupation translations | ArWikiCats/jsons/jobs/jobs_data_basic.py |

### Specialized Job Datasets

```mermaid
flowchart TD

BASE["Base Job Data"]
GENDER["Gender-Specific"]
DOMAIN["Domain-Specific"]
PATTERNS["Pattern-Specific"]
MENS["jobs_mens_data<br/>4,015 entries"]
WOMENS["jobs_womens_data<br/>2,954 entries"]
SHORT["short_womens_jobs<br/>485 entries"]
SPORTS["PLAYERS_TO_MEN_WOMENS_JOBS<br/>1,345 entries"]
RELIGIOUS["RELIGIOUS_KEYS_PP<br/>33 entries"]
SINGERS["MEN_WOMENS_SINGERS<br/>432 entries"]
NAT_BEFORE["NAT_BEFORE_OCC<br/>54 base patterns"]
NAT_JOBS["NAT_BEFORE_OCC_JOBS<br/>96 extended patterns"]
SPORT_VAR["SPORT_JOB_VARIANTS<br/>571 entries"]

subgraph subGraph0 ["Job Data Hierarchy"]
    BASE
    GENDER
    DOMAIN
    PATTERNS
    MENS
    WOMENS
    SHORT
    SPORTS
    RELIGIOUS
    SINGERS
    NAT_BEFORE
    NAT_JOBS
    SPORT_VAR
    BASE --> GENDER
    BASE --> DOMAIN
    BASE --> PATTERNS
    GENDER --> MENS
    GENDER --> WOMENS
    GENDER --> SHORT
    DOMAIN --> SPORTS
    DOMAIN --> RELIGIOUS
    DOMAIN --> SINGERS
    PATTERNS --> NAT_BEFORE
    PATTERNS --> NAT_JOBS
    PATTERNS --> SPORT_VAR
end
```

**Sources:** ArWikiCats/translations/**init**.py, _work_files/data_len.json, ArWikiCats/translations/jobs/Jobs.py, ArWikiCats/translations/jobs/jobs_data_basic.py, ArWikiCats/translations/jobs/jobs_players_list.py

---

## Core Job Resolver Functions

### resolve_jobs_main

The `resolve_jobs_main` function serves as the primary entry point for job category resolution. It orchestrates the resolution pipeline by attempting multiple resolver strategies in sequence.

```mermaid
flowchart TD

INPUT["Category String"]
MAIN["resolve_jobs_main()"]
CHAIN["Resolution Chain"]
R1["resolve_languages_labels()"]
RETURN1["Return label"]
R2["te4_2018_Jobs()"]
RETURN2["Return label"]
R3["Lang_work()"]
RETURN3["Return label"]
R4["resolve_jobs_internal()"]
RETURN4["Return label"]
EMPTY["Return ''"]
OUTPUT["Arabic Label"]

INPUT --> MAIN
MAIN --> CHAIN
CHAIN --> R1
R1 --> RETURN1
R1 --> R2
R2 --> RETURN2
R2 --> R3
R3 --> RETURN3
R3 --> R4
R4 --> RETURN4
R4 --> EMPTY
RETURN1 --> OUTPUT
RETURN2 --> OUTPUT
RETURN3 --> OUTPUT
RETURN4 --> OUTPUT
EMPTY --> OUTPUT
```

### Resolution Priority Levels

The job resolver attempts multiple resolution strategies in this priority order:

1. **Language-based labels** (`resolve_languages_labels`): Handles categories like "French-language singers" or "German-language activists"
2. **Year-country-job patterns** (`te4_2018_Jobs`): Resolves categories with temporal and geographic components like "2018 British footballers"
3. **Language work patterns** (`Lang_work`): Alternative language-based job resolution
4. **Core job resolution** (`resolve_jobs_internal`): Primary job dictionary lookup using gender-specific data

**Sources:** ArWikiCats/new_resolvers/jobs_resolvers/**init**.py, ArWikiCats/make_bots/countries_names_with_sports/t4_2018_jobs.py

---

## Job Resolution with Code Mapping

This diagram maps natural language category patterns to the specific resolver functions and data dictionaries used in the codebase.

```mermaid
flowchart TD

CAT1["'American footballers'"]
FUNC1["resolve_jobs_main()"]
CAT2["'British female actors'"]
CAT3["'German bishops'"]
CAT4["'French-language singers'"]
CHECK["Gender Detection"]
DATA1["jobs_mens_data<br/>['footballers': 'لاعبو كرة قدم']"]
DATA2["jobs_womens_data<br/>['actors': 'ممثلات']"]
DATA3["RELIGIOUS_KEYS_PP<br/>['bishops': 'أساقفة']"]
DATA4["Lang_work()<br/>language_key_translations"]
NAT["All_Nat<br/>['american': NationalityEntry(...)]"]
FORMATTER1["MultiDataFormatterBaseV2<br/>'{nat} {job}' → '{job_ar} {nat_ar}'"]
FORMATTER2["FormatDataV2<br/>'{lang}-language {job}' → '{job_ar} باللغة {lang_ar}'"]
OUTPUT1["'لاعبو كرة قدم أمريكيون'"]
OUTPUT2["'ممثلات بريطانيات'"]
OUTPUT3["'أساقفة ألمان'"]
OUTPUT4["'مغنون باللغة الفرنسية'"]

subgraph subGraph0 ["Category Patterns to Code Entities"]
    CAT1
    FUNC1
    CAT2
    CAT3
    CAT4
    CHECK
    DATA1
    DATA2
    DATA3
    DATA4
    NAT
    FORMATTER1
    FORMATTER2
    OUTPUT1
    OUTPUT2
    OUTPUT3
    OUTPUT4
    CAT1 --> FUNC1
    CAT2 --> FUNC1
    CAT3 --> FUNC1
    CAT4 --> FUNC1
    FUNC1 --> CHECK
    CHECK --> DATA1
    CHECK --> DATA2
    CHECK --> DATA3
    CHECK --> DATA4
    DATA1 --> NAT
    DATA2 --> NAT
    DATA3 --> NAT
    NAT --> FORMATTER1
    DATA4 --> FORMATTER2
    FORMATTER1 --> OUTPUT1
    FORMATTER1 --> OUTPUT2
    FORMATTER1 --> OUTPUT3
    FORMATTER2 --> OUTPUT4
end
```

**Sources:** ArWikiCats/new_resolvers/jobs_resolvers/**init**.py, ArWikiCats/translations/jobs/Jobs.py, ArWikiCats/translations/nats/Nationality.py, ArWikiCats/translations_formats/DataModel/model_data_v2.py

---

## NAT_BEFORE_OCC Pattern Handling

The `NAT_BEFORE_OCC` (Nationality Before Occupation) pattern system handles English categories where the nationality precedes the occupation, requiring special word order transformation in Arabic. For certain occupations, Arabic grammar prefers the occupation before the nationality, opposite to the English order.

### NAT_BEFORE_OCC Data Structure

```python
# Example entries from NAT_BEFORE_OCC
{
    "footballers": "لاعبو كرة القدم",
    "basketball players": "لاعبو كرة السلة",
    "baseball players": "لاعبو كرة القاعدة",
    "rugby players": "لاعبو الرجبي",
    "cricketers": "لاعبو الكريكيت"
}
```

### Pattern Transformation Logic

```mermaid
flowchart TD

INPUT1["'American footballers'"]
SPLIT["Split Components"]
NAT_PART["Nationality: 'American'"]
JOB_PART["Job: 'footballers'"]
LOOKUP1["Check NAT_BEFORE_OCC<br/>Key: 'footballers'"]
FOUND["Value: 'لاعبو كرة القدم'"]
STANDARD_FLOW["Use standard jobs_mens_data"]
NAT_LOOKUP["All_Nat lookup<br/>'american' → NationalityEntry"]
GENDER["Extract gender form<br/>males: 'أمريكيون'"]
COMBINE["Combine: Job + Nationality"]
OUTPUT1["'لاعبو كرة القدم أمريكيون'<br/>(Job-first order)"]
OUTPUT2["'ممثلون أمريكيون'<br/>(Standard order)"]

subgraph subGraph0 ["NAT_BEFORE_OCC Processing"]
    INPUT1
    SPLIT
    NAT_PART
    JOB_PART
    LOOKUP1
    FOUND
    STANDARD_FLOW
    NAT_LOOKUP
    GENDER
    COMBINE
    OUTPUT1
    OUTPUT2
    INPUT1 --> SPLIT
    SPLIT --> NAT_PART
    SPLIT --> JOB_PART
    JOB_PART --> LOOKUP1
    LOOKUP1 --> FOUND
    LOOKUP1 --> STANDARD_FLOW
    FOUND --> NAT_LOOKUP
    NAT_LOOKUP --> GENDER
    GENDER --> COMBINE
    COMBINE --> OUTPUT1
    STANDARD_FLOW --> OUTPUT2
end
```

### NAT_BEFORE_OCC vs Standard Job Resolution

| Pattern Type | English Example | Arabic Output | Word Order |
| --- | --- | --- | --- |
| NAT_BEFORE_OCC | American footballers | لاعبو كرة القدم أمريكيون | Job → Nationality |
| NAT_BEFORE_OCC | German basketball players | لاعبو كرة السلة ألمان | Job → Nationality |
| Standard | British actors | ممثلون بريطانيون | Job → Nationality |
| Standard | French writers | كتاب فرنسيون | Job → Nationality |

**Note:** Both patterns result in Job→Nationality order in Arabic, but `NAT_BEFORE_OCC` entries use expanded job phrases (e.g., "لاعبو كرة القدم" instead of just "لاعبو")

**Sources:** ArWikiCats/translations/jobs/jobs_data_basic.py:7-54, ArWikiCats/new_resolvers/jobs_resolvers/mens.py, ArWikiCats/translations/nats/Nationality.py

---

## Gender-Specific Job Resolution

The job resolver implements comprehensive gender-aware translation to ensure proper Arabic gender agreement. The system maintains separate dictionaries and applies gender-specific transformations.

### Gender Detection and Routing

```mermaid
flowchart TD

INPUT["Category String"]
DETECT["Gender Detection Logic"]
CHECK1["Contains 'female'<br/>or 'women'?"]
FEMALE_PATH["Female Job Resolution"]
CHECK2["Contains 'male'<br/>or 'men'?"]
MALE_PATH["Male Job Resolution"]
NEUTRAL_PATH["Neutral/Default Resolution"]
LOOKUP1["jobs_womens_data<br/>2,954 entries"]
LOOKUP2["jobs_mens_data<br/>4,015 entries"]
LOOKUP3["Jobs_new<br/>1,285 entries"]
GENDER_FORM1["Apply feminine forms<br/>NationalityEntry.females"]
GENDER_FORM2["Apply masculine forms<br/>NationalityEntry.males"]
GENDER_FORM3["Context-dependent forms"]
FORMAT1["MultiDataFormatterBaseV2<br/>{'{female}'} placeholder"]
FORMAT2["MultiDataFormatterBaseV2<br/>{'{male}'} placeholder"]
FORMAT3["Standard formatting"]
OUTPUT["Arabic Label<br/>with correct gender"]

INPUT --> DETECT
DETECT --> CHECK1
CHECK1 --> FEMALE_PATH
CHECK1 --> CHECK2
CHECK2 --> MALE_PATH
CHECK2 --> NEUTRAL_PATH
FEMALE_PATH --> LOOKUP1
MALE_PATH --> LOOKUP2
NEUTRAL_PATH --> LOOKUP3
LOOKUP1 --> GENDER_FORM1
LOOKUP2 --> GENDER_FORM2
LOOKUP3 --> GENDER_FORM3
GENDER_FORM1 --> FORMAT1
GENDER_FORM2 --> FORMAT2
GENDER_FORM3 --> FORMAT3
FORMAT1 --> OUTPUT
FORMAT2 --> OUTPUT
FORMAT3 --> OUTPUT
```

### Gender-Specific Dictionary Structure

```python
# Example from jobs_mens_data
jobs_mens_data = {
    "footballers": "لاعبو كرة قدم",
    "actors": "ممثلون",
    "writers": "كتاب",
    "politicians": "سياسيون"
}

# Example from jobs_womens_data
jobs_womens_data = {
    "footballers": "لاعبات كرة قدم",
    "actors": "ممثلات",
    "writers": "كاتبات",
    "politicians": "سياسيات"
}

# Example from short_womens_jobs (485 entries)
# Used for gender transformation: male form → female form
short_womens_jobs = {
    "لاعبو": "لاعبات",
    "ممثلون": "ممثلات",
    "كتاب": "كاتبات"
}
```

### Gender Agreement with Nationalities

When combining jobs with nationalities, the system uses `NationalityEntry` gender forms:

| Category | Job Dictionary | Nationality Form | Result |
| --- | --- | --- | --- |
| American footballers (male) | jobs_mens_data | NationalityEntry.males | لاعبو كرة قدم أمريكيون |
| American footballers (female) | jobs_womens_data | NationalityEntry.females | لاعبات كرة قدم أمريكيات |
| British actors (male) | jobs_mens_data | NationalityEntry.males | ممثلون بريطانيون |
| British actors (female) | jobs_womens_data | NationalityEntry.females | ممثلات بريطانيات |

**Sources:** ArWikiCats/translations/jobs/Jobs.py, ArWikiCats/translations/jobs/jobs_womens.py:9-485, ArWikiCats/new_resolvers/jobs_resolvers/mens.py, ArWikiCats/new_resolvers/jobs_resolvers/womens.py, ArWikiCats/translations/nats/Nationality.py

---

## Religious and Specialty Job Resolution

The job resolver includes specialized handling for religious occupations and other domain-specific jobs that require different translation patterns.

### Religious Jobs Processing

```mermaid
flowchart TD

INPUT["Religious Category<br/>(e.g., 'German bishops')"]
CHECK["Check RELIGIOUS_KEYS_PP"]
REL_DATA["RELIGIOUS_KEYS_PP<br/>33 entries"]
STANDARD["Standard job resolution"]
ENTRIES["Example entries:<br/>'bishops': 'أساقفة'<br/>'priests': 'قساوسة'<br/>'rabbis': 'حاخامات'"]
NAT["Combine with nationality"]
FORMATTER["MultiDataFormatterBaseV2"]
OUTPUT["'أساقفة ألمان'"]

INPUT --> CHECK
CHECK --> REL_DATA
CHECK --> STANDARD
REL_DATA --> ENTRIES
ENTRIES --> NAT
NAT --> FORMATTER
FORMATTER --> OUTPUT
```

### Religious Keys Structure

The `RELIGIOUS_KEYS_PP` dictionary contains 33 religious occupation translations:

```css
RELIGIOUS_KEYS_PP = {
    "bishops": "أساقفة",
    "priests": "قساوسة",
    "rabbis": "حاخامات",
    "imams": "أئمة",
    "monks": "رهبان",
    "nuns": "راهبات",
    # ... 27 more entries
}
```

### Specialty Job Categories

| Specialty Domain | Dictionary | Size | Example Keys |
| --- | --- | --- | --- |
| Sports Jobs | PLAYERS_TO_MEN_WOMENS_JOBS | 1,345 | "football players", "basketball players" |
| Sport Variants | SPORT_JOB_VARIANTS | 571 | "footballers", "cricketers" |
| Singers | MEN_WOMENS_SINGERS | 432 | "singers", "vocalists" |
| Religious | RELIGIOUS_KEYS_PP | 33 | "bishops", "priests", "rabbis" |

**Sources:** ArWikiCats/translations/jobs/jobs_data_basic.py:124-172, ArWikiCats/translations/jobs/jobs_players_list.py, ArWikiCats/new_resolvers/jobs_resolvers/**init**.py

---

## Job Resolver Integration Points

### Integration with Main Resolution Chain

The job resolver integrates into the main resolution chain through `resolve_label_ar()` in the following sequence:

```mermaid
flowchart TD

ENTRY["resolve_label_ar()"]
R1["Year Patterns"]
R2["Nationality Resolvers"]
R3["Country Name Resolvers"]
R4["resolve_jobs_main()"]
INTERNAL["Job Resolution Pipeline"]
LANG["Language-based jobs"]
YEAR_COUNTRY["Year-country-job"]
CORE["Core job dictionaries"]
MENS["jobs_mens_data"]
WOMENS["jobs_womens_data"]
NEUTRAL["Jobs_new"]
RETURN["Return label"]
R5["Sports Resolvers"]

ENTRY --> R1
R1 --> R2
R2 --> R3
R3 --> R4
R4 --> INTERNAL
INTERNAL --> LANG
LANG --> YEAR_COUNTRY
YEAR_COUNTRY --> CORE
CORE --> MENS
CORE --> WOMENS
CORE --> NEUTRAL
R4 --> RETURN
R4 --> R5
```

### Data Flow Through Formatters

```mermaid
flowchart TD

INPUT["Job + Nationality<br/>Components"]
FORMATTER["MultiDataFormatterBaseV2"]
PLACEHOLDERS["Placeholder Substitution"]
P1["{'{job}'} → 'footballers'"]
P2["{'{job_ar}'} → 'لاعبو كرة قدم'"]
P3["{'{nat}'} → 'american'"]
P4["{'{male}'} → 'أمريكيون'"]
PATTERN["Pattern:<br/>'{nat} {job}' →<br/>'{job_ar} {male}'"]
SUBSTITUTE["Substitute values"]
OUTPUT["'لاعبو كرة قدم أمريكيون'"]

subgraph subGraph0 ["Job Formatting Pipeline"]
    INPUT
    FORMATTER
    PLACEHOLDERS
    P1
    P2
    P3
    P4
    PATTERN
    SUBSTITUTE
    OUTPUT
    INPUT --> FORMATTER
    FORMATTER --> PLACEHOLDERS
    PLACEHOLDERS --> P1
    PLACEHOLDERS --> P2
    PLACEHOLDERS --> P3
    PLACEHOLDERS --> P4
    P1 --> PATTERN
    P2 --> PATTERN
    P3 --> PATTERN
    P4 --> PATTERN
    PATTERN --> SUBSTITUTE
    SUBSTITUTE --> OUTPUT
end
```

**Sources:** ArWikiCats/main_processers/main_resolve.py, ArWikiCats/new_resolvers/reslove_all.py, ArWikiCats/translations_formats/DataModel/model_data_v2.py

---

## Job Resolution Examples

### Example Resolution Paths

| English Category | Resolution Path | Dictionary Used | Arabic Output |
| --- | --- | --- | --- |
| American footballers | NAT_BEFORE_OCC → jobs_mens_data | NAT_BEFORE_OCC, All_Nat | لاعبو كرة القدم أمريكيون |
| British female actors | Gender detection → jobs_womens_data | jobs_womens_data, All_Nat | ممثلات بريطانيات |
| German bishops | RELIGIOUS_KEYS_PP | RELIGIOUS_KEYS_PP, All_Nat | أساقفة ألمان |
| French-language singers | Lang_work | language_key_translations | مغنون باللغة الفرنسية |
| 2018 Brazilian footballers | te4_2018_Jobs | NAT_BEFORE_OCC, YEAR_DATA | لاعبو كرة القدم برازيليون في 2018 |

### Complex Job Category Handling

For categories with multiple components (nationality + job + time/location), the job resolver coordinates with other resolvers:

1. **Time component** extracted by year resolvers
2. **Nationality component** matched against `All_Nat` (799 entries)
3. **Job component** looked up in appropriate gender-specific dictionary
4. **Pattern formatter** combines components in correct Arabic word order
5. **Gender agreement** applied to all adjective forms

**Sources:** ArWikiCats/new_resolvers/jobs_resolvers/**init**.py, ArWikiCats/make_bots/countries_names_with_sports/t4_2018_jobs.py, changelog.md:156-188

---

## Performance and Caching

The job resolver implements caching strategies to optimize repeated lookups:

### Caching Mechanisms

| Function | Caching Method | Purpose |
| --- | --- | --- |
| `resolve_jobs_main` | `functools.lru_cache` | Cache final resolution results |
| `load_jobs_data` | Module-level singleton | Load dictionaries once at startup |
| Formatter instances | Result memoization | Cache pattern matching results |

### Memory Footprint

Job-related data occupies approximately:

* `jobs_mens_data`: ~4,015 entries
* `jobs_womens_data`: ~2,954 entries
* `Jobs_new`: ~1,285 entries
* Supporting data (NAT_BEFORE_OCC, RELIGIOUS_KEYS_PP, etc.): ~700 entries
* **Total**: ~8,900 job translation entries loaded into memory

**Sources:** changelog.md:42, ArWikiCats/translations/jobs/, ArWikiCats/config.py
