solidprivacy commited on
Commit
51357c4
·
verified ·
1 Parent(s): 49f8ffe

Fix missing Dutch legal example dropdown

Browse files
Files changed (1) hide show
  1. presidio_streamlit.py +48 -6
presidio_streamlit.py CHANGED
@@ -61,16 +61,41 @@ except Exception: # keep app usable while new file is being added
61
  def get_dutch_legal_entity_names():
62
  return []
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  try:
65
  from legal_test_examples import TEST_CASES, get_example_names, get_example_text
66
- except Exception:
 
67
  TEST_CASES = []
68
 
69
  def get_example_names():
70
- return []
71
 
72
  def get_example_text(name: str):
73
- return ""
74
 
75
 
76
  st.set_page_config(
@@ -324,15 +349,32 @@ uploaded_file = st.file_uploader(
324
  uploaded_file_type = None
325
  input_text = "".join(demo_text)
326
 
327
- if st_recognition_profile == "Dutch Legal Strict" and TEST_CASES:
328
  with st.expander("Use a fake Dutch legal test example", expanded=False):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
  sample_name = st.selectbox(
330
  "Load synthetic legal example",
331
- ["Do not load a test example"] + get_example_names(),
332
  index=0,
333
  )
334
  if sample_name != "Do not load a test example" and uploaded_file is None:
335
- input_text = get_example_text(sample_name)
 
 
 
336
  st.caption("Loaded synthetic example text. No real personal data is included.")
337
 
338
  if uploaded_file is not None:
 
61
  def get_dutch_legal_entity_names():
62
  return []
63
 
64
+ LEGAL_EXAMPLES_IMPORT_ERROR = None
65
+
66
+ EMBEDDED_LEGAL_TEST_CASES = {
67
+ "Fallback - referenties en administratieve nummers": """Cliëntnummer: CL-FAM-55201.
68
+ De schoolreferentie is HRZ-SAM-2026-04.
69
+ In het verslag van Stichting Horizonzorg wordt dezelfde referentie HRZ-SAM-2026-04 genoemd.
70
+ De factuur met nummer FACT-2026-4481 is onbetaald gebleven.
71
+ De interne klantreferentie van eiser is WR-KLANT-2026-7712.
72
+ De zaakreferentie is ZK-WOON-55091.
73
+ Het artikel 7:669 BW mag niet worden gemaskeerd.
74
+ De datum 15-12-2026 mag niet als referentie worden gezien.
75
+ Het bedrag € 1.250,00 mag niet als referentie worden gezien.
76
+ """,
77
+ "Fallback - familierecht contextbehoud": """Aan de Rechtbank Amsterdam
78
+
79
+ Zaaknummer C/13/701234 / FA RK 26-321
80
+ Rekestnummer RK-2026-887
81
+
82
+ Verzoeker Fatima El Amrani verzoekt wijziging van de omgangsregeling
83
+ met betrekking tot de minderjarige Sami El Amrani.
84
+ Verweerder Peter Bakker woont aan Laan van Meerdervoort 55, 2517 AM Den Haag.
85
+ """,
86
+ }
87
+
88
  try:
89
  from legal_test_examples import TEST_CASES, get_example_names, get_example_text
90
+ except Exception as exc:
91
+ LEGAL_EXAMPLES_IMPORT_ERROR = exc
92
  TEST_CASES = []
93
 
94
  def get_example_names():
95
+ return list(EMBEDDED_LEGAL_TEST_CASES.keys())
96
 
97
  def get_example_text(name: str):
98
+ return EMBEDDED_LEGAL_TEST_CASES.get(name, "")
99
 
100
 
101
  st.set_page_config(
 
349
  uploaded_file_type = None
350
  input_text = "".join(demo_text)
351
 
352
+ if st_recognition_profile == "Dutch Legal Strict":
353
  with st.expander("Use a fake Dutch legal test example", expanded=False):
354
+ example_names = get_example_names()
355
+ if LEGAL_EXAMPLES_IMPORT_ERROR is not None:
356
+ st.warning(
357
+ "Could not import legal_test_examples.py. Showing embedded fallback examples. "
358
+ "Check that legal_test_examples.py exists in the Space root. "
359
+ f"Import error: {LEGAL_EXAMPLES_IMPORT_ERROR}"
360
+ )
361
+ elif not example_names:
362
+ st.warning(
363
+ "No legal examples were loaded from legal_test_examples.py. "
364
+ "Check that TEST_CASES contains examples and that get_example_names() returns names."
365
+ )
366
+ example_names = list(EMBEDDED_LEGAL_TEST_CASES.keys())
367
+
368
  sample_name = st.selectbox(
369
  "Load synthetic legal example",
370
+ ["Do not load a test example"] + example_names,
371
  index=0,
372
  )
373
  if sample_name != "Do not load a test example" and uploaded_file is None:
374
+ example_text = get_example_text(sample_name)
375
+ if not example_text and sample_name in EMBEDDED_LEGAL_TEST_CASES:
376
+ example_text = EMBEDDED_LEGAL_TEST_CASES[sample_name]
377
+ input_text = example_text
378
  st.caption("Loaded synthetic example text. No real personal data is included.")
379
 
380
  if uploaded_file is not None: