TomassiniDigital commited on
Commit
0d9f10f
·
verified ·
1 Parent(s): fb056cf

Upload 2 files

Browse files
Files changed (2) hide show
  1. anonymizer.py +1 -1
  2. recognizers.py +6 -2
anonymizer.py CHANGED
@@ -10,7 +10,7 @@ _CURRENCY_PREFIX = re.compile(r"^(€|EUR|\$|£)\s*", flags=re.IGNORECASE)
10
  # Es. il modello può etichettare un CIG come NUMERO_DOCUMENTO o N_LICENZA — qui
11
  # verifichiamo se rientra in un nostro pattern e rinominiamo l'etichetta.
12
  _RECLASSIFY_PATTERNS: dict[str, re.Pattern] = {
13
- "CIG": re.compile(r"^[0-9A-Z]{10}$"),
14
  "CUP": re.compile(r"^[A-Z][0-9A-Z]{14}$"),
15
  "REA": re.compile(r"^[A-Z]{2}-\d{4,7}$"),
16
  }
 
10
  # Es. il modello può etichettare un CIG come NUMERO_DOCUMENTO o N_LICENZA — qui
11
  # verifichiamo se rientra in un nostro pattern e rinominiamo l'etichetta.
12
  _RECLASSIFY_PATTERNS: dict[str, re.Pattern] = {
13
+ "CIG": re.compile(r"^(?:\d{7}[0-9A-F]{3}|[A-Z][0-9A-F]{9})$"),
14
  "CUP": re.compile(r"^[A-Z][0-9A-Z]{14}$"),
15
  "REA": re.compile(r"^[A-Z]{2}-\d{4,7}$"),
16
  }
recognizers.py CHANGED
@@ -129,9 +129,13 @@ def _r(entity: str, name: str, regex: str, score: float, context: list[str]) ->
129
  # ---------------------------------------------------------------------------
130
  _RECOGNIZERS: list[PatternRecognizer] = [
131
 
132
- # CIG – Codice Identificativo Gara
 
 
 
 
133
  _r("CIG", "cig",
134
- r"\b[0-9A-Z]{10}\b", 0.6,
135
  ["CIG", "codice identificativo", "gara", "appalto"]),
136
 
137
  # CUP – Codice Unico di Progetto
 
129
  # ---------------------------------------------------------------------------
130
  _RECOGNIZERS: list[PatternRecognizer] = [
131
 
132
+ # CIG – Codice Identificativo Gara (formato ufficiale ANAC):
133
+ # • CIG Ordinario : 7 cifre + 3 alfanumerici hex (0-9, A-F)
134
+ # • CIG Unico : lettera A-U + 9 alfanumerici hex
135
+ # • Smart CIG : lettera V-Z + 9 alfanumerici hex
136
+ # Le ultime due si fondono in: [A-Z][0-9A-F]{9}
137
  _r("CIG", "cig",
138
+ r"\b(?:\d{7}[0-9A-F]{3}|[A-Z][0-9A-F]{9})\b", 0.6,
139
  ["CIG", "codice identificativo", "gara", "appalto"]),
140
 
141
  # CUP – Codice Unico di Progetto