solidprivacy-nl commited on
Commit
4334fb3
·
1 Parent(s): 98118c4

Add Dutch recognizer integration tests

Browse files
tests/test_dutch_recognizers_integration.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dutch_recognizers import get_dutch_recognizers, get_dutch_entity_names
2
+ from test_cases.legal_regression_cases import EXPECTED_CANDIDATE_TYPES
3
+
4
+
5
+ INTEGRATION_TEXT = """
6
+ Zaaknummer: 10598721 / UE VERZ 26-441.
7
+ De wederpartij verwees naar intern incidentnummer INC-2026-0912.
8
+ In het dossier wordt daarnaast verwezen naar camerabeeld met referentie CAM-MAAS-2026-0518.
9
+ Claimreferentie verzekeraar: CLM-2026-112233.
10
+ De verhuurder heeft de melding geregistreerd onder reparatienummer REP-2026-4410.
11
+ Afdeling bestuursrecht
12
+ Zaaknummer: ARN 26/4412
13
+ Afdeling vreemdelingenzaken
14
+ Zaaknummer: NL26.12345
15
+ De gemeente gebruikt zaaknummer GEM-HLM-2026-2210.
16
+ Zaaknummer: 200.345.678/01 OK
17
+ KvK-nummer vennootschap: 76543210
18
+ """
19
+
20
+
21
+ def _run_lightweight_recognizers(text: str):
22
+ entities = get_dutch_entity_names(include_legal=True)
23
+ results = []
24
+ for recognizer in get_dutch_recognizers(supported_language="en"):
25
+ if hasattr(recognizer, "load"):
26
+ recognizer.load()
27
+ results.extend(recognizer.analyze(text, entities=entities, nlp_artifacts=None))
28
+ return results
29
+
30
+
31
+ def _value_map(results, text: str):
32
+ mapped = {}
33
+ for result in results:
34
+ value = text[result.start : result.end]
35
+ mapped.setdefault(value, set()).add(result.entity_type)
36
+ return mapped
37
+
38
+
39
+ def test_dutch_recognizers_detect_v11_1_legal_reference_values():
40
+ results = _run_lightweight_recognizers(INTEGRATION_TEXT)
41
+ by_value = _value_map(results, INTEGRATION_TEXT)
42
+
43
+ expected_values = {
44
+ "10598721 / UE VERZ 26-441",
45
+ "INC-2026-0912",
46
+ "CAM-MAAS-2026-0518",
47
+ "CLM-2026-112233",
48
+ "REP-2026-4410",
49
+ "ARN 26/4412",
50
+ "NL26.12345",
51
+ "GEM-HLM-2026-2210",
52
+ "200.345.678/01 OK",
53
+ "76543210",
54
+ }
55
+
56
+ missing = expected_values - set(by_value)
57
+ assert not missing, f"Recognizer integration missed values: {sorted(missing)}"
58
+
59
+
60
+ def test_dutch_recognizers_assign_v11_1_reference_entity_types():
61
+ results = _run_lightweight_recognizers(INTEGRATION_TEXT)
62
+ by_value = _value_map(results, INTEGRATION_TEXT)
63
+
64
+ expected_subset = {
65
+ value: entity_type
66
+ for value, entity_type in EXPECTED_CANDIDATE_TYPES.items()
67
+ if value in INTEGRATION_TEXT and value != "XX123X" and value != "WR-KLANT-2026-7712" and value != "DOSS/2026/1189"
68
+ }
69
+
70
+ mismatches = {
71
+ value: {"expected": expected_type, "actual": sorted(by_value.get(value, set()))}
72
+ for value, expected_type in expected_subset.items()
73
+ if expected_type not in by_value.get(value, set())
74
+ }
75
+ assert not mismatches, f"Recognizer integration type mismatches: {mismatches}"
76
+
77
+
78
+ def test_dutch_recognizers_return_value_only_not_context_label():
79
+ results = _run_lightweight_recognizers(INTEGRATION_TEXT)
80
+ values = {INTEGRATION_TEXT[result.start : result.end] for result in results}
81
+
82
+ assert "Zaaknummer: 10598721 / UE VERZ 26-441" not in values
83
+ assert "intern incidentnummer INC-2026-0912" not in values
84
+ assert "Claimreferentie verzekeraar: CLM-2026-112233" not in values
85
+ assert "KvK-nummer vennootschap: 76543210" not in values