Sofara: an incident library for Egyptian refereeing

Sofara organises 45 incidents from 51 Egyptian Premier League 2026/27 matches into a searchable Arabic library. Each verdict comes from the Referees Committee's own published post-round rulings. Built as a proposal for the EFA Referees Committee; submitted in Oct 2026.

Ground truth is the hard part

Public data cannot say whether a refereeing decision was correct. The only correct or incorrect labels are the Committee's own post-round videos, so I store the call and the card as two separate verdicts, and the tool never judges a decision itself. 20 of the 45 incidents have an official ruling.

Of those 20, the Committee called the on-field decision correct in 16 and incorrect in 4, and judged the card correct in 17 and incorrect in 3. The VAR changed the decision in 4 incidents. 33 incidents link to the source video.

Incidents per round, and how many have an official ruling (round 6 is one match, the derby).
  • Round 11 of 4
  • Round 23 of 9
  • Round 36 of 8
  • Round 44 of 12
  • Round 56 of 7
  • Round 60 of 5

What I rejected before writing code

Synthetic referees. Planting “hidden skills” in fake referees makes any validation circular. Synthetic data appears only in labelled mock-ups.

A second-hand referee table. A betting site's table had duplicate names from transliteration, totals that did not equal yellow plus red, a negative red-card value, many referees with 1 to 3 matches, and foreign referees mixed in.

Per-referee card rates. Referees given derbies and big matches show more cards, and public data cannot control for match difficulty, so these rates would mislead.

Data and pipeline

Version-controlled CSVs go through strict loaders: a bad row fails the whole build and lists every problem. The result is a SQLite database where integrity is enforced in SQL, with CHECK, FOREIGN KEY and UNIQUE constraints and four triggers, not only in Python.

It holds 109 officials, each with one ID. Names are never guessed, and every alias is recorded with its evidence. It also holds 52 expert opinions from 14 named sources, 11 of them independent experts with 47 opinions, published by 15 outlets. Each opinion is summarised in my own words and links to where it was said.

51 matches, 45 incidents, 109 officials, 52 opinions.

Statistics that refuse to overclaim

Each disputed case gets a disagreement score (2 × minority ÷ opinions) and a Wilson 95% interval for the share who back the decision. An expert's agreement rate with the Committee appears only after 10 ruled cases. Fewer than 3 independent opinions is labelled “small sample”, with no verdict.

The wording is always “agreement with the Committee”, never “accuracy”.

Only 5 cases have two or more independent opinions, and the experts split in 4 of them. With a sample that small, the interval is the honest part of the output.

The search is rule-based, not machine learning. It normalises Arabic spelling, matches whole words through common prefixes and suffixes, and maps 84 colloquial terms to structured fields. Every result says why it matched.

The search is built never to miss a case: a test fails if any expected incident is absent, and it runs on a 19-query gold set that I wrote myself, so it is a guard, not an independent score. Precision is reported for context only. The weakest query, “الكرة بيده”, returns many other handball cases (precision 0.125 at worst), and some of those extra hits may be relevant. A parity test checks that the page's JavaScript search returns the same cases as the Python search on all 19.

Engineering

The core package uses only the Python standard library. 157 tests run in CI on Ubuntu and Windows with Python 3.10 and 3.13, and the site deploys to GitHub Pages after every green run. 18 architecture decision records explain the choices above.

Limits and next step

There is no trained model in Sofara. It is data engineering, statistics and search, and 45 incidents is a small sample. Next I plan to add semantic search with Arabic sentence embeddings and score it with Recall@k on the existing 19-query set.