-- Example analytical queries (DuckDB). Replace the path with your local copy or -- 'hf://datasets//ottoman-ledger/ottoman_ledger.parquet'. -- Rule of thumb: count records with count(distinct source_record_id); sum money only from -- unnest(amounts) and filter amount_kind, so totals are not added to item values. -- 1. Coverage: records and events per court and century SELECT court_name, (volume_gregorian_start // 100) + 1 AS century, count(DISTINCT source_record_id) AS records, count(*) FILTER (WHERE event_index > 0) AS events FROM 'ottoman_ledger.parquet' GROUP BY ALL ORDER BY century, records DESC; -- 2. Epistemic status: how often claims are proven, denied or settled SELECT primary_category, event_status, count(*) AS n FROM 'ottoman_ledger.parquet' WHERE event_status IN ('allegation', 'denial', 'testimony', 'judicial_finding', 'settlement') GROUP BY ALL ORDER BY primary_category, n DESC; -- 3. House and vineyard sale prices in akçe by decade (completed or acknowledged sales only) SELECT (hijri_year // 10) * 10 AS hijri_decade, a.asset_type, count(*) AS sales, median(m.value) AS median_price_akce FROM (SELECT *, unnest(assets) AS a, unnest(amounts) AS m FROM 'ottoman_ledger.parquet') WHERE event_type ILIKE '%sale%' AND event_status IN ('completed_transaction', 'acknowledgement') AND a.asset_type IN ('house', 'vineyard') AND m.amount_kind = 'price' AND m.currency_normalized = 'akce' GROUP BY ALL ORDER BY hijri_decade, a.asset_type; -- 4. Women as parties: share of events with an explicitly female participant, by category SELECT primary_category, avg(CASE WHEN list_contains(list_transform(participants, lambda p: p.gender_explicit), 'female') THEN 1 ELSE 0 END) AS share_with_female_party, count(*) AS events FROM 'ottoman_ledger.parquet' WHERE event_index > 0 GROUP BY ALL ORDER BY events DESC; -- 5. Manumissions with the explicit origin of the freed person SELECT gregorian_date_start, p.name_original, p.origin_explicit, court_name, source_record_id FROM (SELECT *, unnest(participants) AS p FROM 'ottoman_ledger.parquet') WHERE primary_category = 'slavery_manumission' AND event_type ILIKE '%manumi%' AND p.origin_explicit IS NOT NULL ORDER BY gregorian_date_start; -- 6. Probate inventories: estate totals and the stated vs summed check SELECT source_record_id, hijri_year, m.value AS stated_total, m.currency_normalized, list_filter(validation_issues, lambda i: i.code LIKE 'inventory_total%')[1].detail AS reconciliation FROM (SELECT *, unnest(amounts) AS m FROM 'ottoman_ledger.parquet') WHERE primary_category = 'inheritance_wealth' AND m.amount_kind = 'total'; -- 7. Official price ceilings (narh) for bread and meat over time SELECT hijri_year, a.description, m.value, m.currency_original, a.unit_original FROM (SELECT *, unnest(assets) AS a FROM 'ottoman_ledger.parquet') t, LATERAL (SELECT unnest(t.amounts) AS m) x WHERE document_type = 'narh_price_list' AND (a.description ILIKE '%bread%' OR a.description ILIKE '%meat%' OR a.description ILIKE '%mutton%') AND m.amount_index = a.value_amount_index; -- 8. Mapping: geocoded neighbourhood-level events (coordinates are modern centroids) SELECT neighborhood, latitude, longitude, count(*) AS events FROM 'ottoman_ledger.parquet' WHERE geographic_precision = 'neighborhood_modern_centroid' GROUP BY ALL ORDER BY events DESC; -- 9. Quality filter: keep only events whose automatic checks passed, never mix with model confidence SELECT validation_status, count(*) AS events, avg(model_confidence) AS mean_self_reported_confidence FROM 'ottoman_ledger.parquet' GROUP BY ALL; -- 10. Records that could not be extracted (coverage audit) SELECT volume_id, count(*) AS records_without_events FROM 'ottoman_ledger.parquet' WHERE event_type IN ('unextracted', 'no_event_extracted') GROUP BY ALL ORDER BY records_without_events DESC;